freetype-devel
[Top][All Lists]
Advanced

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

[Devel] A beginners question


From: Callum Prentice
Subject: [Devel] A beginners question
Date: Mon, 30 Sep 2002 21:04:02 -0000 (GMT)

i would like to render a glyph in a given font into a bitmap (chunk of memory).

i have successfully built the ft2 libs and am now trying to put a sample 
application
together but i'm having some issues - for instance, FT_Get_Glyph_Bitmap doesn't 
seem to
be present in the build now so the example in tutorial.html no longer works.

here is a snippet of code (with all error checking removed) that i am using:

--------------- snip ---------------
FT_Library library;
FT_Init_FreeType ( &library );

FT_Face face;
FT_New_Face ( library, "c:/windows/fonts/arial.ttf", 0, &face );

int charCode = 'A';
int glyph_index = FT_Get_Char_Index ( face, charCode );

std::wcout << L"glyph index is " << glyph_index << std::endl;

FT_Glyph glyph;
FT_Load_Char ( face, glyph_index, FT_LOAD_DEFAULT );

FT_Get_Glyph ( face->glyph, &glyph );

FT_Glyph_To_Bitmap ( &glyph, ft_render_mode_normal, 0, 1 );

FT_BitmapGlyph  glyph_bitmap;
glyph_bitmap = (FT_BitmapGlyph)glyph;

FT_Bitmap myBitmap = glyph_bitmap->bitmap;

int rows = myBitmap.rows;
int width = myBitmap.width;
int pitch = myBitmap.pitch;

std::wcout << L"rows = " << rows << std::endl;
std::wcout << L"width = " << width << std::endl;
std::wcout << L"pitch = " << pitch << std::endl;
--------------- snip ---------------

i test the return value of ll functions and they all seem fine. the number of 
glyphs in
the font is reported as 1320 - i would've expected it to be 256 or 128 but as i 
said,
this is my first foray into font technology.  the glyph index is reported as 36 
for
character 'A', 37 for character 'B' and so on.

so, it all looks like it's probably working except that the number of rows is 1 
and
width/pitch is 2 which can't be correct.

could someone who's done this before tell me if (a) this currently the best 
method to
use and (b) if this is it, suggest why it's not working.

thanks in advance.

callum.





reply via email to

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