Trying to figure out how to render a single character represented by a FT_Bitmap in X
joe9mail at gmail.com
Sat Feb 16 12:54:49 PST 2013
>> I am trying to figure how to print one character from a FT_Bitmap
>> (freetype2 bitmap).
>> But, I am not able to get the character to display properly. I seem to
>> be missing something simple.
>> I seem to be missing something simple while creating the X pixmap
>> based on the FT_Bitmap.buffer.
>> Any thoughts, please?
>> error = FT_Load_Char( face, 'z', FT_LOAD_RENDER );
> This calls FT_Render_Glyph with a mode of FT_RENDER_MODE_NORMAL, which
> generates an 8-bpp antialiased image, whereas ...
>> p = XCreateBitmapFromData(d, w,
>> slot->bitmap.buffer, slot->bitmap.width ,
> ... this expects a 1-bpp monochrome bitmap. Pass FT_LOAD_MONOCHROME to
> FT_Load_Char to get a monochrome bitmap instead of a grey-scale image.
> Also: you're ignoring the bitmap's pitch (slot->bitmap.pitch). The
> bitmap created by FT_Load_Char isn't guaranteed to be "packed", but
> XCreateBitmapFromData() requires it to be. Also, the data in
> slot->bitmap.buffer can be top-to-bottom (positive pitch) or
> bottom-to-top (negative pitch), but XCreateBitmapFromData() only
> supports the former.
> You can get more flexibility by creating an XImage from the data then
> drawing the XImage into a Pixmap. Or you could just convert the data
Thanks a lot for your very informative comments. They were very
helpful. I am trying to get a working program based on your comments.
I will email it to the list once I have a working version.
> The ".bmp" extension is normally used for Microsoft Windows "bitmap"
> (BMP) files. XWriteBitmapFile() generates an "X bitmap" (XBM) file,
> which normally has either a ".xbm" extension or no extension (see the
> files in /usr/include/X11/bitmaps).
Oh, I did not know about ".xbm". Thanks a lot for clarifying that.
More information about the xorg