PoDoFo 1.2.0
Loading...
Searching...
No Matches
PdfFontMetricsObject.h
1// SPDX-FileCopyrightText: 2010 Dominik Seichter <domseichter@web.de>
2// SPDX-FileCopyrightText: 2020 Francesco Pretto <ceztko@gmail.com>
3// SPDX-License-Identifier: LGPL-2.0-or-later OR MPL-2.0
4
5#ifndef PDF_FONT_METRICS_OBJECT_H
6#define PDF_FONT_METRICS_OBJECT_H
7
8#include "PdfDeclarations.h"
9
10#include <array>
11
12#include "PdfFontMetrics.h"
13#include "PdfArray.h"
14#include "PdfName.h"
15#include "PdfString.h"
16
17
18namespace PoDoFo {
19
20class PODOFO_API PdfFontMetricsObject final : public PdfFontMetricsBase
21{
22 friend class PdfFont;
23
24private:
28 PdfFontMetricsObject(const PdfDictionary& fontDict, const PdfReference& fontRef, const PdfDictionary* descriptorDict);
29
30public:
31 ~PdfFontMetricsObject();
32
33 static std::unique_ptr<const PdfFontMetricsObject> Create(const PdfObject& font);
34
35 bool HasUnicodeMapping() const override;
36
37 bool TryGetGID(char32_t codePoint, unsigned& gid) const override;
38
39 bool TryGetFlags(PdfFontDescriptorFlags& value) const override;
40
41 bool TryGetBoundingBox(Corners& value) const override;
42
43 bool TryGetItalicAngle(double& value) const override;
44
45 bool TryGetAscent(double& value) const override;
46
47 bool TryGetDescent(double& value) const override;
48
49 bool TryGetCapHeight(double& value) const override;
50
51 bool TryGetStemV(double& value) const override;
52
53 double GetDefaultWidthRaw() const override;
54
55 double GetLineSpacing() const override;
56
57 double GetUnderlineThickness() const override;
58
59 double GetUnderlinePosition() const override;
60
61 double GetStrikeThroughPosition() const override;
62
63 double GetStrikeThroughThickness() const override;
64
65 std::string_view GetFontName() const override;
66
67 std::string_view GetFontNameRaw() const override;
68
69 std::string_view GetFontFamilyName() const override;
70
71 unsigned char GetSubsetPrefixLength() const override;
72
73 PdfFontStretch GetFontStretch() const override;
74
75 double GetLeadingRaw() const override;
76
77 int GetWeightRaw() const override;
78
79 double GetXHeightRaw() const override;
80
81 double GetStemHRaw() const override;
82
83 double GetAvgWidthRaw() const override;
84
85 double GetMaxWidthRaw() const override;
86
87 PdfFontFileType GetFontFileType() const override;
88
89 const PdfObject* GetFontFileObject() const override;
90
91 unsigned GetFontFileLength1() const override;
92
93 unsigned GetFontFileLength2() const override;
94
95 unsigned GetFontFileLength3() const override;
96
97 const Matrix& GetMatrix() const override;
98
99 bool IsObjectLoaded() const override;
100
101protected:
102 void ExportType3GlyphData(PdfDictionary& fontDict, cspan<std::string_view> glyphs) const override;
103
104 unsigned GetGlyphCountFontProgram() const override;
105
106 std::string_view GetBaseFontName() const override;
107
108 PdfFontType GetFontType() const override;
109
110 bool getIsBoldHint() const override;
111
112 bool getIsItalicHint() const override;
113
114 datahandle getFontFileDataHandle() const override;
115
116private:
117 static std::unique_ptr<const PdfFontMetricsObject> Create(const PdfObject& font, const PdfDictionary* descriptor);
118
119 void processFontName();
120
121 Corners getBBox(const PdfObject& obj);
122
123private:
124 struct Type3FontData;
125
126 std::shared_ptr<charbuff> m_Data;
127 PdfCIDToGIDMapConstPtr m_CIDToGIDMap;
128 Matrix m_Matrix;
129
130 std::string m_FontName;
131 std::string m_FontNameRaw;
132 std::string m_FontBaseName;
133 std::string m_FontFamilyName;
134 unsigned char m_SubsetPrefixLength;
135 bool m_IsItalicHint;
136 bool m_IsBoldHint;
137 bool m_HasBBox;
138 PdfFontStretch m_FontStretch;
139 short m_Weight;
140
141 nullable<PdfFontDescriptorFlags> m_Flags;
142 Corners m_BBox;
143 double m_ItalicAngle;
144 double m_Ascent;
145 double m_Descent;
146 double m_Leading;
147 double m_CapHeight;
148 double m_XHeight;
149 double m_StemV;
150 double m_StemH;
151 double m_AvgWidth;
152 double m_MaxWidth;
153 double m_DefaultWidth;
154
155 const PdfObject* m_FontFileObject;
156 PdfFontType m_FontType;
157 Type3FontData* m_Type3FontData;
158 nullable<PdfFontFileType> m_FontFileType;
159
160 unsigned m_Length1;
161 unsigned m_Length2;
162 unsigned m_Length3;
163
164 double m_LineSpacing;
165 double m_UnderlineThickness;
166 double m_UnderlinePosition;
167 double m_StrikeThroughThickness;
168 double m_StrikeThroughPosition;
169};
170
171};
172
173#endif // PDF_FONT_METRICS_OBJECT_H
This file should be included as the FIRST file in every header of PoDoFo lib.
All classes, functions, types and enums of PoDoFo are members of these namespace.
Definition basetypes.h:13
PdfFontFileType
Definition PdfDeclarations.h:276
@ Create
Create a new file or truncate existing one for writing/reading.
PdfFontType
Enum specifying the type of the font.
Definition PdfDeclarations.h:266