summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/xetexdir
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2018-02-03 13:53:40 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2018-02-03 13:53:40 +0000
commit7fa6eb304b185976cfce57891da0e4d1615def95 (patch)
tree163717992dae222ac39196ed956c72c4d867c973 /Build/source/texk/web2c/xetexdir
parentce8880c6ba605042558a32689c2851c121728ee6 (diff)
XeTeXFontMgr.h, XeTeXFontMgr.cpp: sync with the upstream
git-svn-id: svn://tug.org/texlive/trunk@46529 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/xetexdir')
-rw-r--r--Build/source/texk/web2c/xetexdir/ChangeLog7
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp37
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h8
3 files changed, 32 insertions, 20 deletions
diff --git a/Build/source/texk/web2c/xetexdir/ChangeLog b/Build/source/texk/web2c/xetexdir/ChangeLog
index 57158c5b256..0b7d1fdfad4 100644
--- a/Build/source/texk/web2c/xetexdir/ChangeLog
+++ b/Build/source/texk/web2c/xetexdir/ChangeLog
@@ -12,6 +12,13 @@
native fonts. Fixes #145.
* XeTeX_ext.[ch]: Patch from Hironobu Yamashita to properly
close input pipes. Fixes 147.
+ * XeTeXFontMgr.cpp, XeTeXFontMgr.h: Convert optical size info
+ in OpenType 'size' feature from PostScript to TeX points.
+ Note that this will change behavior for existing documents
+ that use OpenType fonts from optically-sized families, and
+ depend on XeTeX choosing the appropriate face for a given
+ size: the boundaries at which face selection changes will be
+ slightly shifted (corrected) from how earlier versions behaved.
2018-01-17 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp
index d8d249d4863..11094b10b47 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp
+++ b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp
@@ -95,7 +95,7 @@ XeTeXFontMgr::findFont(const char* name, char* variant, double ptSize)
{
std::string nameStr(name);
Font* font = NULL;
- int dsize = 100;
+ double dsize = 10.0;
loadedfontdesignsize = 655360L;
for (int pass = 0; pass < 2; ++pass) {
@@ -103,7 +103,7 @@ XeTeXFontMgr::findFont(const char* name, char* variant, double ptSize)
std::map<std::string,Font*>::iterator i = m_nameToFont.find(nameStr);
if (i != m_nameToFont.end()) {
font = i->second;
- if (font->opSizeInfo.designSize != 0)
+ if (font->opSizeInfo.designSize != 0.0)
dsize = font->opSizeInfo.designSize;
break;
}
@@ -118,7 +118,7 @@ XeTeXFontMgr::findFont(const char* name, char* variant, double ptSize)
i = f->second->styles->find(style);
if (i != f->second->styles->end()) {
font = i->second;
- if (font->opSizeInfo.designSize != 0)
+ if (font->opSizeInfo.designSize != 0.0)
dsize = font->opSizeInfo.designSize;
break;
}
@@ -129,7 +129,7 @@ XeTeXFontMgr::findFont(const char* name, char* variant, double ptSize)
i = m_psNameToFont.find(nameStr);
if (i != m_psNameToFont.end()) {
font = i->second;
- if (font->opSizeInfo.designSize != 0)
+ if (font->opSizeInfo.designSize != 0.0)
dsize = font->opSizeInfo.designSize;
break;
}
@@ -362,9 +362,8 @@ XeTeXFontMgr::findFont(const char* name, char* variant, double ptSize)
// if there's optical size info, try to apply it
if (ptSize < 0.0)
- ptSize = dsize / 10.0;
+ ptSize = dsize;
if (font != NULL && font->opSizeInfo.subFamilyID != 0 && ptSize > 0.0) {
- ptSize = ptSize * 10.0; // convert to decipoints for comparison with the opSize values
double bestMismatch = my_fmax(font->opSizeInfo.minSize - ptSize, ptSize - font->opSizeInfo.maxSize);
if (bestMismatch > 0.0) {
Font* bestMatch = font;
@@ -383,8 +382,8 @@ XeTeXFontMgr::findFont(const char* name, char* variant, double ptSize)
}
}
- if (font != NULL && font->opSizeInfo.designSize != 0)
- loadedfontdesignsize = (font->opSizeInfo.designSize << 16L) / 10;
+ if (font != NULL && font->opSizeInfo.designSize != 0.0)
+ loadedfontdesignsize = unsigned(font->opSizeInfo.designSize * 65536.0 + 0.5);
if (gettracingfontsstate() > 0) {
begindiagnostic();
@@ -455,15 +454,21 @@ XeTeXFontMgr::getOpSize(XeTeXFont font)
hb_face_t* face = hb_font_get_face(hbFont);
OpSizeRec* pSizeRec = (OpSizeRec*) xmalloc(sizeof(OpSizeRec));
+ unsigned int designSize, minSize, maxSize;
bool ok = hb_ot_layout_get_size_params(face,
- &pSizeRec->designSize,
+ &designSize,
&pSizeRec->subFamilyID,
&pSizeRec->nameCode,
- &pSizeRec->minSize,
- &pSizeRec->maxSize);
-
- if (ok)
+ &minSize,
+ &maxSize);
+
+ if (ok) {
+ // Convert sizes from PostScript deci-points to TeX points
+ pSizeRec->designSize = designSize * 72.27 / 72.0 / 10.0;
+ pSizeRec->minSize = minSize * 72.27 / 72.0 / 10.0;
+ pSizeRec->maxSize = maxSize * 72.27 / 72.0 / 10.0;
return pSizeRec;
+ }
free(pSizeRec);
return NULL;
@@ -477,7 +482,7 @@ XeTeXFontMgr::getDesignSize(XeTeXFont font)
{
const OpSizeRec* pSizeRec = getOpSize(font);
if (pSizeRec != NULL)
- return pSizeRec->designSize / 10.0;
+ return pSizeRec->designSize;
else
return 10.0;
}
@@ -493,8 +498,8 @@ XeTeXFontMgr::getOpSizeRecAndStyleFlags(Font* theFont)
theFont->opSizeInfo.designSize = pSizeRec->designSize;
if (pSizeRec->subFamilyID == 0
&& pSizeRec->nameCode == 0
- && pSizeRec->minSize == 0
- && pSizeRec->maxSize == 0)
+ && pSizeRec->minSize == 0.0
+ && pSizeRec->maxSize == 0.0)
goto done_size; // feature is valid, but no 'size' range
theFont->opSizeInfo.subFamilyID = pSizeRec->subFamilyID;
theFont->opSizeInfo.nameCode = pSizeRec->nameCode;
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h
index e56a131ff6b..52a2701a205 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h
+++ b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h
@@ -110,11 +110,11 @@ protected:
class Family;
struct OpSizeRec {
- unsigned int designSize;
+ double designSize;
+ double minSize;
+ double maxSize;
unsigned int subFamilyID;
unsigned int nameCode;
- unsigned int minSize;
- unsigned int maxSize;
};
class Font {
@@ -125,7 +125,7 @@ protected:
, fontRef(ref), weight(0), width(0), slant(0)
, isReg(false), isBold(false), isItalic(false)
{ opSizeInfo.subFamilyID = 0;
- opSizeInfo.designSize = 100; } /* default to 10bp */
+ opSizeInfo.designSize = 10.0; } /* default to 10.0pt */
~Font()
{ delete m_fullName; delete m_psName; }