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 <PDF/PathData.h>
00014 #include <C/PDF/TRN_Font.h>
00015 #include <C/SDF/TRN_SDFDoc.h>
00016 #include <vector>
00017
00018 namespace pdftron {
00019 namespace PDF {
00020
00055 class Font
00056 {
00057 public:
00058
00059 enum StandardType1Font
00060 {
00061 e_times_roman = 0,
00062 e_times_bold,
00063 e_times_italic,
00064 e_times_bold_italic,
00065 e_helvetica,
00066 e_helvetica_bold,
00067 e_helvetica_oblique,
00068 e_helvetica_bold_oblique,
00069 e_courier,
00070 e_courier_bold,
00071 e_courier_oblique,
00072 e_courier_bold_oblique,
00073 e_symbol,
00074 e_zapf_dingbats,
00075 e_null
00076 };
00077
00082 Font (SDF::Obj font_dict = 0);
00083
00087 static Font Create(SDF::SDFDoc& doc, StandardType1Font type, bool embed = false );
00088
00103 static Font CreateTrueTypeFont(SDF::SDFDoc& doc, const UString& font_path,
00104 bool embed=true, bool subset=true);
00105
00120 #ifdef _WIN32
00121 static Font CreateTrueTypeFont2(SDF::SDFDoc& doc, const void* logfont,
00122 bool embed=true, bool subset=true);
00123 #endif
00124
00139 static Font CreateCIDTrueTypeFont(SDF::SDFDoc& doc, const UString& font_path,
00140 bool embed = true, bool subset = true,
00141 const char* encoding = "Identity-H");
00142
00157 #ifdef _WIN32
00158 static Font CreateCIDTrueTypeFont2(SDF::SDFDoc& doc, const void* logfont,
00159 bool embed = true, bool subset = true,
00160 const char* encoding = "Identity-H");
00161 #endif
00162
00171 static Font CreateType1Font(SDF::SDFDoc& doc, const UString& font_path, bool embed = true);
00172
00173
00174
00175 enum Type
00176 {
00177 e_Type1,
00178 e_TrueType,
00179 e_MMType1,
00180 e_Type3,
00181 e_Type0,
00182 e_CIDType0,
00183 e_CIDType2,
00184 };
00185
00186
00187 Font(const Font& c);
00188 Font& operator=(const Font& c);
00189
00193 Type GetType();
00194
00211 bool IsSimple();
00212
00213 #ifndef SWIG
00214
00217 static Type GetType(SDF::Obj font_dict);
00218 #endif
00219
00223 SDF::Obj GetSDFObj ();
00224
00229 SDF::Obj GetDescriptor();
00230
00236 const char* GetName();
00237
00243 const char* GetFamilyName();
00244
00248 bool IsFixedWidth();
00249
00253 bool IsSerif();
00254
00258 bool IsSymbolic();
00259
00263 bool IsItalic();
00264
00268 bool IsAllCap();
00269
00273 bool IsForceBold();
00274
00278 bool IsHorizontalMode();
00279
00294 double GetWidth(UInt32 char_code) const;
00295
00299 double GetMaxWidth();
00300
00305 double GetMissingWidth();
00306
00311 Common::Iterator<UInt32> GetCharCodeIterator();
00312
00313
00334 PathData GetGlyphPath(UInt32 char_code,
00335 bool conics2cubics,
00336 Common::Matrix2D* transform = 0);
00337
00338 #ifndef SWIG
00339
00362 bool GetGlyphPath(UInt32 char_code,
00363 std::vector<UChar>& out_oprs,
00364 std::vector<double>& out_data,
00365 bool conics2cubics,
00366 Common::Matrix2D* transform = 0);
00367 #endif
00368
00395 UString MapToUnicode(UInt32 char_code);
00396
00397 #ifndef SWIG
00398 bool MapToUnicode(UInt32 char_code,
00399 Unicode* out_uni_arr, const int in_uni_sz,
00400 int &out_chars);
00401 #endif
00402
00403 #ifndef SWIG
00404
00418 const char** GetEncoding();
00419 #endif
00420
00427 bool IsEmbedded();
00428
00433 const char* GetEmbeddedFontName();
00434
00440 SDF::Obj GetEmbeddedFont();
00441
00450 int GetEmbeddedFontBufSize();
00451
00461 UInt16 GetUnitsPerEm();
00462
00469 Rect GetBBox();
00470
00480 double GetAscent();
00481
00491 double GetDescent();
00492
00493
00494
00495
00500 int GetStandardType1FontType();
00501
00506 bool IsCFF();
00507
00508
00509
00517 Common::Matrix2D GetType3FontMatrix();
00518
00526 SDF::Obj GetType3GlyphStream(UInt32 char_code);
00527
00528
00529
00530
00531
00549 std::vector<double> GetVerticalAdvance(UInt32 char_code);
00550
00551 #ifndef SWIG
00552 double GetVerticalAdvance(UInt32 char_code, double &out_pos_vect_x, double &out_pos_vect_y);
00553 #endif
00554
00560 Font GetDescendant();
00561
00567 UInt32 MapToCID(UInt32 char_code) const;
00568
00569 #ifndef SWIG
00570
00584 int MapToCID(const UChar* char_data, int char_data_avail, UInt32& out_charcode, UInt32& out_cid) const;
00585 #endif
00586
00590 void Destroy();
00591
00593 #ifndef SWIGHIDDEN
00594 Font(TRN_Font impl);
00595 ~Font();
00596 TRN_Font mp_font;
00597 #endif
00599 };
00600
00601
00602 #include <Impl/Font.inl>
00603
00604 };
00605 };
00606
00607 #endif
00608