diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-07-21 15:12:20 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-07-21 23:02:52 +0900 |
commit | 14c414378d96f7463b989384f4a0e5dd76632b6d (patch) | |
tree | 01a163060865221f9bbbf27b36189ae676261610 | |
parent | a30f5359f03c3017fa19a6770fab32d25d22cb87 (diff) | |
download | tqt3-14c414378d96f7463b989384f4a0e5dd76632b6d.tar.gz tqt3-14c414378d96f7463b989384f4a0e5dd76632b6d.zip |
Fix OpenType language definition tags and array access. This resolves issue #171
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r-- | src/kernel/tqfontengine_x11.cpp | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/src/kernel/tqfontengine_x11.cpp b/src/kernel/tqfontengine_x11.cpp index 6363aac97..8002c42df 100644 --- a/src/kernel/tqfontengine_x11.cpp +++ b/src/kernel/tqfontengine_x11.cpp @@ -2264,6 +2264,8 @@ struct OTScripts { int flags; }; +// Refer to https://learn.microsoft.com/en-us/typography/opentype/spec/scripttags +// for OpenType language tags definition static const OTScripts ot_scripts [] = { // // European Alphabetic Scripts // Latin, @@ -2351,6 +2353,7 @@ static const OTScripts ot_scripts [] = { { FT_MAKE_TAG( 'c', 'a', 'n', 's' ), 0 }, // Mongolian, { FT_MAKE_TAG( 'm', 'o', 'n', 'g' ), 0 }, + // // Symbols // CurrencySymbols, { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 }, @@ -2370,13 +2373,26 @@ static const OTScripts ot_scripts [] = { { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 }, // Braille, { FT_MAKE_TAG( 'b', 'r', 'a', 'i' ), 0 }, -// Unicode, should be used - { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 } - // ### where are these? -// { FT_MAKE_TAG( 'b', 'y', 'z', 'm' ), 0 }, -// { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 }, - // ### Hangul Jamo -// { FT_MAKE_TAG( 'j', 'a', 'm', 'o' ), 0 }, + +// Unicode + { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 }, + +// Tagalog, + { FT_MAKE_TAG( 't', 'g', 'l', 'g' ), 0 }, +// Hanunoo, + { FT_MAKE_TAG( 'h', 'a', 'n', 'o' ), 0 }, +// Buhid, + { FT_MAKE_TAG( 'b', 'u', 'h', 'd' ), 0 }, +// Tagbanwa, + { FT_MAKE_TAG( 't', 'a', 'g', 'b' ), 0 }, + +// KatakanaHalfWidth, -- can't find it, use Katakana code + { FT_MAKE_TAG( 'k', 'a', 'n', 'a' ), 0 }, + +// Limbu, + { FT_MAKE_TAG( 'l', 'i', 'm', 'b' ), 0 }, +// TaiLe, + { FT_MAKE_TAG( 't', 'a', 'l', 'e' ), 0 } }; TQOpenType::TQOpenType(TQFontEngineXft *fe) @@ -2435,7 +2451,10 @@ TQOpenType::~TQOpenType() bool TQOpenType::checkScript(unsigned int script) { - assert(script < TQFont::NScripts); + if (script >= TQFont::NScripts || script >= sizeof(ot_scripts) / sizeof(OTScripts)) + { + return false; + } uint tag = ot_scripts[script].tag; int requirements = ot_scripts[script].flags; @@ -2477,7 +2496,11 @@ void TQOpenType::selectScript(unsigned int script, const Features *features) if (current_script == script) return; - assert(script < TQFont::NScripts); + if (script >= TQFont::NScripts || script >= sizeof(ot_scripts) / sizeof(OTScripts)) + { + return; + } + // find script in our list of supported scripts. uint tag = ot_scripts[script].tag; |