Hi Team,
It would be great if you can resolve my problem.
The font size value is mismatched while comparing with Windows 7 and other operating system for `Cambria Math` font by using `graphics. MeasureString` API.
Issue reproducing code snippet:
char c = '\u23A1'; string text = c.ToString(); System.Drawing.Font font = new System.Drawing.Font("Cambria Math", 8, FontStyle.Regular); StringFormat format = new StringFormat(StringFormat.GenericTypographic); //Remove the linelimit flag from create stringformat object. //The behavior of the linelimit flag is “only entire lines are laid out in the formatting rectangle”, //By default layout continues until the end of the text, or until no more lines are visible as a result of clipping”. format.FormatFlags &= ~StringFormatFlags.LineLimit; format.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces; format.FormatFlags |= StringFormatFlags.NoClip; format.Trimming = StringTrimming.Word; SizeF size = new SizeF(); Bitmap bitmap = new Bitmap(400, 200); Graphics graphics = Graphics.FromImage(bitmap); size.Height = graphics.MeasureString(text[0].ToString(), font, new PointF(0, 0), format).Height;
Please find different values in the following table.
Operating system | Font Height |
Windows 10 | 10.666666 |
Windows 7 | 59.52083 |
Could you please let me know the reason for this and what we have to do to retrieve the same font height in all operating systems.
Please let me know if you have any other concerns.
Thanks,
Sivasubramani.