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