Browse Source

update to latest SixLabors.Fonts

Now support text wrapping
af/merge-core
Scott Williams 9 years ago
parent
commit
0c36757911
  1. 2
      src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
  2. 7
      src/ImageSharp.Drawing/Text/DrawText.cs
  3. 6
      src/ImageSharp.Drawing/Text/TextGraphicsOptions.cs

2
src/ImageSharp.Drawing/ImageSharp.Drawing.csproj

@ -39,7 +39,7 @@
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta001">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="SixLabors.Fonts" Version="0.1.0-alpha0002" />
<PackageReference Include="SixLabors.Fonts" Version="0.1.0-alpha0005" />
<PackageReference Include="SixLabors.Shapes" Version="0.1.0-alpha0010" />
</ItemGroup>
<PropertyGroup>

7
src/ImageSharp.Drawing/Text/DrawText.cs

@ -177,13 +177,14 @@ namespace ImageSharp
dpi = new Vector2((float)source.MetaData.HorizontalResolution, (float)source.MetaData.VerticalResolution);
}
FontSpan style = new FontSpan(font)
FontSpan style = new FontSpan(font, dpi)
{
ApplyKerning = options.ApplyKerning,
TabWidth = options.TabWidth
TabWidth = options.TabWidth,
WrappingWidth = options.WrapTextWidth
};
renderer.RenderText(text, style, dpi);
renderer.RenderText(text, style);
System.Collections.Generic.IEnumerable<SixLabors.Shapes.IPath> shapesToDraw = glyphBuilder.Paths;

6
src/ImageSharp.Drawing/Text/TextGraphicsOptions.cs

@ -41,6 +41,11 @@ namespace ImageSharp.Drawing
/// </summary>
public bool UseImageResolution;
/// <summary>
/// If greater than zero determine the width at which text should wrap.
/// </summary>
public float WrapTextWidth;
/// <summary>
/// Initializes a new instance of the <see cref="TextGraphicsOptions" /> struct.
/// </summary>
@ -52,6 +57,7 @@ namespace ImageSharp.Drawing
this.TabWidth = 4;
this.AntialiasSubpixelDepth = 16;
this.UseImageResolution = false;
this.WrapTextWidth = 0;
}
/// <summary>

Loading…
Cancel
Save