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

void PoDoFo::PdfFontTrueType::EmbedFontFile ( PdfObject pDescriptor ) [private, virtual]

Embed the font file directly into the PDF file.

Parameters:
pDescriptorfont descriptor object

Implements PoDoFo::PdfFontSimple.

Definition at line 45 of file PdfFontTrueType.cpp.

References PoDoFo::PdfDictionary::AddKey(), PoDoFo::PdfVecObjects::CreateObject(), PoDoFo::ePdfError_InvalidHandle, PoDoFo::PdfVariant::GetDictionary(), PoDoFo::PdfFileInputStream::GetFileLength(), PoDoFo::PdfFontMetrics::GetFilename(), PoDoFo::PdfFontMetrics::GetFontData(), PoDoFo::PdfFontMetrics::GetFontDataLen(), PoDoFo::PdfElement::GetObject(), PoDoFo::PdfObject::GetOwner(), PoDoFo::PdfObject::GetStream(), PODOFO_RAISE_ERROR, PoDoFo::PdfObject::Reference(), and PoDoFo::PdfStream::Set().

{
    PdfObject* pContents;
    pdf_long   lSize = 0;
    
    m_bWasEmbedded = true;    
        
    pContents = this->GetObject()->GetOwner()->CreateObject();
    if( !pContents )
    {
        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
    }
        
    pDescriptor->GetDictionary().AddKey( "FontFile2", pContents->Reference() );

    // if the data was loaded from memory - use it from there
    // otherwise, load from disk
    if ( m_pMetrics->GetFontDataLen() && m_pMetrics->GetFontData() ) 
    {
        // FIXME const_cast<char*> is dangerous if string literals may ever be passed
        char* pBuffer = const_cast<char*>( m_pMetrics->GetFontData() );
        lSize = m_pMetrics->GetFontDataLen();
        
        // Set Length1 before creating the stream
        // as PdfStreamedDocument does not allow 
        // adding keys to an object after a stream was written
        pContents->GetDictionary().AddKey( "Length1", PdfVariant( static_cast<pdf_int64>(lSize) ) );
        pContents->GetStream()->Set( pBuffer, lSize );
    } 
    else 
    {
        PdfFileInputStream stream( m_pMetrics->GetFilename() );
        lSize = stream.GetFileLength();

        // Set Length1 before creating the stream
        // as PdfStreamedDocument does not allow 
        // adding keys to an object after a stream was written
        pContents->GetDictionary().AddKey( "Length1", PdfVariant( static_cast<pdf_int64>(lSize) ) );
        pContents->GetStream()->Set( &stream );
            
    }
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index