Fix OpenType language definition tags and array access. This resolves issue #171

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/174/head
Michele Calgaro 4 months ago
parent a30f5359f0
commit 14c414378d
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -2264,6 +2264,8 @@ struct OTScripts {
int flags; int flags;
}; };
// Refer to https://learn.microsoft.com/en-us/typography/opentype/spec/scripttags
// for OpenType language tags definition
static const OTScripts ot_scripts [] = { static const OTScripts ot_scripts [] = {
// // European Alphabetic Scripts // // European Alphabetic Scripts
// Latin, // Latin,
@ -2351,6 +2353,7 @@ static const OTScripts ot_scripts [] = {
{ FT_MAKE_TAG( 'c', 'a', 'n', 's' ), 0 }, { FT_MAKE_TAG( 'c', 'a', 'n', 's' ), 0 },
// Mongolian, // Mongolian,
{ FT_MAKE_TAG( 'm', 'o', 'n', 'g' ), 0 }, { FT_MAKE_TAG( 'm', 'o', 'n', 'g' ), 0 },
// // Symbols // // Symbols
// CurrencySymbols, // CurrencySymbols,
{ FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 }, { 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 }, { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 },
// Braille, // Braille,
{ FT_MAKE_TAG( 'b', 'r', 'a', 'i' ), 0 }, { FT_MAKE_TAG( 'b', 'r', 'a', 'i' ), 0 },
// Unicode, should be used
{ FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 } // Unicode
// ### where are these? { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 },
// { FT_MAKE_TAG( 'b', 'y', 'z', 'm' ), 0 },
// { FT_MAKE_TAG( 'D', 'F', 'L', 'T' ), 0 }, // Tagalog,
// ### Hangul Jamo { FT_MAKE_TAG( 't', 'g', 'l', 'g' ), 0 },
// { FT_MAKE_TAG( 'j', 'a', 'm', 'o' ), 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) TQOpenType::TQOpenType(TQFontEngineXft *fe)
@ -2435,7 +2451,10 @@ TQOpenType::~TQOpenType()
bool TQOpenType::checkScript(unsigned int script) 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; uint tag = ot_scripts[script].tag;
int requirements = ot_scripts[script].flags; int requirements = ot_scripts[script].flags;
@ -2477,7 +2496,11 @@ void TQOpenType::selectScript(unsigned int script, const Features *features)
if (current_script == script) if (current_script == script)
return; return;
assert(script < TQFont::NScripts); if (script >= TQFont::NScripts || script >= sizeof(ot_scripts) / sizeof(OTScripts))
{
return;
}
// find script in our list of supported scripts. // find script in our list of supported scripts.
uint tag = ot_scripts[script].tag; uint tag = ot_scripts[script].tag;

Loading…
Cancel
Save