texlive[46529] Build/source/texk/web2c/xetexdir: XeTeXFontMgr.h,
commits+kakuto at tug.org
commits+kakuto at tug.org
Sat Feb 3 14:53:41 CET 2018
Revision: 46529
http://tug.org/svn/texlive?view=revision&revision=46529
Author: kakuto
Date: 2018-02-03 14:53:40 +0100 (Sat, 03 Feb 2018)
Log Message:
-----------
XeTeXFontMgr.h, XeTeXFontMgr.cpp: sync with the upstream
Modified Paths:
--------------
trunk/Build/source/texk/web2c/xetexdir/ChangeLog
trunk/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp
trunk/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h
Modified: trunk/Build/source/texk/web2c/xetexdir/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/xetexdir/ChangeLog 2018-02-03 12:36:49 UTC (rev 46528)
+++ trunk/Build/source/texk/web2c/xetexdir/ChangeLog 2018-02-03 13:53:40 UTC (rev 46529)
@@ -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 at fuk.kindai.ac.jp>
Modified: trunk/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp
===================================================================
--- trunk/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp 2018-02-03 12:36:49 UTC (rev 46528)
+++ trunk/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp 2018-02-03 13:53:40 UTC (rev 46529)
@@ -95,7 +95,7 @@
{
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 @@
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 @@
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 @@
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 @@
// 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 @@
}
}
- 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 @@
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);
+ &minSize,
+ &maxSize);
- if (ok)
+ 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 @@
{
const OpSizeRec* pSizeRec = getOpSize(font);
if (pSizeRec != NULL)
- return pSizeRec->designSize / 10.0;
+ return pSizeRec->designSize;
else
return 10.0;
}
@@ -493,8 +498,8 @@
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;
Modified: trunk/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h
===================================================================
--- trunk/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h 2018-02-03 12:36:49 UTC (rev 46528)
+++ trunk/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h 2018-02-03 13:53:40 UTC (rev 46529)
@@ -110,11 +110,11 @@
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 @@
, 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; }
More information about the tex-live-commits
mailing list