[Qt-interest] QFontEngineFT::cmapCache may not handle non-Latin characters?

mpsuzuki at hiroshima-u.ac.jp mpsuzuki at hiroshima-u.ac.jp
Wed Jan 5 08:35:26 CET 2011


Hi,

This is my first post to qt-interest. If my post is inappropriate
to here and there is more appropriate one, please let me know.

--

When I was doing some experiments to support UVS by Qt (on
GNU/Linux, sorry), I had a question:

	QFontEngineFT::cmapCache[] may not handle most
	non-Latin characters?

Here I quote a part from qfontengine_ft.cpp how
QFontEngineFT::cmapCache[] is maintained.

----------------------------------------------------------
            unsigned int uc = getChar(str, i, len);
            glyphs->glyphs[glyph_pos] = uc < QFreetypeFace::cmapCacheSize ? freetype->cmapCache[uc] : 0;
            if ( !glyphs->glyphs[glyph_pos] ) {
                glyph_t glyph;
#if !defined(QT_NO_FONTCONFIG)
                if (!mtx) {
                    mtx = qt_fontdatabase_mutex();
                    mtx->lock();
                }

                if (FcCharSetHasChar(freetype->charset, uc)) {
#else
                if (false) {
#endif
                redo0:
                    glyph = FT_Get_Char_Index(face, uc);
                    if (!glyph && (uc == 0xa0 || uc == 0x9)) {
                        uc = 0x20;
                        goto redo0;
                    }
                } else {
                    FT_Set_Charmap(face, freetype->symbol_map);
                    glyph = FT_Get_Char_Index(face, uc);
                    FT_Set_Charmap(face, freetype->unicode_map);
                }
                glyphs->glyphs[glyph_pos] = glyph;
                if (uc < QFreetypeFace::cmapCacheSize)
                    freetype->cmapCache[uc] = glyph;
            }
----------------------------------------------------------

Here, UCS codepoint (uc) is directly used as the indice to
cmapCache[] array. Considering that cmapCache[] array is
in fixed size (according to qfontengine_ft_p.h, its length
is 0x200 items), QFontEngineFT object can cache codepoint-
glyphID pair if codepoint is less than 0x200. It looks like
as if the codepoint-glyphID for non-Latin characters cannot
be cached. So, IPA extensions (U+0250 - U+02AF), Greek
(U+0370 - U+03FF), Cyrillic (U+0400 - U+052F), Armenian,
Hebrew, Syriac, etc etc cannot be cached.

Is this my misunderstanding? And, if it is not my mis-
understanding, there is any possibility to improve it?

Maybe the support for the scripts using many character
codepoints (like CJK Unified Ideographs, Hangul, Unified
Canadian Aboriginal Syllabics, Yi scripts, etc) may require
drastic changes of the design, but the support for many
scripts using rather-small character collections won't
be so drastic.

Regards,
mpsuzuki



More information about the Qt-interest-old mailing list