[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ft] Charmap encoding, something incorrect - getting '/LYH' instead of '
From: |
Richard Baverstock |
Subject: |
[ft] Charmap encoding, something incorrect - getting '/LYH' instead of 'Live' |
Date: |
Sat, 28 Jul 2007 20:27:54 -0700 |
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;