I need to measure text height and width using SkiaSharp. This is my SkiaSharp code:
SKPaint p = new SKPaint
{
Typeface = font.Typeface,
TextSize = font.Size
}
var textBounds = new SKRect(boxSize.Width, boxSize.Height, 0, 0);
p.MeasureText(text, ref textBounds);
and my old code:
System.Windows.Forms.TextRenderer.MeasureText(text, font, boxSize);
SkiaSharp code returns width:5, height:6 MeasureText code return width:15, height:17 for same font, text and boxSize
AFAIK MeasureText uses DPI machine DPI and SkiaSharp defaults to 72 but I have no idea what to do with this information.
- How can I write my SkiaSharp code to return same values as MeasureText?
- How can I check what DPI value TextRenderer.MeasureText used?