PoDoFo 1.2.0
Loading...
Searching...
No Matches
PdfFontMetricsStandard14.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_STANDARD14_H
6#define PDF_FONT_METRICS_STANDARD14_H
7
8#include "PdfDeclarations.h"
9
10#include "PdfFontMetrics.h"
11#include <podofo/auxiliary/Rect.h>
12
13namespace PoDoFo {
14
15struct Standard14FontData;
16
18class PODOFO_API PdfFontMetricsStandard14 final : public PdfFontMetricsBase
19{
20 friend class PdfFont;
21private:
22 PdfFontMetricsStandard14(PdfStandard14FontType fontType,
23 const Standard14FontData& data,
24 GlyphMetricsListConstPtr parsedWidths = { });
25
26public:
29 static std::unique_ptr<const PdfFontMetricsStandard14> Create(
30 PdfStandard14FontType fontType);
31 static std::unique_ptr<const PdfFontMetricsStandard14> Create(
32 PdfStandard14FontType fontType, const PdfObject& fontObj);
33
34private:
35 static std::unique_ptr<const PdfFontMetricsStandard14> Create(
36 PdfStandard14FontType fontType, GlyphMetricsListConstPtr&& parsedWidths);
37
38public:
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 GetFontFamilyName() const override;
72
73 PdfFontStretch GetFontStretch() const override;
74
75 int GetWeightRaw() const override;
76
77 double GetLeadingRaw() 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 bool IsStandard14FontMetrics(PdfStandard14FontType& std14Font) const override;
90
91 unsigned GetFontFileLength1() const override;
92
93 unsigned GetFontFileLength2() const override;
94
95 unsigned GetFontFileLength3() const override;
96
97 inline const Standard14FontData& GetRawData() const { return m_data; }
98
99protected:
100 std::string_view GetBaseFontName() const override;
101
102 unsigned GetGlyphCountFontProgram() const override;
103
104 bool TryGetGlyphWidthFontProgram(unsigned gid, double& width) const override;
105
106 PdfFontType GetFontType() const override;
107
108 bool getIsItalicHint() const override;
109
110 bool getIsBoldHint() const override;
111
112 datahandle getFontFileDataHandle() const override;
113
114private:
115 static std::unique_ptr<PdfFontMetricsStandard14> create(
116 PdfStandard14FontType fontType, const PdfObject* fontObj = nullptr);
117
118public:
119 static std::shared_ptr<const PdfFontMetricsStandard14> GetInstance(PdfStandard14FontType std14Font);
120
121private:
122 PdfStandard14FontType m_Std14FontType;
123 const Standard14FontData& m_data;
124
125 double m_LineSpacing;
126 double m_UnderlineThickness;
127 double m_StrikeThroughThickness;
128};
129
130}
131
132#endif // PDF_FONT_METRICS_STANDARD14_H
This file should be included as the FIRST file in every header of PoDoFo lib.
An unoriented rectangle defined by 2 points.
Definition Corners.h:16
This is the main class to handle the Standard14 metric data.
Definition PdfFontMetricsStandard14.h:19
Before you can draw text on a PDF document, you have to create a font object first.
Definition PdfFont.h:42
This class represents a PDF indirect Object in memory.
Definition PdfObject.h:31
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition basetypes.h:30
A const data provider that can hold a view to a static segments or a shared buffer.
Definition basetypes.h:135
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
PdfFontDescriptorFlags
Enum for the font descriptor flags.
Definition PdfDeclarations.h:233