7 #ifndef PDF_ENCODING_MAP_H
8 #define PDF_ENCODING_MAP_H
11 #include "PdfObject.h"
12 #include "PdfCharCodeMap.h"
16 class PdfIndirectObjectList;
43 bool TryGetNextCharCode(std::string_view::iterator& it,
44 const std::string_view::iterator& end,
PdfCharCode& codeUnit)
const;
49 bool TryGetCharCode(char32_t codePoint,
PdfCharCode& codeUnit)
const;
61 bool TryGetCharCode(
unsigned cid,
PdfCharCode& codeUnit)
const;
65 bool TryGetNextCID(std::string_view::iterator& it,
66 const std::string_view::iterator& end,
PdfCID& cid)
const;
70 bool TryGetNextCodePoints(std::string_view::iterator& it,
71 const std::string_view::iterator& end,
CodePointSpan& codePoints)
const;
79 virtual const PdfEncodingLimits& GetLimits()
const = 0;
101 virtual bool HasLigaturesSupport()
const;
119 virtual bool tryGetNextCharCode(std::string_view::iterator& it,
120 const std::string_view::iterator& end,
PdfCharCode& codeUnit)
const;
151 virtual int GetWModeRaw()
const;
153 static void AppendUTF16CodeTo(
OutputStream& stream, char32_t codePoint, std::u16string& u16tmp);
187 bool TryGetCIDId(
const PdfCharCode& codeUnit,
unsigned&
id)
const;
189 bool tryGetNextCodePoints(std::string_view::iterator& it,
const std::string_view::iterator& end,
197 PdfWModeKind GetWModeSafe()
const;
208 friend class PdfDynamicEncodingMap;
214 bool tryGetNextCharCode(std::string_view::iterator& it,
215 const std::string_view::iterator& end,
PdfCharCode& codeUnit)
const override;
219 bool tryGetCharCode(char32_t codePoint,
PdfCharCode& codeUnit)
const override;
221 bool tryGetCodePoints(
const PdfCharCode& codeUnit,
const unsigned* cidId,
CodePointSpan& codePoints)
const override;
230 inline const PdfCharCodeMap& GetCharMap()
const {
return *m_charMap; }
232 const PdfEncodingLimits& GetLimits()
const override;
238 std::shared_ptr<PdfCharCodeMap> m_charMap;
259 const PdfEncodingLimits& GetLimits()
const override;
262 PdfEncodingLimits m_Limits;
271 friend class PdfFontMetricsFreetype;
276 friend class AppleLatin1Encoding;
289 bool tryGetCharCode(char32_t codePoint,
PdfCharCode& codeUnit)
const override;
290 bool tryGetCodePoints(
const PdfCharCode& codeUnit,
const unsigned* cidId,
CodePointSpan& codePoints)
const override;
305 void CreateUnicodeToGIDMap(
const std::unordered_map<unsigned, unsigned>& codeToGidMap,
306 std::unordered_map<uint32_t, unsigned>& unicodeMap)
const;
312 void initEncodingTable();
316 std::unordered_map<char32_t, char> m_EncodingTable;
329 const PdfEncodingLimits& GetLimits()
const override;
332 bool tryGetCharCode(char32_t codePoint,
PdfCharCode& codeUnit)
const override;
334 bool tryGetCodePoints(
const PdfCharCode& codeUnit,
const unsigned* cidId,
CodePointSpan& codePoints)
const override;
SPDX-FileCopyrightText: (C) 2005 Dominik Seichter domseichter@web.de SPDX-FileCopyrightText: (C) 2020...
A memory owning immutable block of code points, optimized for small segments as up to 3 elements can ...
Definition: PdfCharCodeMap.h:29
An interface for writing blocks of data to a data source.
Definition: OutputStream.h:18
A common base class for built-in encodings which are known by name.
Definition: PdfEncodingMap.h:270
virtual const char32_t * GetToUnicodeTable() const =0
Gets a table of 256 short values which are the big endian Unicode code points that are assigned to th...
const PdfName & GetName() const
Get the name of this encoding.
Definition: PdfEncodingMap.h:286
A bidirectional map from character code units to unspecified code points.
Definition: PdfCharCodeMap.h:109
PdfDifferenceEncoding is an encoding, which is based on either the fonts encoding or a predefined enc...
Definition: PdfDifferenceEncoding.h:108
Basic PdfEncodingMap implementation using a PdfCharCodeMap.
Definition: PdfEncodingMap.h:207
This factory creates a PdfEncodingMap.
Definition: PdfEncodingMapFactory.h:18
PdfEncodingMap used by encodings like PdfBuiltInEncoding or PdfDifferenceEncoding that can define all...
Definition: PdfEncodingMap.h:247
A PdfEncodingMap is a low level interface to convert between utf8 and encoded strings in and to deter...
Definition: PdfEncodingMap.h:28
virtual bool tryGetCodePoints(const PdfCharCode &codeUnit, const unsigned *cidId, CodePointSpan &codePoints) const =0
Get code points from a code unit.
virtual void AppendToUnicodeEntries(OutputStream &stream, charbuff &temp) const =0
During a WriteToUnicodeCMap append "beginbfchar" and "beginbfrange" entries.
virtual void AppendCIDMappingEntries(OutputStream &stream, const PdfFont &font, charbuff &temp) const =0
During a PdfEncoding::ExportToFont() append "begincidchar" and/or "begincidrange" entries.
PdfEncodingMapType GetType() const
Type of encoding, may be Simple or CMap.
Definition: PdfEncodingMap.h:91
virtual bool tryGetCharCode(char32_t codePoint, PdfCharCode &codeUnit) const =0
Try get char code unit from unicode code point.
A PdfEncoding is in PdfFont to transform a text string into a representation so that it can be displa...
Definition: PdfEncoding.h:55
Before you can draw text on a PDF document, you have to create a font object first.
Definition: PdfFont.h:49
PdfIdentityEncoding is a two-byte encoding which can be used with TrueType fonts to represent all cha...
Definition: PdfIdentityEncoding.h:31
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
Dummy encoding map that will just throw exception.
Definition: PdfEncodingMap.h:322
This class represents a PDF indirect Object in memory.
Definition: PdfObject.h:35
A common base class for Pdf defined predefined encodings which are known by name.
Definition: PdfPredefinedEncoding.h:27
Represents a predefined ToUnicode CMap as the ones described in ISO 32000-2:2020 "9....
Definition: PdfPredefinedToUnicodeCMap.h:21
StandardEncoding.
Definition: PdfPredefinedEncoding.h:107
A PDF string context to iteratively scan a string and collect both CID and unicode codepoints.
Definition: PdfEncoding.h:24
Symbol Encoding.
Definition: PdfPredefinedEncoding.h:124
ZapfDingbats encoding.
Definition: PdfPredefinedEncoding.h:141
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
cspan< char32_t > unicodeview
Unicode code point view.
Definition: basetypes.h:27
std::shared_ptr< const PdfEncodingMap > PdfToUnicodeMapConstPtr
Convenience alias for a const /ToUnicode CMap entry shared ptr.
Definition: PdfEncodingMap.h:351
std::shared_ptr< const PdfBuiltInEncoding > PdfBuiltInEncodingConstPtr
Convenience typedef for a const /Encoding map entry shared ptr.
Definition: PdfEncodingMap.h:347
PdfEncodingMapType
Definition: PdfDeclarations.h:113
PdfPredefinedEncodingType
Definition: PdfDeclarations.h:120
std::shared_ptr< const PdfEncodingMap > PdfEncodingMapConstPtr
Convenience typedef for a const /Encoding map entry shared ptr.
Definition: PdfEncodingMap.h:343
Represent a CID (Character ID) with full code unit information.
Definition: PdfEncodingCommon.h:48
A character code unit.
Definition: PdfEncodingCommon.h:20