10 #include "PdfEncodingMap.h"
11 #include "PdfString.h"
12 #include "PdfObject.h"
31 bool IsEndOfString()
const;
39 std::string_view::iterator m_it;
40 std::string_view::iterator m_end;
42 PdfEncodingLimits m_limits;
81 static std::unique_ptr<PdfEncoding> CreateSchim(
const PdfEncoding& encoding,
PdfFont& font);
86 static std::unique_ptr<PdfEncoding> CreateDynamicEncoding(
const std::shared_ptr<PdfCharCodeMap>& cidMap,
87 const std::shared_ptr<PdfCharCodeMap>& toUnicodeMap,
PdfFont& font);
93 std::string ConvertToUtf8(
const PdfString& encodedStr)
const;
98 bool TryConvertToUtf8(
const PdfString& encodedStr, std::string& str)
const;
103 charbuff ConvertToEncoded(
const std::string_view& str)
const;
105 bool TryConvertToEncoded(
const std::string_view& str,
charbuff& encoded)
const;
110 std::vector<PdfCID> ConvertToCIDs(
const PdfString& encodedStr)
const;
115 bool TryConvertToCIDs(
const PdfString& encodedStr, std::vector<PdfCID>& cids)
const;
122 char32_t GetCodePoint(
const PdfCharCode& codeUnit)
const;
130 char32_t GetCodePoint(
unsigned charCode)
const;
151 bool HasCIDMapping()
const;
156 bool IsSimpleEncoding()
const;
160 bool HasParsedLimits()
const;
164 bool IsDynamicEncoding()
const;
169 unsigned GetId()
const {
return m_Id; }
175 const PdfEncodingLimits& GetLimits()
const;
177 bool HasValidToUnicodeMap()
const;
197 inline const PdfEncodingMap& GetEncodingMap()
const {
return *m_Encoding; }
204 PdfEncoding& operator=(
const PdfEncoding&) =
default;
208 void ExportToFont(PdfFont& font)
const;
209 bool TryGetCIDId(
const PdfCharCode& codeUnit,
unsigned& cid)
const;
211 static unsigned GetNextId();
214 bool tryExportEncodingTo(PdfDictionary& dictionary,
bool wantCidMapping)
const;
215 bool tryConvertEncodedToUtf8(
const std::string_view& encoded, std::string& str)
const;
216 bool tryConvertEncodedToCIDs(
const std::string_view& encoded, std::vector<PdfCID>& cids)
const;
217 void writeCIDMapping(PdfObject& cmapObj,
const PdfFont& font,
const std::string_view& baseFont)
const;
218 void writeToUnicodeCMap(PdfObject& cmapObj)
const;
219 bool tryGetCharCode(PdfFont& font,
unsigned gid,
const unicodeview& codePoints, PdfCharCode& unit)
const;
223 PdfEncodingLimits m_ParsedLimits;
A memory owning immutable block of code points, optimized for small segments as up to 3 elements can ...
Definition: PdfCharCodeMap.h:29
This factory creates a PdfEncoding from an existing object in the PDF.
Definition: PdfEncodingFactory.h:20
A PdfEncodingMap is a low level interface to convert between utf8 and encoded strings in and to deter...
Definition: PdfEncodingMap.h:28
A PdfEncoding is in PdfFont to transform a text string into a representation so that it can be displa...
Definition: PdfEncoding.h:55
unsigned GetId() const
Return an Id to be used in hashed containers.
Definition: PdfEncoding.h:169
A PdfFont that represents a CID-keyed font that has a TrueType/OpenType font backend (aka "CIDFontTyp...
Definition: PdfFontCIDTrueType.h:17
A PdfFont that represents a CID-keyed font.
Definition: PdfFontCID.h:17
This is a common base class for simple, non CID-keyed fonts like Type1, TrueType and Type3.
Definition: PdfFontSimple.h:20
Before you can draw text on a PDF document, you have to create a font object first.
Definition: PdfFont.h:49
A PDF string context to iteratively scan a string and collect both CID and unicode codepoints.
Definition: PdfEncoding.h:24
A string that can be written to a PDF document.
Definition: PdfString.h:24
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
@ Create
Create a new file or truncate existing one for writing/reading.
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