PoDoFo 1.0.0-dev
Loading...
Searching...
No Matches
PdfFontMetricsFreetype.h
1
7#ifndef PDF_FONT_METRICS_FREETYPE_H
8#define PDF_FONT_METRICS_FREETYPE_H
9
10#include "PdfDeclarations.h"
11
12#include "PdfFontMetrics.h"
13#include "PdfString.h"
14
15namespace PoDoFo {
16
17struct PdfEncodingLimits;
18
19class PODOFO_API PdfFontMetricsFreetype final : public PdfFontMetrics
20{
21 friend class PdfFontMetrics;
22
23public:
24 ~PdfFontMetricsFreetype();
25
26 std::unique_ptr<PdfCMapEncoding> CreateToUnicodeMap(const PdfEncodingLimits& limitHints) const override;
27
28 bool HasUnicodeMapping() const override;
29
30 bool TryGetGID(char32_t codePoint, unsigned& gid) const override;
31
32 double GetDefaultWidthRaw() const override;
33
34 double GetLineSpacing() const override;
35
36 double GetUnderlineThickness() const override;
37
38 double GetUnderlinePosition() const override;
39
40 double GetStrikeThroughPosition() const override;
41
42 double GetStrikeThroughThickness() const override;
43
44 std::string_view GetFontName() const override;
45
46 std::string_view GetFontFamilyName() const override;
47
48 unsigned char GetSubsetPrefixLength() const override;
49
50 PdfFontStretch GetFontStretch() const override;
51
52 bool TryGetFlags(PdfFontDescriptorFlags& value) const override;
53
54 bool TryGetBoundingBox(Corners& value) const override;
55
56 bool TryGetItalicAngle(double& value) const override;
57
58 bool TryGetAscent(double& value) const override;
59
60 bool TryGetDescent(double& value) const override;
61
62 bool TryGetCapHeight(double& value) const override;
63
64 bool TryGetStemV(double& value) const override;
65
66 double GetLeadingRaw() const override;
67
68 int GetWeightRaw() const override;
69
70 double GetXHeightRaw() const override;
71
72 double GetStemHRaw() const override;
73
74 double GetAvgWidthRaw() const override;
75
76 double GetMaxWidthRaw() const override;
77
78 PdfFontFileType GetFontFileType() const override;
79
80 unsigned GetFontFileLength1() const override;
81
82 unsigned GetFontFileLength2() const override;
83
84 unsigned GetFontFileLength3() const override;
85
86 const datahandle& GetFontFileDataHandle() const override;
87
88 FT_Face GetFaceHandle() const override;
89
90protected:
91 std::string_view GetBaseFontName() const override;
92
93 unsigned GetGlyphCountFontProgram() const override;
94
95 bool TryGetGlyphWidthFontProgram(unsigned gid, double& width) const override;
96
97 bool getIsBoldHint() const override;
98
99 bool getIsItalicHint() const override;
100
101private:
102 PdfFontMetricsFreetype(FT_Face face, const datahandle& data, const PdfFontMetrics* refMetrics = nullptr);
103
104 void init(const PdfFontMetrics* refMetrics);
105
106 void ensureLengthsReady();
107
108 void initType1Lengths(const bufferview& view);
109
110 bool tryBuildFallbackUnicodeMap();
111
112private:
113 FT_Face m_Face;
114 datahandle m_Data;
115 PdfFontFileType m_FontFileType;
116
117 unsigned char m_SubsetPrefixLength;
118 bool m_HasUnicodeMapping;
119 std::unique_ptr<std::unordered_map<uint32_t, unsigned>> m_fallbackUnicodeMap;
120
121 std::string m_FontBaseName;
122 std::string m_FontName;
123 std::string m_FontFamilyName;
124
125 // Conditionally required metrics
127 Corners m_BBox;
128 double m_ItalicAngle;
129 double m_Ascent;
130 double m_Descent;
131 double m_CapHeight;
132 double m_StemV;
133
134 // Optional metrics
135 PdfFontStretch m_FontStretch;
136 int m_Weight;
137 double m_Leading;
138 double m_XHeight;
139 double m_StemH;
140 double m_AvgWidth;
141 double m_MaxWidth;
142 double m_DefaultWidth;
143
144 // Computed metrics
145 double m_LineSpacing;
146 double m_UnderlineThickness;
147 double m_UnderlinePosition;
148 double m_StrikeThroughThickness;
149 double m_StrikeThroughPosition;
150
151 bool m_LengthsReady;
152 unsigned m_Length1;
153 unsigned m_Length2;
154 unsigned m_Length3;
155};
156
157};
158
159#endif // PDF_FONT_METRICS_FREETYPE_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
PdfFontDescriptorFlags
Enum for the font descriptor flags.
Definition PdfDeclarations.h:252