简体   繁体   English

使用FTGL在openGL中进行复合字符字体渲染的问题

[英]Issue with compound character font rendering in openGL using FTGL

In my application, FTGL renders unicode characters of true type fonts well except compound characters . 在我的应用程序中,FTGL可以很好地呈现真型字体的 unicode字符( 复合字符除外) Compound character is a combination of unicode consonant and vowel sounds. 复合字符是unicode辅音和元音的组合。

For example, in an indic language Tamil, the following string input 例如,在泰米尔语印度语中,以下字符串输入

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

is displayed as 显示为

“ openGL中的泰米尔语复合字符”

in the openGL viewer . openGL查看器中

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("கா கி கீ கு கூ கெ கே கை கொ கோ  கௌ");

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. 简而言之,使用复杂文本布局的脚本在Unicode代码点和要呈现的字形之间没有简单的1:1映射。 And Tamil is such a script. 泰米尔语就是这样的剧本。

FTGL only handles scripts that have simple layout, because complex text layout is complex (very much so). FTGL仅处理具有简单布局的脚本,因为复杂的文本布局非常复杂 (非常复杂 )。 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. 您将需要使用诸如Harfbuzz之类的布局引擎来布局文本。 FTGL can still render the script, but you'll need Harfbuzz to tell you which glyphs in the font to render. FTGL仍然可以渲染脚本,但是您需要Harfbuzz来告诉您要渲染字体中的哪些字形。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM