示例#1
0
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;
}
示例#2
0
bool ossimVpfLibrary::getCoverage(const ossimString& name,
                                  ossimVpfCoverage& coverage)
{
  for(int idx = 0; idx < (int)theCoverageNames.size(); ++idx)
    {
      if(theCoverageNames[idx] == name)
	{
	  return getCoverage(idx,
			     coverage);
	}
    }

  return false;
}
示例#3
0
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;
}
示例#4
0
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;
}
示例#5
0
void*
get_ot_assembly_ptr(int f, int g, int horiz)
{
    void*   rval = NULL;

    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);
        }
    }

    return rval;
}
示例#6
0
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;
}
示例#7
0
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);

            // 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;
                    }
                }
            }
        }
    }

    return rval;
}
示例#8
0
void QgsWCSServer::executeRequest()
{
  //request type
  QString request = mParameters.value( "REQUEST" );
  if ( request.isEmpty() )
  {
    //do some error handling
    QgsDebugMsg( "unable to find 'REQUEST' parameter, exiting..." );
    mRequestHandler->setServiceException( QgsMapServiceException( "OperationNotSupported", "Please check the value of the REQUEST parameter" ) );
    return;
  }

  if ( request.compare( "GetCapabilities", Qt::CaseInsensitive ) == 0 )
  {
    QDomDocument capabilitiesDocument;
    try
    {
      capabilitiesDocument = getCapabilities();
    }
    catch ( QgsMapServiceException& ex )
    {
      mRequestHandler->setServiceException( ex );
      return;
    }
    QgsDebugMsg( "seting GetCapabilities response" );
    mRequestHandler->setGetCapabilitiesResponse( capabilitiesDocument );
    return;
  }
  else if ( request.compare( "DescribeCoverage", Qt::CaseInsensitive ) == 0 )
  {
    QDomDocument describeDocument;
    try
    {
      describeDocument = describeCoverage();
    }
    catch ( QgsMapServiceException& ex )
    {
      mRequestHandler->setServiceException( ex );
      return;
    }
    QgsDebugMsg( "seting GetCapabilities response" );
    mRequestHandler->setGetCapabilitiesResponse( describeDocument );
    return;
  }
  else if ( request.compare( "GetCoverage", Qt::CaseInsensitive ) == 0 )
  {
    QByteArray* coverageOutput;
    try
    {
      coverageOutput = getCoverage();
    }
    catch ( QgsMapServiceException& ex )
    {
      mRequestHandler->setServiceException( ex );
      return;
    }
    if ( coverageOutput )
    {
      mRequestHandler->setGetCoverageResponse( coverageOutput );
    }
    return;
  }
}