Free Support Forum -

Get Glyph bounding box based on font size


I want to get the bounding box of a glyph based on font size (i don’t need to render it on an image)
This bounding box should be in pixel.
How can i get this ? The documentation of Aspose.Font is very light… :frowning:



We are checking the related information at our end and will get back to you shortly.


Bounding box of glyph does not depend upon font size. Coordinates of Glyph are related to so-called em square.

From specification, em square is “an imaginary square that is used to size and align glyphs. The dimensions of the em square typically are those of the full body height of a font plus some extra spacing to prevent lines of text from colliding when typeset without extra leading.”

Coordinates of the glyph are described in font units or FUnits.

From the specification: “Since the number of units per em does not vary with the point size at which the font is displayed, the absolute size of a FUnit varies as the point size varies. Because FUnits are relative to the em square, a given location on a glyph will have the same coordinate location in FUnits regardless of the point size at which the font is rendered”

So the size of font does not affect coordinates of the glyph, it is used to scale glyph coordinates from font coordinate system to appropriate graphical device.

Maybe you want to get a bounding box of the glyph with scaled coordinates - related to the font size. But font-size value is not enough for this case. The actual coordinate value depends on graphical device, such device characteristics as dots per inch. Let this characteristic be variable DotsPerInch.

In this case, first we must divide this DotsPerInch value on font’s internal dots per inch (this value always 72), so we get such a variable - ResDotsPerInch = DotsPerInch/72.

And then every coordinate can be calculated for font size as:

ScaledCoordinate = OriginalCoordinate*FontSize*ResDotsPerInch