[Top][All Lists]

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

[ft] How to compare freetype API's with the ttf font tables

From: samaram s
Subject: [ft] How to compare freetype API's with the ttf font tables
Date: Wed, 20 Jan 2010 10:36:45 -0500

Thank you so much werner.

> But the documents says it gives the bitmap conversion of the given
> character.  Please correct me if i am wrong.

Well, yes.  As written in the file, you have to replace `draw_bitmap'
(and consequently `show_image') with something useful.

You mean, the draw bitmap and show_image doesnt produce correct bitmap image?


> Can you please send me some sample bit of code,to compare with mine.
> Is there anyway i can get font size of 10,12 (like word doc font
> size)?

What do you mean with 10,12?  If you want glyphs rendered at 10pt
(using a resolution of 96dpi, the standard on MS Windows), simply say

 error = FT_Set_Char_Size( face, 10 * 64, 0,
                           96, 0 );

I tried the above and didnt get the correct bitmap for the given character.Attached the PNG.
 If i increase the fontsize like 50 or so i can atleast makesure the output bitmap i am getting is E.

> My goal is to get the bitmap image of the given character,

This is not trivial.  What FreeType does is to return a rendered image
of a given *glyph* index.  `FT_Load_Char' is just a convenience
function for very simple cases.  Very often, the mapping from a
character code (or codes) to a glyph index can be quite complicated
(for example, in Indic scripts).

> with the given size and family name.

This is not trivial too, since the handling of font family names is
hairy due to various compatibility issues.  FreeType just takes a font
file name as an argument, nothing more.

> Is there API to get the bitmap image too or should we have to code
> for the same?

`FT_Load_Glyph', using the FT_LOAD_RENDER flag, does this.

error = FT_Load_Char( face, text[n],FT_LOAD_RENDER );

Load_Glyph and Load_Char both does the same right?

I am looking something like below:
Say,The bitmap data starts at 78 and continues for the rest of the data.  The number of bytes of bitmap data is given by the height of the glyph multiplied by the number of bytes required to reproduce each line of pixels.  This data will produce an glyph like...
78  .****...
40  .*......
40  .*......
40  .*......
F0  ****....
40  .*......
40  .*......
40  .*......
40  .*......

I am trying to get something like above for a given character?Please help me whether i am going in a right way or not?Suggest me if i am wrong how to proceed.

Very thankful to you.


Attachment: bitmap for char E.PNG
Description: PNG image

reply via email to

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