GDI+ measured font size is mismatched while comparing with Windows 7 and other operating system for `Cambria Math` font. RRS feed

  • General discussion

  • 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


    Windows 7


    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.



    Wednesday, July 11, 2018 1:24 PM

All replies

  • Any updates on this?

    - Dilli babu.

    Thursday, August 9, 2018 4:59 AM
  • This is really a bottlenecks for us. Can anyone share your ideas on this ?
    Monday, September 10, 2018 6:12 AM
  • Try also print your graphics.PageUnit property to see if they match each other.

    Additionally, check the DpiX and DpiY properties to see if scaling occurs.

    Monday, September 10, 2018 6:25 AM

    We have checked the mentioned properties, but they are same in both Windows 10 and Windows 7


    Values obtained in Windows 10 and Windows 7








    Could you please provide any other suggestions to resolve this problem?


    Wednesday, October 17, 2018 11:21 AM