mono/mono
View on GitHubGraphics.MeasureString does not take in to account PageScale value.
Open
#6,827 opened on Feb 7, 2018
area-BCL: System.Drawinghelp wanted
Description
Steps to Reproduce
-
Create new Graphics based on Bitmap
-
Set PageScale value to say 0.5f
-
Call MeasureStringMethod to get chars and lines fitted count Code sample:
var font = new Font("Arial", 10); var bmp = new Bitmap(1, 1); //Points Test using (var graphics = Graphics.FromImage(bmp)) { graphics.PageUnit = GraphicsUnit.Point; var res = graphics.MeasureString("HELLO", font, new SizeF(float.MaxValue, float.MinValue), new StringFormat(), out var chars, out var lines); Console.WriteLine($"Points: Size={res.Width}x{res.Height}, Chars={chars}, Lines{lines}"); } //Points + scaling test using (var graphics = Graphics.FromImage(bmp)) { graphics.PageUnit = GraphicsUnit.Point; graphics.PageScale = 0.5f; var res = graphics.MeasureString("HELLO", font, new SizeF(float.MaxValue, float.MinValue), new StringFormat(), out var chars, out var lines); Console.WriteLine($"Points+Scale: Size={res.Width}x{res.Height}, Chars={chars}, Lines{lines}"); }
Current Behavior
Measurement results with PageScale =0.5f are the same as with PageScale = 1
Expected Behavior
Measurement results should be different for different PageScale values. PageScale must affect font size and measurement results.
On which platforms did you notice this
[ ] Linux Version Used: Mono version is 5.8.0.108
The issue is not reproduced on Windows + .net Framework