#include <TrueType.hh>
Inheritance diagram for pdf::font::CTrueType:
this class is responsible to general needed info to generate the truetype font dictionary in a PDF. clients of this class creates its object with only the filename of the font (and its index and flags, see the contructor for details). the rest is handled by this class.
it contains a font descriptor which store font metrics and embed the font program, which also store the character widths of all character in the font.
|
the contructor construct a font, given the name of the file, the font index in the file and the type of the font.
00055 : CSimple( core::CName( "TrueType" ) ), 00056 m_descriptor( filename, index, flag ) 00057 { 00058 // freetype::CLibrary library ; 00059 // freetype::CFace face( &library, filename, index ) ; 00060 00061 // BaseName( face.PSName( ) ) ; 00062 BaseName( m_descriptor.Name( ) ) ; 00063 00064 // size is set to 72DPI also, such that one pixel in the font is 00065 // equal to one user space. 00066 // since glyph space is 1/1000 of text space, we use a 1000 pt 00067 // font and its size will be in glyph space 00068 // face.SetSize( 0, 1000, 72, 72 ) ; 00069 00070 /* for ( int i = 0 ; i < width_count ; i++ ) 00071 { 00072 freetype::CGlyph glyph( &face, face.GetGlyphCode( i ) ) ; 00073 m_widths[i] = static_cast<int>( glyph.HoriAdvance( ) ) ; 00074 } 00075 00076 m_descriptor.SetWidth( m_widths, width_count ) ; 00077 */ 00078 } |
|
this function will generate the font dictionary and store it in the PDF file. the font descriptor will also be generated and added as a separate PDF object.
Implements pdf::common::CResource.
00091 { 00092 using namespace core ; 00093 00094 CDictionary *font = CSimple::MakeFontDict( ) ; 00095 font->AddPair( "FirstChar", new CNumber( 0 ) ) ; 00096 font->AddPair( "LastChar", new CNumber( m_descriptor.CharCount( ) - 1 ) ) ; 00097 00098 // width array 00099 CDescriptor::WidthPair widths = m_descriptor.Widths( ) ; 00100 CArray *width_array = new CArray( widths.first, widths.second ) ; 00101 font->AddPair( "Widths", file.AddObj( width_array ).Dup( ) ) ; 00102 00103 // descriptor 00104 font->AddPair( "FontDescriptor", m_descriptor.Write( file ).Dup( ) ) ; 00105 00106 return file.AddObj( font ) ; 00107 } |
|
the font descriptor.
|