Word wrapping with Drawables? #1686
-
Hi there, is it possible to use word wrapping with Drawables drawing text? const int fontSize = 11 * SCALE;
const int originX = 15 * SCALE;
var originY = 215 * SCALE - guildOffset;
var sanitizedBlurb = new string(member.Blurb.Where(AllowedSpecialCharacters.Contains).ToArray());
background.Draw(Fonts.TF2Secondary()
.FontPointSize(fontSize)
.FillColor(MagickColors.WhiteSmoke)
.Gravity(Gravity.Northwest)
.Text(originX, originY, $"\"{sanitizedBlurb}\"")); This works great as-is!...except when a dumb user (such as myself while testing) sets their (ignore the other weird issues with this image - I am migrating some ImageSharp code to Magick.NET and haven't quite squashed all the bugs...) I believe there is a non-Drawables way to accomplish this, but I was curious if 1) it were possible with what I have now, or 2) what other options are available to me to prevent overly long text like this from overflowing past other elements of the image, whether it's words or one single really long word. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
After a bit more fooling around and fixing a bug that I thought was the issue all along, I decided to just go the non-Drawables route. It's a lot more ugly, but it works, so who cares! const int fontSize = 11 * SCALE;
const int originX = 15 * SCALE;
var originY = 215 * SCALE - guildOffset;
const int textBoxWith = 360 * SCALE;
var sanitizedBlurb = new string(member.Blurb.Where(AllowedSpecialCharacters.Contains).ToArray());
var settings = new MagickReadSettings
{
Font = "Data/TF2secondary.ttf",
BackgroundColor = MagickColors.Transparent,
FillColor = MagickColors.WhiteSmoke,
StrokeColor = MagickColors.Transparent,
FontPointsize = fontSize,
Width = textBoxWith
};
using var image = new MagickImage($"caption:\"{sanitizedBlurb}\"", settings);
background.Composite(image, originX, originY, CompositeOperator.Atop); |
Beta Was this translation helpful? Give feedback.
After a bit more fooling around and fixing a bug that I thought was the issue all along, I decided to just go the non-Drawables route. It's a lot more ugly, but it works, so who cares!