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

void PoDoFo::PdfFontSimple::Init ( bool  bEmbed,
const PdfName rsSubType 
) [protected, inherited]

Initialize this font object.

Parameters:
bEmbedif true embed the font data into the PDF file.
rsSubTypethe subtype of the real font.

Definition at line 44 of file PdfFontSimple.cpp.

References PoDoFo::PdfDictionary::AddKey(), PoDoFo::PdfEncoding::AddToDictionary(), PoDoFo::PdfVecObjects::CreateObject(), PoDoFo::PdfFontSimple::EmbedFontFile(), PoDoFo::ePdfError_InvalidHandle, PoDoFo::PdfFont::GetBaseFont(), PoDoFo::PdfFontMetrics::GetBoundingBox(), PoDoFo::PdfVariant::GetDictionary(), PoDoFo::PdfEncoding::GetFirstChar(), PoDoFo::PdfFontMetrics::GetItalicAngle(), PoDoFo::PdfEncoding::GetLastChar(), PoDoFo::PdfElement::GetObject(), PoDoFo::PdfObject::GetOwner(), PoDoFo::PdfFontMetrics::GetPdfAscent(), PoDoFo::PdfFontMetrics::GetPdfDescent(), PoDoFo::PdfFontMetrics::GetWidthArray(), PODOFO_RAISE_ERROR, and PoDoFo::PdfObject::Reference().

Referenced by PoDoFo::PdfFontTrueType::PdfFontTrueType(), and PoDoFo::PdfFontType1::PdfFontType1().

{
    PdfObject*    pWidth;
    PdfObject*    pDescriptor;
    PdfVariant    var;
    PdfArray      array;

    pWidth = this->GetObject()->GetOwner()->CreateObject();
    if( !pWidth )
    {
        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
    }

    m_pMetrics->GetWidthArray( *pWidth, m_pEncoding->GetFirstChar(), m_pEncoding->GetLastChar() );

    pDescriptor = this->GetObject()->GetOwner()->CreateObject( "FontDescriptor" );
    if( !pDescriptor )
    {
        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
    }

    this->GetObject()->GetDictionary().AddKey( PdfName::KeySubtype, rsSubType );
    this->GetObject()->GetDictionary().AddKey("BaseFont", this->GetBaseFont() );
    this->GetObject()->GetDictionary().AddKey("FirstChar", PdfVariant( static_cast<pdf_int64>(m_pEncoding->GetFirstChar()) ) );
    this->GetObject()->GetDictionary().AddKey("LastChar", PdfVariant( static_cast<pdf_int64>(m_pEncoding->GetLastChar()) ) );
    m_pEncoding->AddToDictionary( this->GetObject()->GetDictionary() ); // Add encoding key

    this->GetObject()->GetDictionary().AddKey("Widths", pWidth->Reference() );
    this->GetObject()->GetDictionary().AddKey( "FontDescriptor", pDescriptor->Reference() );

    m_pMetrics->GetBoundingBox( array );

    pDescriptor->GetDictionary().AddKey( "FontName", this->GetBaseFont() );
    //pDescriptor->GetDictionary().AddKey( "FontWeight", (long)m_pMetrics->Weight() );
    pDescriptor->GetDictionary().AddKey( PdfName::KeyFlags, PdfVariant( static_cast<pdf_int64>(32LL) ) ); // TODO: 0 ????
    pDescriptor->GetDictionary().AddKey( "FontBBox", array );
    pDescriptor->GetDictionary().AddKey( "ItalicAngle", PdfVariant( static_cast<pdf_int64>(m_pMetrics->GetItalicAngle()) ) );
    pDescriptor->GetDictionary().AddKey( "Ascent", m_pMetrics->GetPdfAscent() );
    pDescriptor->GetDictionary().AddKey( "Descent", m_pMetrics->GetPdfDescent() );
    pDescriptor->GetDictionary().AddKey( "CapHeight", m_pMetrics->GetPdfAscent() ); // m_pMetrics->CapHeight() );
    pDescriptor->GetDictionary().AddKey( "StemV", PdfVariant( static_cast<pdf_int64>(1LL) ) );               // m_pMetrics->StemV() );

    // Peter Petrov 24 September 2008
    m_pDescriptor = pDescriptor;

    if( bEmbed )
    {
        this->EmbedFontFile( pDescriptor );
        m_bWasEmbedded = true;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index