Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

pdf::font::CTrueType Class Reference

truetype font dictionary in PDF More...

#include <TrueType.hh>

Inheritance diagram for pdf::font::CTrueType:

Inheritance graph
[legend]
Collaboration diagram for pdf::font::CTrueType:

Collaboration graph
[legend]
List of all members.

Public Methods

Private Attributes


Detailed Description

truetype font dictionary in PDF

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.


Constructor & Destructor Documentation

pdf::font::CTrueType::CTrueType const std::string &    filename,
int    index = 0,
CFlags::EFlags    flag = CFlags::serif
 

the contructor construct a font, given the name of the file, the font index in the file and the type of the font.

Parameters:
filename  the filename of the font
index  sometimes a font file can contain multiple font faces. this index will specify one of the face. zero based.
flag  font type. whether the font is a serif, sans, symbol or script 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 }


Member Function Documentation

const core::CObjRef pdf::font::CTrueType::Write core::CFile   file const [virtual]
 

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.

Parameters:
file  the PDF file object to store the truetype font.

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 }


Member Data Documentation

CDescriptor pdf::font::CTrueType::m_descriptor [private]
 

the font descriptor.


The documentation for this class was generated from the following files:
Generated on Sun Feb 2 09:17:22 2003 for libpdf++ by doxygen1.2.16