PoDoFo 1.0.0-dev
Loading...
Searching...
No Matches
PdfEncodingCommon.h
1
7#ifndef PDF_ENCODING_COMMON_H
8#define PDF_ENCODING_COMMON_H
9
10#include "PdfString.h"
11
12namespace PoDoFo
13{
19 struct PODOFO_API PdfCharCode final
20 {
21 unsigned Code;
22
23 // RangeSize example <cd> -> 1, <00cd> -> 2
24 unsigned char CodeSpaceSize;
25
27
30 explicit PdfCharCode(unsigned code);
31
32 PdfCharCode(unsigned code, unsigned char codeSpaceSize);
33
34 bool operator<(const PdfCharCode& rhs) const;
35
36 bool operator==(const PdfCharCode& rhs) const;
37
38 bool operator!=(const PdfCharCode& rhs) const;
39
40 public:
41 unsigned GetByteCode(unsigned char byteIdx) const;
42 void AppendTo(std::string& str) const;
43 void WriteHexTo(std::string& str, bool wrap = true) const;
44 };
45
46 // TODO: Optimize me
47 using PdfCharCodeList = std::vector<PdfCharCode>;
48
51 struct PODOFO_API PdfCID final
52 {
53 unsigned Id;
54 PdfCharCode Unit;
55
56 PdfCID();
57
61 explicit PdfCID(unsigned id);
62
63 PdfCID(unsigned id, const PdfCharCode& unit);
64
68 PdfCID(const PdfCharCode& unit);
69 };
70
73 struct PODOFO_API PdfGID final
74 {
75 unsigned Id = 0;
76 unsigned MetricsId = 0;
77
78 PdfGID();
79
80 PdfGID(unsigned id);
81
82 PdfGID(unsigned id, unsigned metricsId);
83 };
84
87 struct PODOFO_API PdfCharGIDInfo
88 {
89 unsigned Cid = 0;
91 };
92
93 struct PODOFO_API PdfEncodingLimits final
94 {
95 public:
96 PdfEncodingLimits(unsigned char minCodeSize, unsigned char maxCodeSize,
98
101 PdfEncodingLimits();
102
106 bool AreValid() const;
107
111 bool HaveValidCodeSizeRange() const;
112
113 PdfCharCode FirstChar; // The first defined character code
114 PdfCharCode LastChar; // The last defined character code
115 unsigned char MinCodeSize;
116 unsigned char MaxCodeSize;
117 };
118
119 struct PODOFO_API PdfCIDSystemInfo final
120 {
121 PdfString Registry;
122 PdfString Ordering;
123 int Supplement = 0;
124 };
125}
126
127namespace std
128{
131 template<>
132 struct hash<PoDoFo::PdfCharCode>
133 {
134 size_t operator()(const PoDoFo::PdfCharCode& code) const noexcept
135 {
136 return code.CodeSpaceSize << 24 | code.Code;
137 }
138 };
139}
140
141#endif // PDF_ENCODING_COMMON_H
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition basetypes.h:38
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition basetypes.h:16
Represent a CID (Character ID) with full code unit information.
Definition PdfEncodingCommon.h:52
A character code unit.
Definition PdfEncodingCommon.h:20
Represents a bundle of a CID and GID information.
Definition PdfEncodingCommon.h:88
PdfGID Gid
The identifier of the glyph in font program and PDF metrics.
Definition PdfEncodingCommon.h:90
Represents a GID (Glyph ID) with PDF metrics identifier.
Definition PdfEncodingCommon.h:74