freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft] Freetype / Microsoft GDI size mismatch


From: Tor Andersson
Subject: Re: [ft] Freetype / Microsoft GDI size mismatch
Date: Sun, 28 Feb 2010 00:39:02 +0100

Steffen,

On Fri, Feb 26, 2010 at 10:57 AM, Steffen R <address@hidden> wrote:

> LOGFONT lf = {0};
> lf.lfHeight = m_pointSize;
> // other values...
> HFONT hFont = ::CreateFontIndirect(&lf);
> HDC dc = CreateCompatibleDC(NULL);
> ::SelectObject(dc, hFont);
> ::DrawTextW(dc, text, -1, rectangle, formatFlags);
>
> The results look noticably smaller rendered with this code. I don't find
> many hints for the reason apart from the logical vs. physical resolution
> issue, but that does not solve it entirely. For example, with a given size
> of 19, multiplication with 72 and division by 96 yields 14.25 as a font
> size. Using a pixel ruler on my screen shows 12 or at most 13 pixels when
> rendered with GDI, which makes a big difference in my application.
>
> Does anyone know the reason for this? Any hints are highly appreciated.

The MSDN docs for LOGFONT state that lfHeight is in device units, so
you're asking for a 19 pixel high font. At the default resolution of windows,
this is equivalent to a point size of 14.25 as you calculated. You didn't
mention which resolution you're passing to freetype.

To get a 19 pixel high font in freetype, call:

FT_Set_Char_Size(face, 19 * 64, 19 * 64, 72, 72).

To get a 14.25 point high font in freetype at 96 dpi, call:

FT_Set_Char_Size(face, 14.25 * 64, 14.25 * 64, 96, 96).

-Tor




reply via email to

[Prev in Thread] Current Thread [Next in Thread]