[Top][All Lists]

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

Re: [ft] Ascii Space

From: Russell Shaw
Subject: Re: [ft] Ascii Space
Date: Mon, 31 Jul 2006 20:48:45 +1000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20060205 Debian/1.7.12-1.1

Werner LEMBERG wrote:
However, if the character is a space (ascii 32), then
FT_Glyph_To_Bitmap() fails with error=6 "invalid argument".

Is that normal? Even though there is no visible glyph, shouldn't it
give an all-zeros bitmap of the correct width?

Please provide a self-contained, complete example which I can compile
for testing.

libfreetype6-dev 2.2.1-2 on Debian-sid.


INCLUDES = -I/usr/include/freetype2
LIBS = -lfreetype
main(int argc, char *argv[])
    FT_Library ftlib;
    FT_Error error = FT_Init_FreeType(&ftlib);
    if(error) {
        printf("FT_init error.\n");

    char *fontname = "/usr/share/fonts/truetype/msttcorefonts/arial.ttf";

    FT_Face face;
    error = FT_New_Face(ftlib, fontname, 0, &face);

    if(error == FT_Err_Unknown_File_Format) {
        printf("FT_face error.\n");

    error = FT_Set_Char_Size(face, 0, 20*64/*20pt*/, 74, 75);
    FT_ULong keysym = ' ';
    int glyph_index = FT_Get_Char_Index(face, keysym); /* retrieve kerning 
distance and move pen position */
    error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);

    FT_Glyph glyph;

    error = FT_Get_Glyph(face->glyph, &glyph);   // must be manually destroyed 
with FT_Done_Glyph(glyph)

    if(error) {
        printf("Error loading glyph.\n");
    assert(glyph->format != FT_GLYPH_FORMAT_BITMAP);
//  This fails if the character was a space: ascii 0x32
    error = FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_MONO, 0, 1);    // 
destroy old previous glyph
    if(error) {
        printf("Error getting glyph bitmap.\n");

reply via email to

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