freetype
[Top][All Lists]
Advanced

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

Re: [ft] FT_Set_Char_Size vs. FT_Set_Pixel_Sizes


From: Olumide
Subject: Re: [ft] FT_Set_Char_Size vs. FT_Set_Pixel_Sizes
Date: Fri, 18 Nov 2016 13:20:43 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

On 17/11/2016 18:25, Werner LEMBERG wrote:
I have used FT_Set_Pixel_Sizes( face , 32 , 32 ) -- because 32 by 32
is the maximum font dimension of a font in my application. Upon
inspection of the resulting face->glyph I get a bitmap that's only
about 25% of the size specified in FT_Set_Pixel_Sizes (Bitmap
details: rows = top = 22, width = 13, left = 1).  Of course I may
have completely misunderstood what FT_Set_Pixel_Sizes does.  Please
do correct me where my thinking or understanding is incorrect.

Your thinking *is* incorrect :-) FT_Set_Pixel_Sizes sets the *nominal*
size for the whole font, this is, the size the font designer thinks
the font looks best for a given pixel size.  In many cases, the
largest glyphs in the font (e.g., `|', `(', or `)') have this height,
but usually the actual glyph heights are lower.

You might try the `FT_Request_Size' function using
`FT_SIZE_REQUEST_TYPE_REAL_DIM' or `FT_SIZE_REQUEST_TYPE_BBOX' to
better approximate your desired height.  Note, however, that with
activated hinting the only possibility to exactly make a glyph fit
into a given height is trial and error: You start with an
approximation value, then look at the delta relative to the wanted
height, then decrease or increase the size as needed and try again.
If you are unfortunate, the glyph height jumps by two pixels, not
fitting your desired height at all...

I've just tried the following

FT_Size_RequestRec req = { FT_SIZE_REQUEST_TYPE_BBOX , 0 , 3450 , 0 , 0 };
FT_Request_Size( face , &req );

Where 3450 is experimentally obtained such that the bitmap has 32 rows for the tallest (pipe character). Then I loaded the character 'f'(shorter than the pipe symbol) expecting to get a bitmap with fewer rows, instead I got a bitmap with a larger number of rows.

So I returned to the previous approach and set

FT_Set_Pixel_Sizes( face , 55 , 55 );

Where the value 55 is experimentally obtained such that the resulting bitmap has 32 rows for the tallest (pipe character). Again Then I loaded the character 'f' expecting to get a bitmap with fewer rows, instead I got a bitmap with a larger number of rows.

Any advise will be much appreciated.

Regards,

- Olumide




reply via email to

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