summaryrefslogtreecommitdiff
path: root/fofi/FoFiTrueType.cc
diff options
context:
space:
mode:
authorSuzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>2012-03-26 22:31:29 +0200
committerAlbert Astals Cid <aacid@kde.org>2012-03-26 22:39:55 +0200
commit55d039ada063a9427de6dd59846ce1570ab26e9f (patch)
tree8e6b5b700ed16561776a552180dc5b4d7917edfd /fofi/FoFiTrueType.cc
parenta8b0fa4d07480242afba7751995e38eaf3147ac5 (diff)
CJK improvements
More info in the mailing list threads * script names for vertical writing mode should be differentiated for CJK * 2 workarounds for a Korean font on Microsoft Windows
Diffstat (limited to 'fofi/FoFiTrueType.cc')
-rw-r--r--fofi/FoFiTrueType.cc47
1 files changed, 36 insertions, 11 deletions
diff --git a/fofi/FoFiTrueType.cc b/fofi/FoFiTrueType.cc
index 431910da..d0bc8004 100644
--- a/fofi/FoFiTrueType.cc
+++ b/fofi/FoFiTrueType.cc
@@ -18,6 +18,7 @@
// Copyright (C) 2007 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2008, 2009 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com>
+// Copyright (C) 2012 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -2219,7 +2220,17 @@ Guint FoFiTrueType::charToTag(const char *tagName)
setup GSUB table data
Only supporting vertical text substitution.
*/
-int FoFiTrueType::setupGSUB(const char *tagName)
+int FoFiTrueType::setupGSUB(const char *scriptName)
+{
+ return setupGSUB(scriptName, NULL);
+}
+
+/*
+ setup GSUB table data
+ Only supporting vertical text substitution.
+*/
+int FoFiTrueType::setupGSUB(const char *scriptName,
+ const char *languageName)
{
Guint gsubTable;
unsigned int i;
@@ -2236,11 +2247,11 @@ int FoFiTrueType::setupGSUB(const char *tagName)
int x;
Guint pos;
- if (tagName == 0) {
+ if (scriptName == 0) {
gsubFeatureTable = 0;
return 0;
}
- scriptTag = charToTag(tagName);
+ scriptTag = charToTag(scriptName);
/* read GSUB Header */
if ((x = seekTable("GSUB")) < 0) {
return 0; /* GSUB table not found */
@@ -2277,11 +2288,25 @@ int FoFiTrueType::setupGSUB(const char *tagName)
/* read script table */
/* use default language system */
pos = gsubTable+scriptList+scriptTable;
- langSys = getU16BE(pos,&parsedOk);/* default language system */
+ langSys = 0;
+ if (languageName) {
+ Guint langTag = charToTag(languageName);
+ Guint langCount = getU16BE(pos+2,&parsedOk);
+ for (i = 0;i < langCount && langSys == 0;i++) {
+ tag = getU32BE(pos+4+i*(4+2),&parsedOk);
+ if (tag == langTag) {
+ langSys = getU16BE(pos+4+i*(4+2)+4,&parsedOk);
+ }
+ }
+ }
+ if (langSys == 0) {
+ /* default language system */
+ langSys = getU16BE(pos,&parsedOk);
+ }
/* read LangSys table */
if (langSys == 0) {
- /* no ldefault LangSys */
+ /* no default LangSys */
return 0;
}
@@ -2453,6 +2478,9 @@ int FoFiTrueType::checkGIDInCoverage(Guint coverage, Guint orgGID)
case 1:
count = getU16BE(pos,&parsedOk);
pos += 2;
+ // In some poor CJK fonts, key GIDs are not sorted,
+ // thus we cannot finish checking even when the range
+ // including orgGID seems to have already passed.
for (i = 0;i < count;i++) {
Guint gid;
@@ -2462,9 +2490,6 @@ int FoFiTrueType::checkGIDInCoverage(Guint coverage, Guint orgGID)
/* found */
index = i;
break;
- } else if (gid > orgGID) {
- /* not found */
- break;
}
}
break;
@@ -2481,13 +2506,13 @@ int FoFiTrueType::checkGIDInCoverage(Guint coverage, Guint orgGID)
pos += 2;
startIndex = getU16BE(pos,&parsedOk);
pos += 2;
+ // In some poor CJK fonts, key GIDs are not sorted,
+ // thus we cannot finish checking even when the range
+ // including orgGID seems to have already passed.
if (startGID <= orgGID && orgGID <= endGID) {
/* found */
index = startIndex+orgGID-startGID;
break;
- } else if (orgGID <= endGID) {
- /* not found */
- break;
}
}
break;