joe M wrote: > 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 , > slot->bitmap.rows); ... 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 manually. > > XWriteBitmapFile(d,"test1.bmp",p,slot->bitmap.width,slot->bitmap.rows,0,0); 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). -- Glynn Clements <gl...@gclements.plus.com> _______________________________________________ xorg@lists.x.org: X.Org support Archives: http://lists.freedesktop.org/archives/xorg Info: http://lists.x.org/mailman/listinfo/xorg Your subscription address: arch...@mail-archive.com