当前位置: 首页>>代码示例>>C++>>正文


C++ XeTeXFontInst::getMathTable方法代码示例

本文整理汇总了C++中XeTeXFontInst::getMathTable方法的典型用法代码示例。如果您正苦于以下问题:C++ XeTeXFontInst::getMathTable方法的具体用法?C++ XeTeXFontInst::getMathTable怎么用?C++ XeTeXFontInst::getMathTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XeTeXFontInst的用法示例。


在下文中一共展示了XeTeXFontInst::getMathTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SWAP

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;
}
开发者ID:texlive,项目名称:texlive-source,代码行数:34,代码来源:XeTeXOTMath.cpp

示例2: if

static int
getMathKernAt(int f, int g, MathKernSide side, int height)
{
    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->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);

            // XXX: the following makes no sense WRT my understanding of the
            // spec! it is just how things worked for me.
            if (count == 0)
                rval = SWAP(kernTable->kern[-1].value);
            else if (height < SWAP(kernTable->height[0].value))
                rval = SWAP(kernTable->kern[1].value);
            else if (height > SWAP(kernTable->height[count].value))
                rval = SWAP(kernTable->kern[count+1].value);
            else {
                for (int i = 0; i < count; i++) {
                    if (height > SWAP(kernTable->height[i].value)) {
                        rval = SWAP(kernTable->kern[i+1].value);
                        break;
                    }
                }
            }

            //fprintf(stderr, "   kern: %f %f\n", font->unitsToPoints(height), font->unitsToPoints(rval));
        }
    }

    return rval;
}
开发者ID:texlive,项目名称:texlive-source,代码行数:72,代码来源:XeTeXOTMath.cpp


注:本文中的XeTeXFontInst::getMathTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。