Issue with compound character font rendering in openGL using FTGL

292 views Asked by At

In my application, FTGL renders unicode characters of true type fonts well except compound characters. Compound character is a combination of unicode consonant and vowel sounds.

For example, in an indic language Tamil, the following string input

"கா கி கீ கு கூ கெ கே கை கொ கோ கௌ"

is displayed as

"tamil compound characters in openGL"

in the openGL viewer.

output of some characters is not same as input.

Can anybody help on this?

my code snippet,

    std::ifstream fontFile("latha.ttf", std::ios::binary);//tamil unicode font
    if (fontFile.fail())
        return NULL;
    fontFile.seekg(0, std::ios::end);
    std::fstream::pos_type fontFileSize = fontFile.tellg();
    fontFile.seekg(0);
    unsigned char *fontBuffer = new unsigned char[fontFileSize];
    fontFile.read((char *)fontBuffer, fontFileSize);        

    FTBitmapFont* m_pFTFont = new FTBitmapFont(fontBuffer, fontFileSize);
    m_pFTFont->Render("கா கி கீ கு கூ கெ கே கை கொ கோ  கௌ");
1

There are 1 answers

1
Nicol Bolas On

Welcome to the wonderful world of "complex text layout". Enjoy your stay ;)

To put it simply, a script that uses complex text layout does not have a simple 1:1 mapping between Unicode codepoints and the glyph to be rendered. And Tamil is such a script.

FTGL only handles scripts that have simple layout, because complex text layout is complex (very much so). So it's not going to be able to reproduce Tamil script correctly.

You will need to use a layout engine like Harfbuzz to layout your text. FTGL can still render the script, but you'll need Harfbuzz to tell you which glyphs in the font to render.