summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/xetexdir
diff options
context:
space:
mode:
authorJonathan Kew <jfkthame@googlemail.com>2007-01-05 13:39:34 +0000
committerJonathan Kew <jfkthame@googlemail.com>2007-01-05 13:39:34 +0000
commit7f83d621a028015e39b6831decc8a3295866c5bc (patch)
tree08a9561eb46897ad3646f49d5d2b978e9d431807 /Build/source/texk/web2c/xetexdir
parentdc562290a5a164285ef63c96de55755c072f89ea (diff)
better heuristics for detecting opentype 'size' feature version
git-svn-id: svn://tug.org/texlive/trunk@3154 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/xetexdir')
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp
index 63b7f13f389..62c787da5bb 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp
+++ b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp
@@ -468,15 +468,36 @@ XeTeXFontMgr::getOpSizeRecAndStyleFlags(Font* theFont)
/* if featureParamsOffset < (offset of feature from featureListTable),
then we have a correct size table;
otherwise we (presumably) have a "broken" one from the old FDK */
- if (offset < (const char*)feature - (const char*)featureListTable)
- pSizeRec = (const OpSizeRec*)((char*)feature + offset);
- else
- pSizeRec = (const OpSizeRec*)((char*)featureListTable + offset);
- theFont->opSizeInfo.designSize = SWAP(pSizeRec->designSize);
- theFont->opSizeInfo.subFamilyID = SWAP(pSizeRec->subFamilyID);
- theFont->opSizeInfo.nameCode = SWAP(pSizeRec->nameCode);
- theFont->opSizeInfo.minSize = SWAP(pSizeRec->minSize);
- theFont->opSizeInfo.maxSize = SWAP(pSizeRec->maxSize);
+ for (int i = 0; i < 2; ++i) {
+ if (i == 0)
+ pSizeRec = (const OpSizeRec*)((char*)feature + offset);
+ else
+ pSizeRec = (const OpSizeRec*)((char*)featureListTable + offset);
+ if (SWAP(pSizeRec->designSize) == 0)
+ continue; // incorrect 'size' feature format
+ if (SWAP(pSizeRec->subFamilyID) == 0
+ && SWAP(pSizeRec->nameCode) == 0
+ && SWAP(pSizeRec->minSize) == 0
+ && SWAP(pSizeRec->maxSize) == 0)
+ break; // feature is valid, but no 'size' range
+ if (SWAP(pSizeRec->designSize) < SWAP(pSizeRec->minSize))
+ continue;
+ if (SWAP(pSizeRec->designSize) > SWAP(pSizeRec->maxSize))
+ continue;
+ if (SWAP(pSizeRec->maxSize) <= SWAP(pSizeRec->minSize))
+ continue;
+ if (SWAP(pSizeRec->nameCode) < 256)
+ continue;
+ if (SWAP(pSizeRec->nameCode) > 32767)
+ continue;
+ // looks like we've found a usable feature!
+ theFont->opSizeInfo.designSize = SWAP(pSizeRec->designSize);
+ theFont->opSizeInfo.subFamilyID = SWAP(pSizeRec->subFamilyID);
+ theFont->opSizeInfo.nameCode = SWAP(pSizeRec->nameCode);
+ theFont->opSizeInfo.minSize = SWAP(pSizeRec->minSize);
+ theFont->opSizeInfo.maxSize = SWAP(pSizeRec->maxSize);
+ break;
+ }
break;
}
}