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: Steffen R
Subject: Re: [ft] Freetype / Microsoft GDI size mismatch
Date: Sun, 28 Feb 2010 08:42:21 -0800 (PST)

Thank you, Tor,
I tried both of these calls and in every case the results look as I would
have expected. It's the MS GDI renderer that seems to render too small (12 -
13 pt instead of 14.25). I was hoping that someone has encountered the same
problem before and knows an explanation why GDI renders so small. I will
also try to post the problem in some GDI-related forum and post an
explanation here if I find one.
Steffen



Tor Andersson wrote:
> 
> 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
> 
> 
> 
> _______________________________________________
> Freetype mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/freetype
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Freetype---Microsoft-GDI-size-mismatch-tp27716380p27736230.html
Sent from the Freetype - User mailing list archive at Nabble.com.





reply via email to

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