Commit 55d039ad authored by suzuki toshiya's avatar suzuki toshiya Committed by Albert Astals Cid

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
parent a8b0fa4d
......@@ -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;
......
......@@ -16,6 +16,7 @@
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
// Copyright (C) 2007 Koji Otani <sho@bbr.jp>
// Copyright (C) 2011 Albert Astals Cid <aacid@kde.org>
// 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
......@@ -165,7 +166,12 @@ public:
// Otherwise returns false. (Only useful for OpenType CFF fonts).
GBool getCFFBlock(char **start, int *length);
int setupGSUB(const char *tagName);
// setup vert/vrt2 GSUB for default lang
int setupGSUB(const char *scriptName);
// setup vert/vrt2 GSUB for specified lang
int setupGSUB(const char *scriptName, const char* languageName);
private:
FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA, int faceIndexA);
......
......@@ -28,6 +28,7 @@
// Copyright (C) 2011 Axel Strübing <axel.struebing@freenet.de>
// Copyright (C) 2011, 2012 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2012 Yi Yang <ahyangyi@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
......@@ -2232,36 +2233,37 @@ int *GfxCIDFont::getCodeToGIDMap(FoFiTrueType *ff, int *mapsizep) {
static struct CMapListEntry {
const char *collection;
const char *scriptTag;
const char *languageTag;
const char *toUnicodeMap;
const char **CMaps;
} CMapList[] = {
{
"Adobe-CNS1",
"kana",
"hani", "CHN ",
"Adobe-CNS1-UCS2",
adobe_cns1_cmaps,
},
{
"Adobe-GB1",
"kana",
"hani", "CHN ",
"Adobe-GB1-UCS2",
adobe_gb1_cmaps,
},
{
"Adobe-Japan1",
"kana",
"kana", "JAN ",
"Adobe-Japan1-UCS2",
adobe_japan1_cmaps,
},
{
"Adobe-Japan2",
"kana",
"kana", "JAN ",
"Adobe-Japan2-UCS2",
adobe_japan2_cmaps,
},
{
"Adobe-Korea1",
"kana",
"hang", "KOR ",
"Adobe-Korea1-UCS2",
adobe_korea1_cmaps,
},
......@@ -2359,7 +2361,7 @@ int *GfxCIDFont::getCodeToGIDMap(FoFiTrueType *ff, int *mapsizep) {
cMap->decRefCnt();
}
}
ff->setupGSUB(lp->scriptTag);
ff->setupGSUB(lp->scriptTag, lp->languageTag);
} else {
error(errSyntaxError, -1, "Unknown character collection {0:t}\n",
getCollection());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment