All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Font.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------------------
2 // Copyright (c) 2001-2018 by PDFTron Systems Inc. All Rights Reserved.
3 // Consult legal.txt regarding legal and license information.
4 //---------------------------------------------------------------------------------------
5 #ifndef PDFTRON_H_CPPPDFFont
6 #define PDFTRON_H_CPPPDFFont
7 
8 #include <Common/Matrix2D.h>
9 #include <Common/UString.h>
10 #include <Common/Iterator.h>
11 #include <PDF/Rect.h>
12 #include <PDF/PathData.h>
13 #include <C/PDF/TRN_Font.h>
14 #include <C/SDF/TRN_SDFDoc.h>
15 #include <vector>
16 
17 namespace pdftron {
18  namespace PDF {
19 
54 class Font
55 {
56 public:
57 
59  {
74  e_null // not a standard font
75  };
76 
82  Font (SDF::Obj font_dict = 0);
83 
87  static Font Create(SDF::SDFDoc& doc, StandardType1Font type, bool embed = false );
88 
103  static Font CreateTrueTypeFont(SDF::SDFDoc& doc, const UString& font_path,
104  bool embed=true, bool subset=true);
105 
120  #ifdef _WIN32
121  static Font CreateTrueTypeFont2(SDF::SDFDoc& doc, const void* logfont,
122  bool embed=true, bool subset=true);
123  #endif
124 
125 
126  enum Encoding
127  {
130  };
131 
150  static Font CreateCIDTrueTypeFont(SDF::SDFDoc& doc, const UString& font_path,
151  bool embed = true, bool subset = true,
152  Encoding encoding=e_IdentityH,
153  UInt32 ttc_font_index=0);
154 
171  #ifdef _WIN32
172  static Font CreateCIDTrueTypeFont2(SDF::SDFDoc& doc, const void* logfont,
173  bool embed = true, bool subset = true,
174  Encoding encoding=e_IdentityH);
175  #endif
176 
181  static Font Create(SDF::SDFDoc& doc, Font& from, const UString& char_set);
182  static Font Create(SDF::SDFDoc& doc, const char* name, const UString& char_set);
183 
192  static Font CreateType1Font(SDF::SDFDoc& doc, const UString& font_path, bool embed = true);
193 
194  // Common Font methods ----------------------------------------------------------
195 
196  enum Type
197  {
198  e_Type1, // Type 1 PostScript font
199  e_TrueType, // TrueType font
200  e_MMType1, // Type 1 multiple master PostScript font
201  e_Type3, // Type 3 PostScript font
202  e_Type0, // Type 0 PostScript composite (CID) font
203  e_CIDType0, // Type 0 CID font
204  e_CIDType2, // Type 2 CID font
205  };
206 
207 
208  Font(const Font& c);
209  Font& operator=(const Font& c);
210 
214  Type GetType();
215 
232  bool IsSimple();
233 
234 #ifndef SWIG
235 
238  static Type GetType(SDF::Obj font_dict);
239 #endif
240 
244  SDF::Obj GetSDFObj ();
245 
251 
257  const char* GetName();
258 
264  const char* GetFamilyName();
265 
269  bool IsFixedWidth();
270 
274  bool IsSerif();
275 
279  bool IsSymbolic();
280 
284  bool IsItalic();
285 
289  bool IsAllCap();
290 
294  bool IsForceBold();
295 
299  bool IsHorizontalMode();
300 
315  double GetWidth(UInt32 char_code) const;
316 
320  double GetMaxWidth();
321 
326  double GetMissingWidth();
327 
333 
334 
355  PathData GetGlyphPath(UInt32 char_code,
356  bool conics2cubics,
357  Common::Matrix2D* transform = 0);
358 
385  UString MapToUnicode(UInt32 char_code);
386 
387 #ifndef SWIG
388  bool MapToUnicode(UInt32 char_code,
389  Unicode* out_uni_arr, const int in_uni_sz,
390  int &out_chars);
391 #endif
392 
393 #ifndef SWIG
394 
408  const char** GetEncoding();
409 #endif
410 
417  bool IsEmbedded();
418 
423  const char* GetEmbeddedFontName();
424 
431 
441 
452 
459  Rect GetBBox();
460 
470  double GetAscent();
471 
481  double GetDescent();
482 
483 
484  // Type1 specific methods -------------------------------------------------------
485 
491 
496  bool IsCFF();
497 
498  // Type3 specific methods -------------------------------------------------------
499 
508 
517 
518 
519  // Type0 specific methods -------------------------------------------------------
520 
521 
539  std::vector<double> GetVerticalAdvance(UInt32 char_code);
540 
541 #ifndef SWIG
542  double GetVerticalAdvance(UInt32 char_code, double &out_pos_vect_x, double &out_pos_vect_y);
543 #endif
544 
551 
557  UInt32 MapToCID(UInt32 char_code) const;
558 
559 #ifndef SWIG
560 
574  int MapToCID(const UChar* char_data, int char_data_avail, UInt32& out_charcode, UInt32& out_cid) const;
575 #endif
576 
580  void Destroy();
581 
583 #ifndef SWIGHIDDEN
584  Font(TRN_Font impl);
585  ~Font();
586  TRN_Font mp_font;
587 #endif
588 };
590 
591 
592 #include <Impl/Font.inl>
593 
594  }; // namespace PDF
595 }; // namespace pdftron
596 
597 #endif // PDFTRON_H_CPPPDFFont
UInt16 GetUnitsPerEm()
PathData GetGlyphPath(UInt32 char_code, bool conics2cubics, Common::Matrix2D *transform=0)
std::vector< double > GetVerticalAdvance(UInt32 char_code)
const char * GetFamilyName()
TRN_UInt16 UInt16
Definition: BasicTypes.h:14
Common::Iterator< UInt32 > GetCharCodeIterator()
static Font CreateCIDTrueTypeFont(SDF::SDFDoc &doc, const UString &font_path, bool embed=true, bool subset=true, Encoding encoding=e_IdentityH, UInt32 ttc_font_index=0)
UString MapToUnicode(UInt32 char_code)
const char * GetName()
Font & operator=(const Font &c)
TRN_Unicode Unicode
Definition: BasicTypes.h:22
static Font CreateType1Font(SDF::SDFDoc &doc, const UString &font_path, bool embed=true)
int GetStandardType1FontType()
TRN_UInt32 UInt32
Definition: BasicTypes.h:13
static Font CreateTrueTypeFont(SDF::SDFDoc &doc, const UString &font_path, bool embed=true, bool subset=true)
double GetWidth(UInt32 char_code) const
Common::Matrix2D GetType3FontMatrix()
TRN_UChar UChar
Definition: BasicTypes.h:12
double GetMissingWidth()
SDF::Obj GetSDFObj()
static Font Create(SDF::SDFDoc &doc, StandardType1Font type, bool embed=false)
SDF::Obj GetDescriptor()
SDF::Obj GetEmbeddedFont()
UInt32 MapToCID(UInt32 char_code) const
const char * GetEmbeddedFontName()
const char ** GetEncoding()
int GetEmbeddedFontBufSize()
SDF::Obj GetType3GlyphStream(UInt32 char_code)
Font(SDF::Obj font_dict=0)

© 2002-2014 PDFTron Systems Inc.