Directwrite: Font height issues
I'm using Directwrite to display scrollable text in a render target, and I want to calculate how many lines of text will fit per screen.
I've been using this code to calculate the number of lines that will fit on the RT:
The results of the above code seem to be accurate for some fonts, but not for others, resulting in the RT "clipping" the text too early. For these other fonts, using
/* pTextFormat is an IDWriteTextFormat pointer, dpi_y is the desktop's vertical dpi, and GetHeight() returns the height (in pixels) of the render target. */
float size = (pTextFormat->GetFontSize()/72.0f)*dpi_y;
instead seems to work.
float size = pTextFormat->GetFontSize();
My problem is that I don't know how to tell which font should use which method, or why one method works for one font but not another.
I'm using IDWriteTextLayouts to display the text.