int get_ot_math_ital_corr(int f, int g) { int 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))); } return rval; }
int ot_part_full_advance(int f, const GlyphAssembly* a, int i) { int rval = 0; if (fontarea[f] == OTGR_FONT_FLAG) { XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]); rval = D2Fix(font->unitsToPoints(SWAP(a->partRecords[i].fullAdvance))); } return rval; }
int get_ot_math_constant(int f, int n) { int rval = 0; if (fontarea[f] == OTGR_FONT_FLAG) { XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]); rval = getMathConstant(font, (mathConstantIndex)n); /* scale according to font size, except the ones that are percentages */ if (n > scriptScriptPercentScaleDown && n < radicalDegreeBottomRaisePercent) rval = D2Fix(font->unitsToPoints(rval)); } return rval; }
int get_ot_math_kern(int f, int g, int sf, int sg, int cmd, int shift) { int rval = 0; if (fontarea[f] == OTGR_FONT_FLAG) { XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]); int kern = 0, skern = 0; float corr_height_top = 0.0, corr_height_bot = 0.0; shift = Fix2D(shift); if (cmd == sup_cmd) { // superscript corr_height_top = font->pointsToUnits(glyph_height(f, g)); corr_height_bot = -font->pointsToUnits(glyph_depth(sf, sg) + shift); kern = getMathKernAt(f, g, topRight, corr_height_top); skern = getMathKernAt(sf, sg, bottomLeft, corr_height_top); rval = kern + skern; kern = getMathKernAt(f, g, topRight, corr_height_bot); skern = getMathKernAt(sf, sg, bottomLeft, corr_height_bot); if ((kern + skern) < rval) rval = kern + skern; } else if (cmd == sub_cmd) { // subscript corr_height_top = font->pointsToUnits(glyph_height(sf, sg) - 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); rval = kern + skern; kern = getMathKernAt(f, g, bottomRight, corr_height_bot); skern = getMathKernAt(sf, sg, topLeft, corr_height_bot); if ((kern + skern) < rval) rval = kern + skern; } else { assert(0); // we should not reach here } rval = D2Fix(font->unitsToPoints(rval)); } return rval; }
int ot_min_connector_overlap(int f) { int 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))); } return rval; }
int get_ot_math_variant(int f, int g, int v, integer* adv, int horiz) { int 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))); } } } return rval; }
int get_ot_math_accent_pos(int f, int g) { int 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)); } } return rval; }
Fixed getSlant(XeTeXFont font) { float italAngle = ((XeTeXFontInst*)font)->getItalicAngle(); return D2Fix(tan(-italAngle * M_PI / 180.0)); }