diff options
-rw-r--r-- | Build/source/texk/web2c/Makefile.in | 4 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/ChangeLog | 4 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/MathTable.h | 278 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp | 10 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/XeTeXFontInst.h | 4 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp | 5 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h | 1 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/XeTeXOTMath.cpp | 370 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/XeTeXOTMath.h | 7 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/am/xetex.am | 1 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/xetex.defines | 1 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/xetex.h | 1 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/xetex.web | 5 |
13 files changed, 122 insertions, 569 deletions
diff --git a/Build/source/texk/web2c/Makefile.in b/Build/source/texk/web2c/Makefile.in index 7f6da7d38e1..849f08cced8 100644 --- a/Build/source/texk/web2c/Makefile.in +++ b/Build/source/texk/web2c/Makefile.in @@ -896,7 +896,7 @@ am_libunilib_a_OBJECTS = \ libunilib_a_OBJECTS = $(am_libunilib_a_OBJECTS) libxetex_a_AR = $(AR) $(ARFLAGS) libxetex_a_LIBADD = -am__libxetex_a_SOURCES_DIST = xetexdir/MathTable.h \ +am__libxetex_a_SOURCES_DIST = \ xetexdir/XeTeXFontInst.cpp xetexdir/XeTeXFontInst.h \ xetexdir/XeTeXFontMgr.cpp xetexdir/XeTeXFontMgr.h \ xetexdir/XeTeXLayoutInterface.cpp \ @@ -3631,7 +3631,7 @@ libxetex_a_CPPFLAGS = $(xetex_cppflags) libxetex_a_CFLAGS = $(WARNING_CFLAGS) libxetex_a_CXXFLAGS = # $(WARNING_CXXFLAGS) libxetex_a_OBJCXXFLAGS = # $(WARNING_OBJCXXFLAGS) -libxetex_a_SOURCES = xetexdir/MathTable.h xetexdir/XeTeXFontInst.cpp \ +libxetex_a_SOURCES = xetexdir/XeTeXFontInst.cpp \ xetexdir/XeTeXFontInst.h xetexdir/XeTeXFontMgr.cpp \ xetexdir/XeTeXFontMgr.h xetexdir/XeTeXLayoutInterface.cpp \ xetexdir/XeTeXLayoutInterface.h xetexdir/XeTeXOTMath.cpp \ diff --git a/Build/source/texk/web2c/xetexdir/ChangeLog b/Build/source/texk/web2c/xetexdir/ChangeLog index 598c92efd55..eef47f4e0ce 100644 --- a/Build/source/texk/web2c/xetexdir/ChangeLog +++ b/Build/source/texk/web2c/xetexdir/ChangeLog @@ -1,3 +1,7 @@ +2017-03-12 Akira Kakuto <kakuto@fuk.kinidai.ac.jp> + + * Sync with the upstream.. + 2016-10-03 Akira Kakuto <kakuto@fuk.kinidai.ac.jp> * XeTeXOTMath.cpp: Sync with the upstream.. diff --git a/Build/source/texk/web2c/xetexdir/MathTable.h b/Build/source/texk/web2c/xetexdir/MathTable.h deleted file mode 100644 index 589cc1a2658..00000000000 --- a/Build/source/texk/web2c/xetexdir/MathTable.h +++ /dev/null @@ -1,278 +0,0 @@ -/****************************************************************************\ - Part of the XeTeX typesetting system - Copyright (c) 1994-2008 by SIL International - Copyright (c) 2009 by Jonathan Kew - Copyright (c) 2012 by Khaled Hosny - - SIL Author(s): Jonathan Kew - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE -FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the copyright holders -shall not be used in advertising or otherwise to promote the sale, -use or other dealings in this Software without prior written -authorization from the copyright holders. -\****************************************************************************/ - -#ifndef __MATHTABLE_H__ -#define __MATHTABLE_H__ - -#ifndef ANY_NUMBER -#define ANY_NUMBER 1 -#endif - -typedef uint16_t Offset; - -typedef struct { - int16_t value; - Offset deviceTable; -} MathValueRecord; - -typedef struct { - GlyphID start; - GlyphID end; - int16_t startCoverageIndex; -} RangeRecord; - -typedef struct { - uint32_t version; - Offset mathConstants; - Offset mathGlyphInfo; - Offset mathVariants; -} MathTableHeader; - -typedef struct { - uint16_t scriptPercentScaleDown; - uint16_t scriptScriptPercentScaleDown; - uint16_t delimitedSubFormulaMinHeight; - uint16_t displayOperatorMinHeight; - MathValueRecord mathLeading; - MathValueRecord axisHeight; - MathValueRecord accentBaseHeight; - MathValueRecord flattenedAccentBaseHeight; - MathValueRecord subscriptShiftDown; - MathValueRecord subscriptTopMax; - MathValueRecord subscriptBaselineDropMin; - MathValueRecord superscriptShiftUp; - MathValueRecord superscriptShiftUpCramped; - MathValueRecord superscriptBottomMin; - MathValueRecord superscriptBaselineDropMax; - MathValueRecord subSuperscriptGapMin; - MathValueRecord superscriptBottomMaxWithSubscript; - MathValueRecord spaceAfterScript; - MathValueRecord upperLimitGapMin; - MathValueRecord upperLimitBaselineRiseMin; - MathValueRecord lowerLimitGapMin; - MathValueRecord lowerLimitBaselineDropMin; - MathValueRecord stackTopShiftUp; - MathValueRecord stackTopDisplayStyleShiftUp; - MathValueRecord stackBottomShiftDown; - MathValueRecord stackBottomDisplayStyleShiftDown; - MathValueRecord stackGapMin; - MathValueRecord stackDisplayStyleGapMin; - MathValueRecord stretchStackTopShiftUp; - MathValueRecord stretchStackBottomShiftDown; - MathValueRecord stretchStackGapAboveMin; - MathValueRecord stretchStackGapBelowMin; - MathValueRecord fractionNumeratorShiftUp; - MathValueRecord fractionNumeratorDisplayStyleShiftUp; - MathValueRecord fractionDenominatorShiftDown; - MathValueRecord fractionDenominatorDisplayStyleShiftDown; - MathValueRecord fractionNumeratorGapMin; - MathValueRecord fractionNumDiisplayStyleGapMin; - MathValueRecord fractionRuleThickness; - MathValueRecord fractionDenominatorGapMin; - MathValueRecord fractionDenomDisplayStyleGapMin; - MathValueRecord skewedFractionHorizontalGap; - MathValueRecord skewedFractionVerticalGap; - MathValueRecord overbarVerticalGap; - MathValueRecord overbarRuleThickness; - MathValueRecord overbarExtraAscender; - MathValueRecord underbarVerticalGap; - MathValueRecord underbarRuleThickness; - MathValueRecord underbarExtraDescender; - MathValueRecord radicalVerticalGap; - MathValueRecord radicalDisplayStyleVerticalGap; - MathValueRecord radicalRuleThickness; - MathValueRecord radicalExtraAscender; - MathValueRecord radicalKernBeforeDegree; - MathValueRecord radicalKernAfterDegree; - uint16_t radicalDegreeBottomRaisePercent; -} MathConstants; - -typedef enum { - unknown = -1, - scriptPercentScaleDown = 0, - scriptScriptPercentScaleDown, - delimitedSubFormulaMinHeight, - displayOperatorMinHeight, - mathLeading, - firstMathValueRecord = mathLeading, - axisHeight, - accentBaseHeight, - flattenedAccentBaseHeight, - subscriptShiftDown, - subscriptTopMax, - subscriptBaselineDropMin, - superscriptShiftUp, - superscriptShiftUpCramped, - superscriptBottomMin, - superscriptBaselineDropMax, - subSuperscriptGapMin, - superscriptBottomMaxWithSubscript, - spaceAfterScript, - upperLimitGapMin, - upperLimitBaselineRiseMin, - lowerLimitGapMin, - lowerLimitBaselineDropMin, - stackTopShiftUp, - stackTopDisplayStyleShiftUp, - stackBottomShiftDown, - stackBottomDisplayStyleShiftDown, - stackGapMin, - stackDisplayStyleGapMin, - stretchStackTopShiftUp, - stretchStackBottomShiftDown, - stretchStackGapAboveMin, - stretchStackGapBelowMin, - fractionNumeratorShiftUp, - fractionNumeratorDisplayStyleShiftUp, - fractionDenominatorShiftDown, - fractionDenominatorDisplayStyleShiftDown, - fractionNumeratorGapMin, - fractionNumDisplayStyleGapMin, - fractionRuleThickness, - fractionDenominatorGapMin, - fractionDenomDisplayStyleGapMin, - skewedFractionHorizontalGap, - skewedFractionVerticalGap, - overbarVerticalGap, - overbarRuleThickness, - overbarExtraAscender, - underbarVerticalGap, - underbarRuleThickness, - underbarExtraDescender, - radicalVerticalGap, - radicalDisplayStyleVerticalGap, - radicalRuleThickness, - radicalExtraAscender, - radicalKernBeforeDegree, - radicalKernAfterDegree, - lastMathValueRecord = radicalKernAfterDegree, - radicalDegreeBottomRaisePercent, - lastMathConstant = radicalDegreeBottomRaisePercent -} mathConstantIndex; - -typedef struct { - uint16_t minConnectorOverlap; - Offset vertGlyphCoverage; - Offset horizGlyphCoverage; - uint16_t vertGlyphCount; - uint16_t horizGlyphCount; - Offset vertGlyphConstruction[ANY_NUMBER]; - Offset horizGlyphConstruction[ANY_NUMBER]; -} MathVariants; - -typedef struct { - GlyphID variantGlyph; - uint16_t advanceMeasurement; -} MathGlyphVariantRecord; - -typedef struct { - Offset glyphAssembly; - uint16_t variantCount; - MathGlyphVariantRecord mathGlyphVariantRecord[ANY_NUMBER]; -} MathGlyphConstruction; - -typedef struct { - GlyphID glyph; - uint16_t startConnectorLength; - uint16_t endConnectorLength; - uint16_t fullAdvance; - uint16_t partFlags; -} GlyphPartRecord; -#define fExtender 0x0001 - -typedef struct { - MathValueRecord italicsCorrection; - uint16_t partCount; - GlyphPartRecord partRecords[ANY_NUMBER]; -} GlyphAssembly; - -typedef struct { - Offset mathItalicsCorrectionInfo; - Offset mathTopAccentAttachment; - Offset extendedShapeCoverage; - Offset mathKernInfo; -} MathGlyphInfo; - -typedef struct { - Offset coverage; - uint16_t italicsCorrectionCount; - MathValueRecord italicsCorrection[ANY_NUMBER]; -} MathItalicsCorrectionInfo; - -typedef struct { - Offset coverage; - uint16_t topAccentAttachmentCount; - MathValueRecord topAccentAttachment[ANY_NUMBER]; -} MathTopAccentAttachment; - -typedef struct { - Offset topRight; - Offset topLeft; - Offset bottomRight; - Offset bottomLeft; -} MathKernInfoRecord; - -typedef struct { - Offset coverage; - uint16_t kernInfoCount; - MathKernInfoRecord kernInfo[ANY_NUMBER]; -} MathKernInfo; - -typedef struct { - uint16_t heightCount; - MathValueRecord height[ANY_NUMBER]; -/* - * The offset of this will vary depending on the size of the height[] array, - * so we have to compute it at runtime, not refer to a fixed field offset. - * - MathValueRecord kern[ANY_NUMBER]; - */ -} MathKernTable; - -typedef struct { - uint16_t format; -} Coverage; - -typedef struct { - uint16_t format; - uint16_t glyphCount; - GlyphID glyphArray[ANY_NUMBER]; -} CoverageFormat1; - -typedef struct { - uint16_t format; - uint16_t rangeCount; - RangeRecord rangeArray[ANY_NUMBER]; -} CoverageFormat2; - -#endif diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp index afdb847862d..1778858e5b9 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp @@ -67,7 +67,6 @@ XeTeXFontInst::XeTeXFontInst(const char* pathname, int index, float pointSize, i , m_index(0) , m_ftFace(0) , m_hbFont(NULL) - , m_math(NULL) { if (pathname != NULL) initialize(pathname, index, status); @@ -81,7 +80,6 @@ XeTeXFontInst::~XeTeXFontInst() } hb_font_destroy(m_hbFont); delete[] m_filename; - free(m_math); } /* HarfBuzz font functions */ @@ -388,14 +386,6 @@ XeTeXFontInst::getFontTable(OTTag tag) const return table; } -char * -XeTeXFontInst::getMathTable() -{ - if (m_math == NULL) - m_math = (char*) getFontTable(MATH_TAG); - return m_math; -} - void * XeTeXFontInst::getFontTable(FT_Sfnt_Tag tag) const { diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontInst.h b/Build/source/texk/web2c/xetexdir/XeTeXFontInst.h index 65e92933214..e666fa60bdc 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontInst.h +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontInst.h @@ -50,8 +50,6 @@ authorization from the copyright holders. #include FT_FREETYPE_H #include FT_TRUETYPE_TABLES_H -#define MATH_TAG HB_TAG('M','A','T','H') - // create specific subclasses for each supported platform class XeTeXFontInst @@ -72,7 +70,6 @@ protected: FT_Face m_ftFace; hb_font_t* m_hbFont; - char *m_math; public: XeTeXFontInst(float pointSize, int &status); @@ -84,7 +81,6 @@ public: void *getFontTable(OTTag tableTag) const; void *getFontTable(FT_Sfnt_Tag tableTag) const; - char *getMathTable(); const char *getFilename(uint32_t* index) const { diff --git a/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp b/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp index 4753a7064d1..5b2d2b53933 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp +++ b/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp @@ -1018,8 +1018,5 @@ usingOpenType(XeTeXLayoutEngine engine) bool isOpenTypeMathFont(XeTeXLayoutEngine engine) { - if (engine->font->getMathTable() != NULL) - return true; - else - return false; + return hb_ot_math_has_data(hb_font_get_face(engine->font->getHbFont())); } diff --git a/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h b/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h index 5c510d11884..0e0193361bf 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h +++ b/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h @@ -48,6 +48,7 @@ typedef struct XeTeXLayoutEngine_rec* XeTeXLayoutEngine; #include FT_TRUETYPE_TABLES_H #include <hb.h> +#include <hb-ot.h> #include "XeTeX_ext.h" #include "XeTeXFontMgr.h" diff --git a/Build/source/texk/web2c/xetexdir/XeTeXOTMath.cpp b/Build/source/texk/web2c/xetexdir/XeTeXOTMath.cpp index a10cc21d236..d1a4ab432be 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXOTMath.cpp +++ b/Build/source/texk/web2c/xetexdir/XeTeXOTMath.cpp @@ -41,66 +41,33 @@ authorization from the copyright holders. #include "XeTeX_web.h" #include "XeTeXLayoutInterface.h" #include "XeTeXFontInst.h" -#include "XeTeXswap.h" - -static int32_t getCoverage(const Coverage* coverage, GlyphID g) -{ - if (SWAP(coverage->format) == 1) { - const CoverageFormat1 *table = (const CoverageFormat1 *) coverage; - for (int i = 0; i < SWAP(table->glyphCount); i++) { - if (SWAP(table->glyphArray[i]) == g) - return i; - } - } else if (SWAP(coverage->format) == 2) { - const CoverageFormat2 *table = (const CoverageFormat2 *) coverage; - for (int i = 0; i < SWAP(table->rangeCount); i++) { - if (SWAP(table->rangeArray[i].start) <= g && SWAP(table->rangeArray[i].end) >= g) - return SWAP(table->rangeArray[i].startCoverageIndex) + (g - SWAP(table->rangeArray[i].start)); - } - } - - return -1; -} - -static int16_t getMathConstant(XeTeXFontInst* fontInst, mathConstantIndex whichConstant) -{ - const char* table = fontInst->getMathTable(); - if (table == NULL) - return 0; - - const uint16_t* constants = (const uint16_t*)(table + SWAP(((const MathTableHeader*)table)->mathConstants)); - - if (whichConstant < firstMathValueRecord) { - /* it's a simple 16-bit value */ - return SWAP(constants[whichConstant]); - } - else if (whichConstant <= lastMathValueRecord) { - const MathValueRecord* valueRecords = (const MathValueRecord*) - ((char*)constants + firstMathValueRecord * sizeof(uint16_t) - firstMathValueRecord * sizeof(MathValueRecord)); - return SWAP(valueRecords[whichConstant].value); - } - else if (whichConstant <= lastMathConstant) { - return SWAP(constants[whichConstant + (lastMathValueRecord - firstMathValueRecord + 1)]); - } - else - return 0; /* or abort, with "internal error" or something */ -} int get_ot_math_constant(int f, int n) { - int rval = 0; + hb_ot_math_constant_t constant = (hb_ot_math_constant_t) n; + hb_position_t rval = 0; if (fontarea[f] == OTGR_FONT_FLAG) { XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]); - rval = getMathConstant(font, (mathConstantIndex)n); + hb_font_t* hbFont = font->getHbFont(); + rval = hb_ot_math_get_constant(hbFont, constant); /* scale according to font size, except the ones that are percentages */ - if (n > scriptScriptPercentScaleDown && n < radicalDegreeBottomRaisePercent) - rval = D2Fix(font->unitsToPoints(rval)); + switch (constant) { + case HB_OT_MATH_CONSTANT_SCRIPT_PERCENT_SCALE_DOWN: + case HB_OT_MATH_CONSTANT_SCRIPT_SCRIPT_PERCENT_SCALE_DOWN: + case HB_OT_MATH_CONSTANT_RADICAL_DEGREE_BOTTOM_RAISE_PERCENT: + break; + default: + rval = D2Fix(font->unitsToPoints(rval)); + break; + } } return rval; } +#define unknown ((hb_ot_math_constant_t)-1) + /* fontdimen IDs for math symbols font (family 2) */ #define math_x_height 5 #define math_quad 6 @@ -120,30 +87,30 @@ get_ot_math_constant(int f, int n) #define delim2 21 /* size of \.{\\atopwithdelims} delimiters in non-displays */ #define axis_height 22 /* height of fraction lines above the baseline */ -const mathConstantIndex TeX_sym_to_OT_map[] = { +const hb_ot_math_constant_t TeX_sym_to_OT_map[] = { unknown, unknown, unknown, unknown, unknown, - accentBaseHeight, // x-height + HB_OT_MATH_CONSTANT_ACCENT_BASE_HEIGHT, // x-height unknown, // quad unknown, - fractionNumeratorDisplayStyleShiftUp, - fractionNumeratorShiftUp, - stackTopShiftUp, - fractionDenominatorDisplayStyleShiftDown, - fractionDenominatorShiftDown, - superscriptShiftUp, // ?? - superscriptShiftUp, // ?? - superscriptShiftUpCramped, - subscriptShiftDown, // ?? - subscriptShiftDown, // ?? - superscriptBaselineDropMax, // ?? - subscriptBaselineDropMin, // ?? - delimitedSubFormulaMinHeight, + HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_DISPLAY_STYLE_SHIFT_UP, + HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_SHIFT_UP, + HB_OT_MATH_CONSTANT_STACK_TOP_SHIFT_UP, + HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_DISPLAY_STYLE_SHIFT_DOWN, + HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_SHIFT_DOWN, + HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP, // ?? + HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP, // ?? + HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP_CRAMPED, + HB_OT_MATH_CONSTANT_SUBSCRIPT_SHIFT_DOWN, // ?? + HB_OT_MATH_CONSTANT_SUBSCRIPT_SHIFT_DOWN, // ?? + HB_OT_MATH_CONSTANT_SUPERSCRIPT_BASELINE_DROP_MAX, // ?? + HB_OT_MATH_CONSTANT_SUBSCRIPT_BASELINE_DROP_MIN, // ?? + HB_OT_MATH_CONSTANT_DELIMITED_SUB_FORMULA_MIN_HEIGHT, unknown, // using quad instead for now - axisHeight + HB_OT_MATH_CONSTANT_AXIS_HEIGHT }; int @@ -159,8 +126,8 @@ get_native_mathsy_param(int f, int n) rval = std::min<int>(1.5 * fontsize[f], get_native_mathsy_param(f, delim1)); } else { - if (n < sizeof(TeX_sym_to_OT_map) / sizeof(mathConstantIndex)) { - mathConstantIndex ot_index = TeX_sym_to_OT_map[n]; + if (n < sizeof(TeX_sym_to_OT_map) / sizeof(hb_ot_math_constant_t)) { + hb_ot_math_constant_t ot_index = TeX_sym_to_OT_map[n]; if (ot_index != unknown) rval = get_ot_math_constant(f, (int)ot_index); } @@ -178,21 +145,21 @@ get_native_mathsy_param(int f, int n) #define big_op_spacing4 12 /* minimum baselineskip below displayed op */ #define big_op_spacing5 13 /* padding above and below displayed limits */ -const mathConstantIndex TeX_ext_to_OT_map[] = { +const hb_ot_math_constant_t TeX_ext_to_OT_map[] = { unknown, unknown, unknown, unknown, unknown, - accentBaseHeight, // x-height + HB_OT_MATH_CONSTANT_ACCENT_BASE_HEIGHT, // x-height unknown, // quad unknown, - fractionRuleThickness, // default_rule_thickness - upperLimitGapMin, // big_op_spacing1 - lowerLimitGapMin, // big_op_spacing2 - upperLimitBaselineRiseMin, // big_op_spacing3 - lowerLimitBaselineDropMin, // big_op_spacing4 - stackGapMin // big_op_spacing5 + HB_OT_MATH_CONSTANT_FRACTION_RULE_THICKNESS, // default_rule_thickness + HB_OT_MATH_CONSTANT_UPPER_LIMIT_GAP_MIN, // big_op_spacing1 + HB_OT_MATH_CONSTANT_LOWER_LIMIT_GAP_MIN, // big_op_spacing2 + HB_OT_MATH_CONSTANT_UPPER_LIMIT_BASELINE_RISE_MIN, // big_op_spacing3 + HB_OT_MATH_CONSTANT_LOWER_LIMIT_BASELINE_DROP_MIN, // big_op_spacing4 + HB_OT_MATH_CONSTANT_STACK_GAP_MIN // big_op_spacing5 }; int @@ -203,8 +170,8 @@ get_native_mathex_param(int f, int n) if (n == math_quad) rval = fontsize[f]; else { - if (n < sizeof(TeX_ext_to_OT_map) / sizeof(mathConstantIndex)) { - mathConstantIndex ot_index = TeX_ext_to_OT_map[n]; + if (n < sizeof(TeX_ext_to_OT_map) / sizeof(hb_ot_math_constant_t)) { + hb_ot_math_constant_t ot_index = TeX_ext_to_OT_map[n]; if (ot_index != unknown) rval = get_ot_math_constant(f, (int)ot_index); } @@ -217,42 +184,25 @@ get_native_mathex_param(int f, int n) int get_ot_math_variant(int f, int g, int v, integer* adv, int horiz) { - int rval = g; + hb_codepoint_t rval = g; *adv = -1; if (fontarea[f] == OTGR_FONT_FLAG) { XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]); - - const char* table = font->getMathTable(); - if (table == NULL) - return rval; - - uint16_t offset = SWAP(((const MathTableHeader*)table)->mathVariants); - if (offset == 0) - return rval; - const MathVariants* variants = (const MathVariants*)(table + offset); - - offset = horiz ? SWAP(variants->horizGlyphCoverage) : SWAP(variants->vertGlyphCoverage); - if (offset == 0) - return rval; - const Coverage* coverage = (const Coverage*)(((const char*)variants) + offset); - - int32_t index = getCoverage(coverage, g); - if (index >= 0) { - if (horiz) - index += SWAP(variants->vertGlyphCount); - const MathGlyphConstruction* construction = (const MathGlyphConstruction*)(((const char*)variants) - + SWAP(variants->vertGlyphConstruction[index])); - if (v < SWAP(construction->variantCount)) { - rval = SWAP(construction->mathGlyphVariantRecord[v].variantGlyph); - *adv = D2Fix(font->unitsToPoints(SWAP(construction->mathGlyphVariantRecord[v].advanceMeasurement))); - } + hb_font_t* hbFont = font->getHbFont(); + hb_ot_math_glyph_variant_t variant[1]; + unsigned int count = 1; + hb_ot_math_get_glyph_variants(hbFont, g, horiz ? HB_DIRECTION_RTL : HB_DIRECTION_TTB, v, &count, variant); + if (count > 0) { + rval = variant->glyph; + *adv = D2Fix(font->unitsToPoints(variant->advance)); } } return rval; } + void* get_ot_assembly_ptr(int f, int g, int horiz) { @@ -260,66 +210,40 @@ get_ot_assembly_ptr(int f, int g, int horiz) if (fontarea[f] == OTGR_FONT_FLAG) { XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]); - - const char* table = font->getMathTable(); - if (table == NULL) - return rval; - - uint16_t offset = SWAP(((const MathTableHeader*)table)->mathVariants); - if (offset == 0) - return rval; - const MathVariants* variants = (const MathVariants*)(table + offset); - - offset = horiz ? SWAP(variants->horizGlyphCoverage) : SWAP(variants->vertGlyphCoverage); - if (offset == 0) - return rval; - const Coverage* coverage = (const Coverage*)(((const char*)variants) + offset); - - int32_t index = getCoverage(coverage, g); - if (index >= 0) { - if (horiz) - index += SWAP(variants->vertGlyphCount); - const MathGlyphConstruction* construction = (const MathGlyphConstruction*)(((const char*)variants) - + SWAP(variants->vertGlyphConstruction[index])); - offset = SWAP(construction->glyphAssembly); - if (offset != 0) - rval = (void*)(((const char*)construction) + offset); + hb_font_t* hbFont = font->getHbFont(); + + unsigned int count = hb_ot_math_get_glyph_assembly(hbFont, g, horiz ? HB_DIRECTION_RTL : HB_DIRECTION_TTB, 0, NULL, NULL, NULL); + if (count > 0) { + GlyphAssembly* a = (GlyphAssembly*) xmalloc(sizeof(GlyphAssembly)); + a->count = count; + a->parts = (hb_ot_math_glyph_part_t*) xmalloc(count * sizeof(hb_ot_math_glyph_part_t)); + hb_ot_math_get_glyph_assembly(hbFont, g, horiz ? HB_DIRECTION_RTL : HB_DIRECTION_TTB, 0, &a->count, a->parts, NULL); + rval = (void*) a; } } return rval; } +void +free_ot_assembly(GlyphAssembly* a) +{ + if (!a) + return; + free (a->parts); + free (a); +} + int get_ot_math_ital_corr(int f, int g) { - int rval = 0; + hb_position_t rval = 0; if (fontarea[f] == OTGR_FONT_FLAG) { XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]); - - const char* table = font->getMathTable(); - if (table == NULL) - return rval; - - uint16_t offset = SWAP(((const MathTableHeader*)table)->mathGlyphInfo); - if (offset == 0) - return rval; - const MathGlyphInfo* glyphInfo = (const MathGlyphInfo*)(table + offset); - - offset = SWAP(glyphInfo->mathItalicsCorrectionInfo); - if (offset == 0) - return rval; - const MathItalicsCorrectionInfo* italCorrInfo = (const MathItalicsCorrectionInfo*)(((const char*)glyphInfo) + offset); - - offset = SWAP(italCorrInfo->coverage); - if (offset == 0) - return rval; - const Coverage* coverage = (const Coverage*)(((const char*)italCorrInfo) + offset); - - int32_t index = getCoverage(coverage, g); - if (index >= 0 && index < SWAP(italCorrInfo->italicsCorrectionCount)) - rval = D2Fix(font->unitsToPoints(SWAP(italCorrInfo->italicsCorrection[index].value))); + hb_font_t* hbFont = font->getHbFont(); + rval = hb_ot_math_get_glyph_italics_correction(hbFont, g); + rval = D2Fix(font->unitsToPoints(rval)); } return rval; @@ -328,35 +252,13 @@ get_ot_math_ital_corr(int f, int g) int get_ot_math_accent_pos(int f, int g) { - int rval = 0x7fffffffUL; + hb_position_t rval = 0x7fffffffUL; if (fontarea[f] == OTGR_FONT_FLAG) { XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]); - - const char* table = font->getMathTable(); - if (table == NULL) - return rval; - - uint16_t offset = SWAP(((const MathTableHeader*)table)->mathGlyphInfo); - if (offset == 0) - return rval; - const MathGlyphInfo* glyphInfo = (const MathGlyphInfo*)(table + offset); - - offset = SWAP(glyphInfo->mathTopAccentAttachment); - if (offset == 0) - return rval; - const MathTopAccentAttachment* accentAttachment = (const MathTopAccentAttachment*)(((const char*)glyphInfo) + offset); - - offset = SWAP(accentAttachment->coverage); - if (offset == 0) - return rval; - const Coverage* coverage = (const Coverage*)(((const char*)accentAttachment) + offset); - - int32_t index = getCoverage(coverage, g); - if (index >= 0 && index < SWAP(accentAttachment->topAccentAttachmentCount)) { - rval = (int16_t)SWAP(accentAttachment->topAccentAttachment[index].value); - rval = D2Fix(font->unitsToPoints(rval)); - } + hb_font_t* hbFont = font->getHbFont(); + rval = hb_ot_math_get_glyph_top_accent_attachment(hbFont, g); + rval = D2Fix(font->unitsToPoints(rval)); } return rval; @@ -365,97 +267,27 @@ get_ot_math_accent_pos(int f, int g) int ot_min_connector_overlap(int f) { - int rval = 0; + hb_position_t rval = 0; if (fontarea[f] == OTGR_FONT_FLAG) { XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]); - - const char* table = font->getMathTable(); - if (table == NULL) - return rval; - - uint16_t offset = SWAP(((const MathTableHeader*)table)->mathVariants); - if (offset == 0) - return rval; - const MathVariants* variants = (const MathVariants*)(table + offset); - - rval = D2Fix(font->unitsToPoints(SWAP(variants->minConnectorOverlap))); + hb_font_t* hbFont = font->getHbFont(); + rval = hb_ot_math_get_min_connector_overlap(hbFont, HB_DIRECTION_RTL); + rval = D2Fix(font->unitsToPoints(rval)); } return rval; } -typedef enum { - topRight, - topLeft, - bottomRight, - bottomLeft, -} MathKernSide; - static int -getMathKernAt(int f, int g, MathKernSide side, int height) +getMathKernAt(int f, int g, hb_ot_math_kern_t side, int height) { - int rval = 0; + hb_position_t rval = 0; + if (fontarea[f] == OTGR_FONT_FLAG) { XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]); - - const char* table = font->getMathTable(); - if (table == NULL) - return rval; - - uint16_t offset = SWAP(((const MathTableHeader*)table)->mathGlyphInfo); - if (offset == 0) - return rval; - - const MathGlyphInfo* glyphInfo = (const MathGlyphInfo*)(table + offset); - - offset = SWAP(glyphInfo->mathKernInfo); - if (offset == 0) - return rval; - - const MathKernInfo* mathKernInfo = (const MathKernInfo*)(((const char*)glyphInfo) + offset); - - offset = SWAP(mathKernInfo->coverage); - if (offset == 0) - return rval; - - const Coverage* coverage = (const Coverage*)(((const char*)mathKernInfo) + offset); - - int32_t index = getCoverage(coverage, g); - if (index >= 0 && index < SWAP(mathKernInfo->kernInfoCount)) { - if (side == topRight) - offset = SWAP(mathKernInfo->kernInfo[index].topRight); - else if (side == bottomRight) - offset = SWAP(mathKernInfo->kernInfo[index].bottomRight); - else if (side == topLeft) - offset = SWAP(mathKernInfo->kernInfo[index].topLeft); - else if (side == bottomLeft) - offset = SWAP(mathKernInfo->kernInfo[index].bottomLeft); - else - assert(0); // we should not reach here - - if (offset == 0) - return rval; - - const MathKernTable* kernTable = (const MathKernTable*)(((const char*)mathKernInfo) + offset); - - uint16_t count = SWAP(kernTable->heightCount); - - // kern[] array immediately follows the height[] array with |count| elements - const MathValueRecord* kern = &kernTable->height[0] + count; - - if (count == 0 || height < SWAP(kernTable->height[0].value)) - rval = SWAP(kern[0].value); - else { - rval = SWAP(kern[count].value); - for (int i = 0; i < count; i++) { - if (height <= SWAP(kernTable->height[i].value)) { - rval = SWAP(kern[i].value); - break; - } - } - } - } + hb_font_t* hbFont = font->getHbFont(); + rval = hb_ot_math_get_glyph_kerning(hbFont, g, side, height); } return rval; @@ -505,12 +337,12 @@ get_ot_math_kern(int f, int g, int sf, int sg, int cmd, int shift) corr_height_top = font->pointsToUnits(glyph_height(f, g)); corr_height_bot = -font->pointsToUnits(glyph_depth(sf, sg) + Fix2D(shift)); - kern = getMathKernAt(f, g, topRight, corr_height_top); - skern = getMathKernAt(sf, sg, bottomLeft, corr_height_top); + kern = getMathKernAt(f, g, HB_OT_MATH_KERN_TOP_RIGHT, corr_height_top); + skern = getMathKernAt(sf, sg, HB_OT_MATH_KERN_BOTTOM_LEFT, corr_height_top); rval = kern + skern; - kern = getMathKernAt(f, g, topRight, corr_height_bot); - skern = getMathKernAt(sf, sg, bottomLeft, corr_height_bot); + kern = getMathKernAt(f, g, HB_OT_MATH_KERN_TOP_RIGHT, corr_height_bot); + skern = getMathKernAt(sf, sg, HB_OT_MATH_KERN_BOTTOM_LEFT, corr_height_bot); if ((kern + skern) < rval) rval = kern + skern; @@ -518,12 +350,12 @@ get_ot_math_kern(int f, int g, int sf, int sg, int cmd, int shift) corr_height_top = font->pointsToUnits(glyph_height(sf, sg) - Fix2D(shift)); corr_height_bot = -font->pointsToUnits(glyph_depth(f, g)); - kern = getMathKernAt(f, g, bottomRight, corr_height_top); - skern = getMathKernAt(sf, sg, topLeft, corr_height_top); + kern = getMathKernAt(f, g, HB_OT_MATH_KERN_BOTTOM_RIGHT, corr_height_top); + skern = getMathKernAt(sf, sg, HB_OT_MATH_KERN_TOP_LEFT, corr_height_top); rval = kern + skern; - kern = getMathKernAt(f, g, bottomRight, corr_height_bot); - skern = getMathKernAt(sf, sg, topLeft, corr_height_bot); + kern = getMathKernAt(f, g, HB_OT_MATH_KERN_BOTTOM_RIGHT, corr_height_bot); + skern = getMathKernAt(sf, sg, HB_OT_MATH_KERN_TOP_LEFT, corr_height_bot); if ((kern + skern) < rval) rval = kern + skern; @@ -540,19 +372,19 @@ get_ot_math_kern(int f, int g, int sf, int sg, int cmd, int shift) int ot_part_count(const GlyphAssembly* a) { - return SWAP(a->partCount); + return a->count; } int ot_part_glyph(const GlyphAssembly* a, int i) { - return SWAP(a->partRecords[i].glyph); + return a->parts[i].glyph; } int ot_part_is_extender(const GlyphAssembly* a, int i) { - return (SWAP(a->partRecords[i].partFlags) & fExtender) != 0; + return (a->parts[i].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER) != 0; } int @@ -562,7 +394,7 @@ ot_part_start_connector(int f, const GlyphAssembly* a, int i) if (fontarea[f] == OTGR_FONT_FLAG) { XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]); - rval = D2Fix(font->unitsToPoints(SWAP(a->partRecords[i].startConnectorLength))); + rval = D2Fix(font->unitsToPoints(a->parts[i].start_connector_length)); } return rval; @@ -575,7 +407,7 @@ ot_part_end_connector(int f, const GlyphAssembly* a, int i) if (fontarea[f] == OTGR_FONT_FLAG) { XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]); - rval = D2Fix(font->unitsToPoints(SWAP(a->partRecords[i].endConnectorLength))); + rval = D2Fix(font->unitsToPoints(a->parts[i].end_connector_length)); } return rval; @@ -588,7 +420,7 @@ ot_part_full_advance(int f, const GlyphAssembly* a, int i) if (fontarea[f] == OTGR_FONT_FLAG) { XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]); - rval = D2Fix(font->unitsToPoints(SWAP(a->partRecords[i].fullAdvance))); + rval = D2Fix(font->unitsToPoints(a->parts[i].full_advance)); } return rval; diff --git a/Build/source/texk/web2c/xetexdir/XeTeXOTMath.h b/Build/source/texk/web2c/xetexdir/XeTeXOTMath.h index ba2cc873041..1b8362bb0ea 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXOTMath.h +++ b/Build/source/texk/web2c/xetexdir/XeTeXOTMath.h @@ -34,7 +34,11 @@ authorization from the copyright holders. #define __XETEX_OT_MATH__ #include "XeTeX_ext.h" -#include "MathTable.h" + +typedef struct { + unsigned int count; + hb_ot_math_glyph_part_t* parts; +} GlyphAssembly; /* public "C" APIs for calling from Web(-to-C) code */ #ifdef __cplusplus @@ -45,6 +49,7 @@ extern "C" { int get_ot_math_constant(int f, int n); int get_ot_math_variant(int f, int g, int v, integer* adv, int horiz); void* get_ot_assembly_ptr(int f, int g, int horiz); + void free_ot_assembly(GlyphAssembly* a); int get_ot_math_ital_corr(int f, int g); int get_ot_math_accent_pos(int f, int g); int get_ot_math_kern(int f, int g, int sf, int sg, int cmd, int shift); diff --git a/Build/source/texk/web2c/xetexdir/am/xetex.am b/Build/source/texk/web2c/xetexdir/am/xetex.am index d3a0def8320..475f8dc44bc 100644 --- a/Build/source/texk/web2c/xetexdir/am/xetex.am +++ b/Build/source/texk/web2c/xetexdir/am/xetex.am @@ -135,7 +135,6 @@ libxetex_a_CXXFLAGS = # $(WARNING_CXXFLAGS) libxetex_a_OBJCXXFLAGS = # $(WARNING_OBJCXXFLAGS) libxetex_a_SOURCES = \ - xetexdir/MathTable.h \ xetexdir/XeTeXFontInst.cpp \ xetexdir/XeTeXFontInst.h \ xetexdir/XeTeXFontMgr.cpp \ diff --git a/Build/source/texk/web2c/xetexdir/xetex.defines b/Build/source/texk/web2c/xetexdir/xetex.defines index ef22d53c8db..8772a82b622 100644 --- a/Build/source/texk/web2c/xetexdir/xetex.defines +++ b/Build/source/texk/web2c/xetexdir/xetex.defines @@ -113,6 +113,7 @@ authorization from the copyright holders. @define function getotmathconstant(); @define function getotmathvariant(); @define function getotassemblyptr(); +@define procedure freeotassembly(); @define function getotmathitalcorr(); @define function getotmathaccentpos(); @define function getotmathkern(); diff --git a/Build/source/texk/web2c/xetexdir/xetex.h b/Build/source/texk/web2c/xetexdir/xetex.h index 8231d768043..2360e3920ca 100644 --- a/Build/source/texk/web2c/xetexdir/xetex.h +++ b/Build/source/texk/web2c/xetexdir/xetex.h @@ -91,6 +91,7 @@ authorization from the copyright holders. #define getotmathconstant get_ot_math_constant #define getotmathvariant get_ot_math_variant #define getotassemblyptr get_ot_assembly_ptr +#define freeotassembly free_ot_assembly #define getotmathitalcorr get_ot_math_ital_corr #define getotmathaccentpos get_ot_math_accent_pos #define getotmathkern get_ot_math_kern diff --git a/Build/source/texk/web2c/xetexdir/xetex.web b/Build/source/texk/web2c/xetexdir/xetex.web index 227ab66bb18..b935cefe947 100644 --- a/Build/source/texk/web2c/xetexdir/xetex.web +++ b/Build/source/texk/web2c/xetexdir/xetex.web @@ -16435,6 +16435,7 @@ end else begin b:=new_null_box; width(b):=null_delimiter_space; {use this width if no delimiter was found} end; shift_amount(b):=half(height(b)-depth(b)) - axis_height(s); +free_ot_assembly(ot_assembly_ptr); var_delimiter:=b; end; @@ -17083,6 +17084,7 @@ var p,@!x,@!y:pointer; {temporary registers for box construction} @!ot_assembly_ptr:void_pointer; begin fetch(accent_chr(q)); x:=null; +ot_assembly_ptr:=nil; if is_native_font(cur_f) then begin c:=cur_c; f:=cur_f; if not is_bottom_acc(q) then s:=compute_ot_math_accent_pos(q) else s:=0; @@ -17136,6 +17138,7 @@ if x<>null then begin info(nucleus(q)):=y; math_type(nucleus(q)):=sub_box; end; + free_ot_assembly(ot_assembly_ptr); end; @ @<Make the height of box |y|...@>= @@ -17347,6 +17350,7 @@ var delta:scaled; {offset between subscript and superscript} begin if (subtype(q)=normal)and(cur_style<text_style) then subtype(q):=limits; delta:=0; +ot_assembly_ptr:=nil; if math_type(nucleus(q))=math_char then begin fetch(nucleus(q)); if not is_ot_font(cur_f) then begin @@ -17404,6 +17408,7 @@ found: save_f:=cur_f; if subtype(q)=limits then @<Construct a box with limits above and below it, skewed by |delta|@>; +free_ot_assembly(ot_assembly_ptr); make_op:=delta; end; |