Font.h

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------------------
00002 // Copyright (c) 2001-2008 by PDFTron Systems Inc. All Rights Reserved.
00003 // Consult legal.txt regarding legal and license information.
00004 //---------------------------------------------------------------------------------------
00005 
00006 #ifndef   H_CPPPDFFont
00007 #define   H_CPPPDFFont
00008 
00009 #include <Common/Matrix2D.h>
00010 #include <Common/UString.h>
00011 #include <Common/Iterator.h>
00012 #include <PDF/Rect.h>
00013 #include <C/PDF/TRN_Font.h>
00014 #include <C/SDF/TRN_SDFDoc.h>
00015 #include <vector>
00016 
00017 namespace pdftron {
00018         namespace PDF {
00019 
00054 class Font
00055 {
00056 public:
00057 
00058         enum StandardType1Font
00059         {
00060                 e_times_roman = 0,
00061                 e_times_bold,
00062                 e_times_italic,
00063                 e_times_bold_italic,
00064                 e_helvetica,
00065                 e_helvetica_bold,
00066                 e_helvetica_oblique,
00067                 e_helvetica_bold_oblique,
00068                 e_courier,
00069                 e_courier_bold,
00070                 e_courier_oblique,
00071                 e_courier_bold_oblique,
00072                 e_symbol, 
00073                 e_zapf_dingbats,
00074                 e_null                          // not a standard font
00075         };
00076 
00081          Font (SDF::Obj font_dict = 0);
00082 
00086          static Font Create(SDF::SDFDoc& doc, StandardType1Font type);
00087 
00102          static Font CreateTrueTypeFont(SDF::SDFDoc& doc, const UString& font_path, 
00103                 bool embed=true, bool subset=true);
00104 
00119         #ifdef _WIN32
00120          static Font CreateTrueTypeFont2(SDF::SDFDoc& doc, const void* logfont, 
00121                 bool embed=true, bool subset=true);
00122         #endif
00123 
00138          static Font CreateCIDTrueTypeFont(SDF::SDFDoc& doc, const UString& font_path, 
00139                 bool embed = true, bool subset = true, 
00140                 const char* encoding = "Identity-H");
00141 
00156         #ifdef _WIN32
00157          static Font CreateCIDTrueTypeFont2(SDF::SDFDoc& doc, const void* logfont, 
00158                 bool embed = true, bool subset = true, 
00159                 const char* encoding = "Identity-H");
00160         #endif
00161 
00170          static Font CreateType1Font(SDF::SDFDoc& doc, const UString& font_path, bool embed = true);
00171 
00172         // Common Font methods ----------------------------------------------------------
00173 
00174         enum Type
00175         {
00176                 e_Type1,                        // Type 1 PostScript font       
00177                 e_TrueType,                     // TrueType font
00178                 e_MMType1,                      // Type 1 multiple master PostScript font
00179                 e_Type3,                        // Type 3 PostScript font
00180                 e_Type0,                        // Type 0 PostScript composite (CID) font
00181                 e_CIDType0,                     // Type 0 CID font
00182                 e_CIDType2,                     // Type 2 CID font
00183         };
00184 
00185 
00186          Font(const Font& c);
00187          Font& operator=(const Font& c);
00188 
00192          Type GetType();
00193 
00210          bool IsSimple();
00211 
00215          static Type GetType(SDF::Obj font_dict);
00216 
00220          SDF::Obj GetSDFObj ();
00221 
00226          SDF::Obj GetDescriptor();
00227 
00233          const char* GetName();
00234 
00240          const char* GetFamilyName();
00241 
00245          bool IsFixedWidth();
00246 
00250          bool IsSerif();
00251 
00255          bool IsSymbolic();
00256 
00260          bool IsItalic();
00261 
00265          bool IsAllCap();
00266 
00270          bool IsForceBold();
00271 
00275          bool IsHorizontalMode();
00276 
00287          double GetWidth(UInt char_code);
00288 
00292          double GetMaxWidth();
00293 
00298          double GetMissingWidth();
00299 
00304          Common::Iterator<UInt> GetCharCodeIterator();
00305 
00306 
00330          bool GetGlyphPath(UInt char_code,
00331                                           std::vector<UChar>& out_oprs, 
00332                                           std::vector<double>& out_data, 
00333                                           bool conics2cubics, 
00334                                           Common::Matrix2D* transform = 0);
00361          bool MapToUnicode(UInt char_code, 
00362                         Unicode* out_uni_arr, const int in_uni_sz, 
00363                         int &out_chars);
00364 
00379          const char** GetEncoding();
00380 
00387          bool IsEmbedded();
00388 
00393          const char* GetEmbeddedFontName();
00394 
00400          SDF::Obj GetEmbeddedFont();
00401 
00410          int GetEmbeddedFontBufSize();
00411 
00421          UShort GetUnitsPerEm();
00422 
00429          Rect GetBBox();
00430 
00440          double GetAscent();
00441 
00451          double GetDescent();
00452 
00453 
00454         // Type1 specific methods -------------------------------------------------------
00455 
00460          int GetStandardType1FontType();
00461 
00466          bool IsCFF();
00467 
00468         // Type3 specific methods -------------------------------------------------------
00469 
00477          Common::Matrix2D GetType3FontMatrix();
00478 
00486          SDF::Obj GetType3GlyphStream(UInt char_code);
00487 
00488 
00489         // Type0 specific methods -------------------------------------------------------
00490 
00491 
00509          double GetVerticalAdvance(UInt char_code, double &out_pos_vect_x, double &out_pos_vect_y);
00510 
00516          Font GetDescendant();
00517 
00523          UInt MapToCID(UInt char_code);
00524 
00539          int MapToCID(const UChar* char_data, int char_data_avail, UInt& out_charcode, UInt& out_cid);
00540 
00542         Font(TRN_Font impl);
00543         ~Font();        
00544         TRN_Font mp_font;
00546 };
00547 
00548 
00549 #include <Impl/Font.inl>
00550 
00551         };      // namespace PDF
00552 };      // namespace pdftron
00553 
00554 #endif
00555 

© 2002-2008 PDFTron Systems Inc.