PoDoFo  1.0.0-dev
PdfFontMetricsStandard14.h
1 
7 #ifndef PDF_FONT_METRICS_STANDARD14_H
8 #define PDF_FONT_METRICS_STANDARD14_H
9 
10 #include "PdfDeclarations.h"
11 
12 #include "PdfFontMetrics.h"
13 #include <podofo/auxiliary/Rect.h>
14 
15 namespace PoDoFo {
16 
17 struct Standard14FontData;
18 
22 class PODOFO_API PdfFontMetricsStandard14 final : public PdfFontMetricsBase
23 {
24 private:
25  PdfFontMetricsStandard14(PdfStandard14FontType fontType,
26  const Standard14FontData& data,
27  std::unique_ptr<std::vector<double>> parsedWidths = { });
28 
29 public:
33  static std::unique_ptr<const PdfFontMetricsStandard14> Create(
34  PdfStandard14FontType fontType);
35  static std::unique_ptr<const PdfFontMetricsStandard14> Create(
36  PdfStandard14FontType fontType, const PdfObject& fontObj);
37 
38 public:
39  unsigned GetGlyphCount() const override;
40 
41  bool TryGetGlyphWidth(unsigned gid, double& width) const override;
42 
43  bool HasUnicodeMapping() const override;
44 
45  bool TryGetGID(char32_t codePoint, unsigned& gid) const override;
46 
47  double GetDefaultWidthRaw() const override;
48 
49  double GetLineSpacing() const override;
50 
51  double GetUnderlineThickness() const override;
52 
53  double GetUnderlinePosition() const override;
54 
55  double GetStrikeThroughPosition() const override;
56 
57  double GetStrikeThroughThickness() const override;
58 
59  std::string_view GetFontName() const override;
60 
61  std::string_view GetFontFamilyName() const override;
62 
63  PdfFontStretch GetFontStretch() const override;
64 
65  int GetWeightRaw() const override;
66 
67  PdfFontDescriptorFlags GetFlags() const override;
68 
69  void GetBoundingBox(std::vector<double>& bbox) const override;
70 
71  double GetItalicAngle() const override;
72 
73  double GetAscent() const override;
74 
75  double GetDescent() const override;
76 
77  double GetLeadingRaw() const override;
78 
79  double GetCapHeight() const override;
80 
81  double GetXHeightRaw() const override;
82 
83  double GetStemV() 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  bool IsStandard14FontMetrics(PdfStandard14FontType& std14Font) const override;
94 
95  unsigned GetFontFileLength1() const override;
96 
97  unsigned GetFontFileLength2() const override;
98 
99  unsigned GetFontFileLength3() const override;
100 
101  inline const Standard14FontData& GetRawData() const { return m_data; }
102 
103 protected:
104  std::string_view GetBaseFontName() const override;
105 
106  bool getIsItalicHint() const override;
107 
108  bool getIsBoldHint() const override;
109 
110  datahandle getFontFileDataHandle() const override;
111 
112 private:
113  static std::unique_ptr<PdfFontMetricsStandard14> create(
114  PdfStandard14FontType fontType, const PdfObject* fontObj = nullptr);
115 
116 public:
117  static std::shared_ptr<const PdfFontMetricsStandard14> GetInstance(PdfStandard14FontType std14Font);
118 
119 private:
120  PdfStandard14FontType m_Std14FontType;
121  const Standard14FontData& m_data;
122  // /Widths parsed from a font object, if available
123  std::unique_ptr<std::vector<double>> m_parsedWidths;
124 
125  double m_Ascent;
126  double m_Descent;
127 
128  double m_LineSpacing;
129  double m_UnderlineThickness;
130  double m_UnderlinePosition;
131  double m_StrikeThroughThickness;
132  double m_StrikeThroughPosition;
133 };
134 
135 }
136 
137 #endif // PDF_FONT_METRICS_STANDARD14_H
SPDX-FileCopyrightText: (C) 2005 Dominik Seichter domseichter@web.de SPDX-FileCopyrightText: (C) 2020...
This is the main class to handle the Standard14 metric data.
Definition: PdfFontMetricsStandard14.h:23
This class represents a PDF indirect Object in memory.
Definition: PdfObject.h:35
A const data provider that can hold a view to a static segments or a shared buffer.
Definition: basetypes.h:144
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition: basetypes.h:16
PdfFontFileType
Definition: PdfDeclarations.h:267
@ Create
Create a new file or truncate existing one for writing/reading.
PdfFontDescriptorFlags
Enum for the font descriptor flags.
Definition: PdfDeclarations.h:223