How to determine the maximum height in pixels of a given font?

I need to measure or somehow determine the maximum height for a given font.

I also need to determine where the base font is located.

The Graphics.MeasureString function apparently only defines the bounding box of a particular row (which is useful, but not what I need right now).

In particular, I am looking for ONLY the vertical font size in pixels. However, it should vertically place all possible lines.

Is this something you can programmatically determine?

+4
source share
1 answer

You are looking for the Height property of your font, which is the "line spacing in pixels of this font." The position of the baseline (above the top of the next line of text) is determined by the GetCellDescent method of the font family, but this is in "construction units" that must be converted to pixels ( here's how ). MSDN has an interesting article on getting font metrics.

+7
source

Source: https://habr.com/ru/post/1386038/


All Articles