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

PoDoFo::PdfFontMetricsObject::PdfFontMetricsObject ( PdfObject pFont,
PdfObject pDescriptor,
const PdfEncoding *const   pEncoding 
)

Create a font metrics object based on an existing PdfObject

Parameters:
pObjectan existing font descriptor object
pEncodinga PdfEncoding which will NOT be owned by PdfFontMetricsObject

Definition at line 30 of file PdfFontMetricsObject.cpp.

References PoDoFo::ePdfError_InvalidHandle, PoDoFo::PdfVariant::GetArray(), PoDoFo::PdfVariant::GetDictionary(), PoDoFo::PdfObject::GetIndirectKey(), PoDoFo::PdfDictionary::GetKey(), PoDoFo::PdfVariant::GetName(), m_bSymbol, and PODOFO_RAISE_ERROR.

    : PdfFontMetrics( ePdfFontType_Unknown, "", NULL ),
      m_pEncoding( pEncoding )
{
    if( !pDescriptor )
    {
        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
    }

    m_sName        = pDescriptor->GetDictionary().GetKey( "FontName" )->GetName();
    m_bbox         = pDescriptor->GetDictionary().GetKey( "FontBBox" )->GetArray();
    // OC 15.08.2010 BugFix: /FirstChar /LastChar /Widths are in the Font dictionary and not in the FontDescriptor
    m_nFirst       = static_cast<int>(pFont->GetDictionary().GetKeyAsLong( "FirstChar", 0L ));
    m_nLast        = static_cast<int>(pFont->GetDictionary().GetKeyAsLong( "LastChar", 0L ));
       // OC 15.08.2010 BugFix: GetIndirectKey() instead of GetDictionary().GetKey() and "Widths" instead of "Width"
    m_width        = pFont->GetIndirectKey( "Widths" )->GetArray();

    m_nWeight      = static_cast<unsigned int>(pDescriptor->GetDictionary().GetKeyAsLong( "FontWeight", 400L ));
    m_nItalicAngle = static_cast<int>(pDescriptor->GetDictionary().GetKeyAsLong( "ItalicAngle", 0L ));

    m_dPdfAscent   = pDescriptor->GetDictionary().GetKeyAsReal( "Ascent", 0.0 );
    m_dAscent      = m_dPdfAscent / 1000.0;
    m_dPdfDescent  = pDescriptor->GetDictionary().GetKeyAsReal( "Descent", 0.0 );
    m_dDescent     = m_dPdfDescent / 1000.0;
    m_dLineSpacing = m_dAscent + m_dDescent;
    
    // Try to fine some sensible values
    m_dUnderlineThickness = 1.0;
    m_dUnderlinePosition  = 0.0;
    m_dStrikeOutThickness = m_dUnderlinePosition;
    m_dStrikeOutPosition  = m_dAscent / 2.0;

    m_bSymbol = false; // TODO
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index