Loading...
Searching...
No Matches
Font.h
Go to the documentation of this file.
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2025 by Apryse Software 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 <PDF/ShapedText.h>
14#include <C/PDF/TRN_Font.h>
15#include <C/SDF/TRN_SDFDoc.h>
16#include <vector>
17
18namespace pdftron {
19 namespace PDF {
20
55class Font
56{
57public:
58
77
83 Font (SDF::Obj font_dict = 0);
84
88 static Font Create(SDF::SDFDoc& doc, StandardType1Font type, bool embed = false );
89
104 static Font CreateTrueTypeFont(SDF::SDFDoc& doc, const UString& font_path,
105 bool embed=true, bool subset=true);
106
121 #ifdef _WIN32
122 static Font CreateTrueTypeFont2(SDF::SDFDoc& doc, const void* logfont,
123 bool embed=true, bool subset=true);
124 #endif
125
126
132
151 static Font CreateCIDTrueTypeFont(SDF::SDFDoc& doc, const UString& font_path,
152 bool embed = true, bool subset = true,
153 Encoding encoding=e_IdentityH,
154 UInt32 ttc_font_index=0);
155
172 #ifdef _WIN32
173 static Font CreateCIDTrueTypeFont2(SDF::SDFDoc& doc, const void* logfonta,
174 bool embed = true, bool subset = true,
175 Encoding encoding=e_IdentityH);
176 #endif
177
194#ifdef _WIN32
195 static Font CreateCIDTrueTypeFont2Unicode(SDF::SDFDoc& doc, const void* logfontw,
196 bool embed = true, bool subset = true,
197 Encoding encoding = e_IdentityH);
198#endif
199
214 static Font Create(SDF::SDFDoc& doc, Font& from, const UString& char_set);
215
230 static Font Create(SDF::SDFDoc& doc, const char* name, const UString& char_set);
231
240 static Font CreateType1Font(SDF::SDFDoc& doc, const UString& font_path, bool embed = true);
241
242 // Common Font methods ----------------------------------------------------------
243
244 enum Type
245 {
246 e_Type1, // Type 1 PostScript font
247 e_TrueType, // TrueType font
248 e_MMType1, // Type 1 multiple master PostScript font
249 e_Type3, // Type 3 PostScript font
250 e_Type0, // Type 0 PostScript composite (CID) font
251 e_CIDType0, // Type 0 CID font
252 e_CIDType2, // Type 2 CID font
253 };
254
255
256 Font(const Font& c);
257 Font& operator=(const Font& c);
258
263
280 bool IsSimple();
281
282#ifndef SWIG
286 static Type GetType(SDF::Obj font_dict);
287#endif
288
293
299
305 const char* GetName();
306
312 const char* GetFamilyName();
313
318
322 bool IsSerif();
323
328
332 bool IsItalic();
333
337 bool IsAllCap();
338
343
348
363 double GetWidth(UInt32 char_code) const;
364
368 double GetMaxWidth();
369
375
381
382
404 bool conics2cubics,
405 Common::Matrix2D* transform = 0);
406
407
429 ShapedText GetShapedText(const UString& text_to_shape);
430
458
459#ifndef SWIG
460 bool MapToUnicode(UInt32 char_code,
461 Unicode* out_uni_arr, const int in_uni_sz,
462 int &out_chars);
463#endif
464
465#ifndef SWIG
480 const char** GetEncoding();
481#endif
482
490
495 const char* GetEmbeddedFontName();
496
503
513
524
532
542 double GetAscent();
543
553 double GetDescent();
554
555
556 // Type1 specific methods -------------------------------------------------------
557
563
568 bool IsCFF();
569
570 // Type3 specific methods -------------------------------------------------------
571
580
589
590
591 // Type0 specific methods -------------------------------------------------------
592
593
611#ifndef SWIG
612 double GetVerticalAdvance(UInt32 char_code, double &out_pos_vect_x, double &out_pos_vect_y);
613#endif
614
615 std::vector<double> GetVerticalAdvance(UInt32 char_code);
616
623
629 UInt32 MapToCID(UInt32 char_code) const;
630
631#ifndef SWIG
646 int MapToCID(const UChar* char_data, int char_data_avail, UInt32& out_charcode, UInt32& out_cid) const;
647#endif
648
652 void Destroy();
653
654// @cond PRIVATE_DOC
655#ifndef SWIGHIDDEN
656 Font(TRN_Font impl);
657 ~Font();
658 TRN_Font mp_font;
659#endif
660// @endcond
661};
662
663
664#include <Impl/Font.inl>
665
666 }; // namespace PDF
667}; // namespace pdftron
668
669#endif // PDFTRON_H_CPPPDFFont
const char * GetEmbeddedFontName()
const char ** GetEncoding()
static Font Create(SDF::SDFDoc &doc, const char *name, const UString &char_set)
double GetMissingWidth()
int MapToCID(const UChar *char_data, int char_data_avail, UInt32 &out_charcode, UInt32 &out_cid) const
static Font CreateTrueTypeFont(SDF::SDFDoc &doc, const UString &font_path, bool embed=true, bool subset=true)
Font(SDF::Obj font_dict=0)
Font(const Font &c)
static Font CreateType1Font(SDF::SDFDoc &doc, const UString &font_path, bool embed=true)
SDF::Obj GetSDFObj()
UString MapToUnicode(UInt32 char_code)
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)
@ e_helvetica_bold_oblique
Definition Font.h:68
@ e_helvetica_oblique
Definition Font.h:67
@ e_courier_bold_oblique
Definition Font.h:72
@ e_times_bold_italic
Definition Font.h:64
const char * GetFamilyName()
static Type GetType(SDF::Obj font_dict)
SDF::Obj GetEmbeddedFont()
std::vector< double > GetVerticalAdvance(UInt32 char_code)
int GetEmbeddedFontBufSize()
UInt16 GetUnitsPerEm()
double GetVerticalAdvance(UInt32 char_code, double &out_pos_vect_x, double &out_pos_vect_y)
bool MapToUnicode(UInt32 char_code, Unicode *out_uni_arr, const int in_uni_sz, int &out_chars)
Common::Iterator< UInt32 > GetCharCodeIterator()
UInt32 MapToCID(UInt32 char_code) const
ShapedText GetShapedText(const UString &text_to_shape)
double GetWidth(UInt32 char_code) const
SDF::Obj GetDescriptor()
static Font Create(SDF::SDFDoc &doc, Font &from, const UString &char_set)
static Font Create(SDF::SDFDoc &doc, StandardType1Font type, bool embed=false)
Font & operator=(const Font &c)
PathData GetGlyphPath(UInt32 char_code, bool conics2cubics, Common::Matrix2D *transform=0)
int GetStandardType1FontType()
Common::Matrix2D GetType3FontMatrix()
SDF::Obj GetType3GlyphStream(UInt32 char_code)
const char * GetName()
TRN_UInt32 UInt32
Definition BasicTypes.h:13
TRN_UChar UChar
Definition BasicTypes.h:12
TRN_UInt16 UInt16
Definition BasicTypes.h:14
TRN_Unicode Unicode
Definition BasicTypes.h:22