7 #ifndef PDF_DIFFERENCE_ENCODING_H
8 #define PDF_DIFFERENCE_ENCODING_H
10 #include "PdfEncodingMap.h"
24 unsigned char Code = 0;
26 char32_t MappedCodePoint = U
'\0';
29 using List = std::vector<Difference>;
30 using iterator = std::vector<Difference>::iterator;
31 using const_iterator = std::vector<Difference>::const_iterator;
49 void AddDifference(
unsigned char code, char32_t codePoint);
57 void AddDifference(
unsigned char code,
const PdfName& name,
bool explicitNames =
false);
66 bool TryGetMappedName(
unsigned char code,
const PdfName*& name)
const;
67 bool TryGetMappedName(
unsigned char code,
const PdfName*& name, char32_t& codePoint)
const;
81 size_t GetCount()
const;
83 const_iterator begin()
const {
return m_differences.begin(); }
85 const_iterator end()
const {
return m_differences.end(); }
88 void addDifference(
unsigned char code, char32_t codePoint,
const PdfName& name);
89 bool contains(
unsigned char code,
const PdfName*& name, char32_t& codePoint);
91 struct DifferenceComparatorPredicate
94 inline bool operator()(
const Difference& diff1,
const Difference& diff2)
const
96 return diff1.Code < diff2.Code;
126 std::unique_ptr<PdfDifferenceEncoding>& encoding);
135 static std::unique_ptr<PdfDifferenceEncoding> CreateFromObject(
const PdfObject& obj,
const PdfFontMetrics& metrics);
142 static char32_t NameToCodePoint(
const std::string_view& name);
149 static PdfName CodePointToName(char32_t codePoint);
161 bool tryGetCharCode(char32_t codePoint,
PdfCharCode& codeUnit)
const override;
162 bool tryGetCodePoints(
const PdfCharCode& codeUnit,
const unsigned* cidId,
CodePointSpan& codePoints)
const override;
165 void buildReverseMap();
170 bool m_reverseMapBuilt;
171 std::unordered_map<char32_t, unsigned char> m_reverseMap;
A memory owning immutable block of code points, optimized for small segments as up to 3 elements can ...
Definition: PdfCharCodeMap.h:29
This class represents a PdfArray Use it for all arrays that are written to a PDF file.
Definition: PdfArray.h:81
PdfDifferenceEncoding is an encoding, which is based on either the fonts encoding or a predefined enc...
Definition: PdfDifferenceEncoding.h:108
const PdfDifferenceList & GetDifferences() const
Get read-only access to the object containing the actual differences.
Definition: PdfDifferenceEncoding.h:157
A helper class for PdfDifferenceEncoding that can be used to create a differences array.
Definition: PdfDifferenceEncoding.h:21
PdfEncodingMap used by encodings like PdfBuiltInEncoding or PdfDifferenceEncoding that can define all...
Definition: PdfEncodingMap.h:247
This abstract class provides access to font metrics information.
Definition: PdfFontMetrics.h:33
A list of PdfObjects that constitutes the indirect object list of the document The PdfParser will rea...
Definition: PdfIndirectObjectList.h:30
This class represents a PdfName.
Definition: PdfName.h:24
This class represents a PDF indirect Object in memory.
Definition: PdfObject.h:35
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition: basetypes.h:16
@ Name
Name datatype. Names are used as keys in dictionary to reference values.
std::shared_ptr< const PdfEncodingMap > PdfEncodingMapConstPtr
Convenience typedef for a const /Encoding map entry shared ptr.
Definition: PdfEncodingMap.h:343
A character code unit.
Definition: PdfEncodingCommon.h:20