summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2024-07-21 15:12:20 +0900
committerMichele Calgaro <[email protected]>2024-07-21 23:04:07 +0900
commite06dfea32cfd8b0b541236b2d4391f844dda3a01 (patch)
tree38fc9dded286031554383abf5a0986e6dd7d5667
parentb634a4f66f9f2f0785f03719ee1c33612880d76c (diff)
downloadtqt3-e06dfea32cfd8b0b541236b2d4391f844dda3a01.tar.gz
tqt3-e06dfea32cfd8b0b541236b2d4391f844dda3a01.zip
Fix OpenType language definition tags and array access. This resolves issue #171
Signed-off-by: Michele Calgaro <[email protected]> (cherry picked from commit 14c414378d96f7463b989384f4a0e5dd76632b6d)
-rw-r--r--src/kernel/qfontengine_x11.cpp41
1 files changed, 32 insertions, 9 deletions
diff --git a/src/kernel/qfontengine_x11.cpp b/src/kernel/qfontengine_x11.cpp
index 65ab15811..46cdf4bf0 100644
--- a/src/kernel/qfontengine_x11.cpp
+++ b/src/kernel/qfontengine_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;