From 0c3675791109133792d59bb3350975711e604e4a Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Wed, 12 Apr 2017 13:06:23 +0100 Subject: [PATCH] update to latest SixLabors.Fonts Now support text wrapping --- src/ImageSharp.Drawing/ImageSharp.Drawing.csproj | 2 +- src/ImageSharp.Drawing/Text/DrawText.cs | 7 ++++--- src/ImageSharp.Drawing/Text/TextGraphicsOptions.cs | 6 ++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index 259ae4b0f..8ba0cbdd0 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -39,7 +39,7 @@ All - + diff --git a/src/ImageSharp.Drawing/Text/DrawText.cs b/src/ImageSharp.Drawing/Text/DrawText.cs index 1f5f4cdb1..eba11b5c5 100644 --- a/src/ImageSharp.Drawing/Text/DrawText.cs +++ b/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 shapesToDraw = glyphBuilder.Paths; diff --git a/src/ImageSharp.Drawing/Text/TextGraphicsOptions.cs b/src/ImageSharp.Drawing/Text/TextGraphicsOptions.cs index b58a40b34..6b09f2395 100644 --- a/src/ImageSharp.Drawing/Text/TextGraphicsOptions.cs +++ b/src/ImageSharp.Drawing/Text/TextGraphicsOptions.cs @@ -41,6 +41,11 @@ namespace ImageSharp.Drawing /// public bool UseImageResolution; + /// + /// If greater than zero determine the width at which text should wrap. + /// + public float WrapTextWidth; + /// /// Initializes a new instance of the struct. /// @@ -52,6 +57,7 @@ namespace ImageSharp.Drawing this.TabWidth = 4; this.AntialiasSubpixelDepth = 16; this.UseImageResolution = false; + this.WrapTextWidth = 0; } ///