Logo Search packages:      
Sourcecode: libpodofo version File versions  Download package

long PoDoFo::NonPublic::PdfTTFWriter::GetGlyphDataLocation ( unsigned int  nIndex,
long *  plLength,
PdfInputDevice pDevice 
) const [private]

Get the offset to the location of the glyphs data.

Parameters:
nIndexunicode index of the glyph to load
plLengthpointer to an address where the length of the glyphdata can be stored
pDevicean input device which can be used to read the CMap table which is required for certain glyphs
Returns:
the offset to the glyph data or -1 if the glyph does not exist

Definition at line 1428 of file PdfTTFWriter.cpp.

References m_lGlyphDataOffset, m_ranges, m_tLoca, and PoDoFo::NonPublic::PdfTTFWriter::TCMapFormat4::segCountX2.

{
    // find the correct cmap range
    std::vector<TCMapRange>::const_iterator it = m_ranges.begin();
    // TODO: binary search!!!
    while( it != m_ranges.end() )
    {
        if( (*it).nStart <= nIndex && (*it).nEnd > nIndex ) 
        {
            // we got a position!!
            printf("Found Range for %u: %6u - %6u Delta: %6i Offset: %6u\n", nIndex, (*it).nStart, (*it).nEnd, 
                   (*it).nDelta, (*it).nOffset );
            
            if( (*it).nOffset )
            {
                const int nSegCount = format4.segCountX2 >> 1;
                
                int j = (*it).nOffset - (nSegCount - (it-m_ranges.begin())*2);
                printf("j1 = %i\n", j );
                j = (nIndex - (*it).nStart) + j/2;
                printf("j2 = %i\n", j );
                nIndex = m_vecGlyphIds[j];
                printf("nIndex=%i\n", nIndex );

                
                // 81 ??? 
                // 1314

                /*
                long lAddress = (*it).nOffset/2 + (nIndex - (*it).nStart) + (*it).nOffset;
                pDevice->Seek( lAddress + m_lCMapOffset );

                pdf_ttf_ushort glyph;
                READ_TTF_USHORT( glyph );

                printf("lAddress alone=%lx %li\n", lAddress, lAddress );
                printf("lAddress=%lx\n", lAddress + m_lCMapOffset );
                nIndex = glyph;
                printf("glyph=%u\n", glyph );
                */
                //nIndex   = 108;
                //lAddress = 0x858a;
                //nIndex = *lAddress nach Seek
            }


            nIndex = static_cast<unsigned int>( (nIndex + (*it).nDelta & 0xFFFFU ) );
            break;
        }

        ++it;
    }

    if( it == m_ranges.end() ) // go to "missing glyph" if no glyph was found
        nIndex = 0;

    printf("INDEX: %i RANGE(0 - %i)\n", nIndex, m_tLoca.size() );
    // check if the glyph index is in our current range
    if( nIndex < 0 || nIndex > m_tLoca.size() )
        return -1;

    if( nIndex + 1 < m_tLoca.size() )
        *plLength = m_tLoca[nIndex+1] - m_tLoca[nIndex];
    else
        *plLength = 0;

    printf("Reading from index: %i (max: %i) len=%i\n", nIndex, m_tLoca.size(), *plLength );


    return m_lGlyphDataOffset + m_tLoca[nIndex];
}

Generated by  Doxygen 1.6.0   Back to index