freetype
[Top][All Lists]
Advanced

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

Re: [ft] Charmap encoding, something incorrect - getting '/LYH' instead


From: Brady Duga
Subject: Re: [ft] Charmap encoding, something incorrect - getting '/LYH' instead of 'Live'
Date: Sun, 29 Jul 2007 09:19:09 -0700

It looks like you are getting the glyph index for your character code, and are then passing that to the load call that takes a character index. Either don't first translate the character code or use load_glyph instead of load_char.

--Brady

On Jul 28, 2007, at 8:27 PM, Richard Baverstock <address@hidden> wrote:

I'm using freetype2 on mac os x to display some text on an image. I load the font, get the glyph, get the bitmap, do the displaying etc., no errors. However, instead of the word "Live" being displayed, I get "/LYH".

So it looks like something with my charmap selection or the char's I'm sending to FT_Get_Char_Index are wrong. However, I can't figure out *why* they are wrong. They are the equivalent ascii/unicode values for L, i, v and e, and I'm using FT_ENCODING_UNICODE. Also tried FT_ENCODING_APPLE_ROMAN, but that didn't help.

Of interest, '/' is 'L' - 29, as are the rest of the characters ... did I miss something where I had to *add* 29 (decimal) to the equivalent ascii code?

Anyone have any suggestions?

Thanks,
Richard

###### Code for loading FT_Face #########

#define DEFAULT_ENCODING FT_ENCODING_UNICODE
       int error = FT_New_Face(m_sFTLib,
                               szFile.c_str(), 0, &m_pFont);

       if (error)
       {
           TRACE(DbgPlugins, "Unable to create new face");
           assert(0);
           break;
       }

       error = FT_Select_Charmap(m_pFont, DEFAULT_ENCODING);

       if (error)
       {
           TRACE(DbgPlugins, "Unable to set char map to encoding");
           assert(0);
       }

       // Set font size
       error = FT_Set_Pixel_Sizes(m_pFont, 0, ulSize);

       if (error)
       {
TRACE(DbgPlugins, "Unable to set pixel size to %lu", ulSize);
           assert(0);
       }

       res = Result_OK;


###### Code for getting the char/bitmap #######
       U32 ulChar = (unsigned char)m_szText.at(i);

       S32 ulGlyph = FT_Get_Char_Index(m_pFont, ulChar);

       if (ulGlyph == 0)
           TRACE(DbgPlugins, "Error finding glyph");

error = FT_Load_Char(m_pFont, ulGlyph, FT_LOAD_RENDER | FT_LOAD_MONOCHROME);

       if (error)
           TRACE(DbgPlugins, "Error loading char");

       TRACE(DbgPlugins, "Drawing 0x%08x", ulChar);

       DrawGlyph(pBuffer, ulPitch,
                 ulWidth, ulHeight,
                 ulX, ulY,
                 pSlot);

       ulX += pSlot->advance.x >> 6;






_______________________________________________
Freetype mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/freetype




reply via email to

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