00001
00002
00003
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
00075 };
00076
00081 Font (SDF::Obj font_dict = 0);
00082
00086 static Font Create(SDF::SDFDoc& doc, StandardType1Font type, bool embed = false );
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
00173
00174 enum Type
00175 {
00176 e_Type1,
00177 e_TrueType,
00178 e_MMType1,
00179 e_Type3,
00180 e_Type0,
00181 e_CIDType0,
00182 e_CIDType2,
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
00291 double GetWidth(UInt32 char_code) const;
00292
00296 double GetMaxWidth();
00297
00302 double GetMissingWidth();
00303
00308 Common::Iterator<UInt32> GetCharCodeIterator();
00309
00310
00334 bool GetGlyphPath(UInt32 char_code,
00335 std::vector<UChar>& out_oprs,
00336 std::vector<double>& out_data,
00337 bool conics2cubics,
00338 Common::Matrix2D* transform = 0);
00365 bool MapToUnicode(UInt32 char_code,
00366 Unicode* out_uni_arr, const int in_uni_sz,
00367 int &out_chars);
00368
00383 const char** GetEncoding();
00384
00391 bool IsEmbedded();
00392
00397 const char* GetEmbeddedFontName();
00398
00404 SDF::Obj GetEmbeddedFont();
00405
00414 int GetEmbeddedFontBufSize();
00415
00425 UInt16 GetUnitsPerEm();
00426
00433 Rect GetBBox();
00434
00444 double GetAscent();
00445
00455 double GetDescent();
00456
00457
00458
00459
00464 int GetStandardType1FontType();
00465
00470 bool IsCFF();
00471
00472
00473
00481 Common::Matrix2D GetType3FontMatrix();
00482
00490 SDF::Obj GetType3GlyphStream(UInt32 char_code);
00491
00492
00493
00494
00495
00513 double GetVerticalAdvance(UInt32 char_code, double &out_pos_vect_x, double &out_pos_vect_y);
00514
00520 Font GetDescendant();
00521
00527 UInt32 MapToCID(UInt32 char_code) const;
00528
00543 int MapToCID(const UChar* char_data, int char_data_avail, UInt32& out_charcode, UInt32& out_cid) const;
00544
00546 Font(TRN_Font impl);
00547 ~Font();
00548 TRN_Font mp_font;
00550 };
00551
00552
00553 #include <Impl/Font.inl>
00554
00555 };
00556 };
00557
00558 #endif
00559