From 7f83d621a028015e39b6831decc8a3295866c5bc Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Fri, 5 Jan 2007 13:39:34 +0000 Subject: better heuristics for detecting opentype 'size' feature version git-svn-id: svn://tug.org/texlive/trunk@3154 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp | 39 +++++++++++++++++------ 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'Build') 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; } } -- cgit v1.2.3