Setting custom DPI resolution, font scaling behavior #189
-
I'm converting a large project from using System.Drawing.* over to ImageSharp (great work btw!). For example with System.Drawing: var image = new System.Drawing.Bitmap(320, 240);
image.SetResolution(600, 600); // 600 dpi
var font = new Font("Arial", 16, GraphicsUnit.Point);
// ... draw text on the image ... This produces a different result with ImageSharp as the fonts don't scale: var image = new Image<Rgba32>(320, 240);
image.Metadata.VerticalResolution = 600;
image.Metadata.HorizontalResolution = 600;
var font = new Font(SystemFonts.Find("Arial"), 16);
// ... draw text on the image ... Is there a different way to affect font scaling or am I on my own here? |
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 1 reply
-
I think I found what I'm looking for here, hopefully this helps someone else out: var drawingOptions = new DrawingOptions
{
TextOptions = new TextOptions
{
ApplyKerning = true,
DpiX = 600,
DpiY = 600
},
};
image.Mutate(c => c.DrawText(drawingOptions, "My Text", font, Color.Black, new PointF(x, y))); As a "it would be nice" if by default, the TextOptions for DrawText were to inherit the Dpi setting from the image metadata it's drawing on. But that's just my 2 cents :) |
Beta Was this translation helpful? Give feedback.
I think I found what I'm looking for here, hopefully this helps someone else out:
As a "it would be nice" if by default, the TextOptions for DrawText were to inherit the Dpi setting from the image metadata it's drawing on. But that's just my 2 cents :)