PoDoFo  1.0.0-dev
Public Member Functions | Friends | List of all members
PoDoFo::PdfEncoding Class Referencefinal

A PdfEncoding is in PdfFont to transform a text string into a representation so that it can be displayed in a PDF file. More...

#include <PdfEncoding.h>

Public Member Functions

 PdfEncoding ()
 Null encoding, when used as an actual encoding a dynamic encoding will be constructed instead.
 
 PdfEncoding (const PdfEncodingMapConstPtr &encoding, const PdfToUnicodeMapConstPtr &toUnicode=nullptr)
 
 PdfEncoding (const PdfEncoding &)=default
 
std::string ConvertToUtf8 (const PdfString &encodedStr) const
 
bool TryConvertToUtf8 (const PdfString &encodedStr, std::string &str) const
 
charbuff ConvertToEncoded (const std::string_view &str) const
 
bool TryConvertToEncoded (const std::string_view &str, charbuff &encoded) const
 
std::vector< PdfCIDConvertToCIDs (const PdfString &encodedStr) const
 
bool TryConvertToCIDs (const PdfString &encodedStr, std::vector< PdfCID > &cids) const
 
char32_t GetCodePoint (const PdfCharCode &codeUnit) const
 Get code point from char code unit. More...
 
char32_t GetCodePoint (unsigned charCode) const
 Get code point from char code. More...
 
PdfStringScanContext StartStringScan (const PdfString &encodedStr)
 
const PdfCharCodeGetFirstChar () const
 This return the first char code used in the encoding. More...
 
const PdfCharCodeGetLastChar () const
 This return the last char code used in the encoding. More...
 
bool IsNull () const
 Return true if the encoding is a dummy null encoding.
 
bool HasCIDMapping () const
 Return true if the encoding does CID mapping.
 
bool IsSimpleEncoding () const
 Return true if the encoding is simple and has a non-CID mapping /Encoding entry.
 
bool HasParsedLimits () const
 Returns true if /FirstChar and /LastChar were parsed from object.
 
bool IsDynamicEncoding () const
 Return true if the encoding is a dynamic CID mapping.
 
unsigned GetId () const
 Return an Id to be used in hashed containers.
 
const PdfEncodingLimits & GetLimits () const
 Get actual limits of the encoding. More...
 
bool HasValidToUnicodeMap () const
 
const PdfEncodingMapGetToUnicodeMap () const
 Get the ToUnicode map, throws if missing.
 
bool GetToUnicodeMapSafe (const PdfEncodingMap *&toUnicode) const
 Get the ToUnicode map, fallback to the normal encoding if missing. More...
 
const PdfEncodingMapGetToUnicodeMapSafe () const
 Get the ToUnicode map, fallback to the normal encoding if missing. More...
 
const PdfEncodingMapGetEncodingMap () const
 
const PdfEncodingMapConstPtr GetEncodingMapPtr () const
 
const PdfEncodingMapConstPtr GetToUnicodeMapPtr () const
 
PdfEncodingoperator= (const PdfEncoding &)=default
 

Friends

class PdfEncodingFactory
 
class PdfFont
 
class PdfFontCID
 
class PdfFontCIDTrueType
 
class PdfFontSimple
 

Detailed Description

A PdfEncoding is in PdfFont to transform a text string into a representation so that it can be displayed in a PDF file.

PdfEncoding can also be used to convert strings from a PDF file back into a PdfString.

Member Function Documentation

◆ ConvertToCIDs()

vector< PdfCID > PdfEncoding::ConvertToCIDs ( const PdfString encodedStr) const
Remarks
Doesn't throw if conversion failed, totally or partially

◆ ConvertToEncoded()

charbuff PdfEncoding::ConvertToEncoded ( const std::string_view &  str) const
Remarks
It throws if conversion failed, totally or partially

◆ ConvertToUtf8()

string PdfEncoding::ConvertToUtf8 ( const PdfString encodedStr) const
Remarks
Doesn't throw if conversion failed, totally or partially

◆ GetCodePoint() [1/2]

char32_t PdfEncoding::GetCodePoint ( const PdfCharCode codeUnit) const

Get code point from char code unit.

Returns
the found code point or U'\0' if missing or multiple matched codepoints

◆ GetCodePoint() [2/2]

char32_t PdfEncoding::GetCodePoint ( unsigned  charCode) const

Get code point from char code.

Returns
the found code point or U'\0' if missing or multiple matched codepoints
Remarks
it will iterate available code sizes

◆ GetFirstChar()

const PdfCharCode & PdfEncoding::GetFirstChar ( ) const

This return the first char code used in the encoding.

Remarks
Mostly useful for non cid-keyed fonts to export /FirstChar

◆ GetLastChar()

const PdfCharCode & PdfEncoding::GetLastChar ( ) const

This return the last char code used in the encoding.

Remarks
Mostly useful for non cid-keyed fonts to export /LastChar

◆ GetLimits()

const PdfEncodingLimits & PdfEncoding::GetLimits ( ) const

Get actual limits of the encoding.

May be the limits inferred from /Encoding or the limits inferred by /FirstChar, /LastChar

◆ GetToUnicodeMapSafe() [1/2]

const PdfEncodingMap & PdfEncoding::GetToUnicodeMapSafe ( ) const

Get the ToUnicode map, fallback to the normal encoding if missing.

Returns
the retrieved map
Remarks
As a general rule, we always use this method when converting encoded -> Unicode

◆ GetToUnicodeMapSafe() [2/2]

bool PdfEncoding::GetToUnicodeMapSafe ( const PdfEncodingMap *&  toUnicode) const

Get the ToUnicode map, fallback to the normal encoding if missing.

Parameters
toUnicodethe retrieved map
Returns
true if the retrieved map is valid, false otherwise

◆ TryConvertToCIDs()

bool PdfEncoding::TryConvertToCIDs ( const PdfString encodedStr,
std::vector< PdfCID > &  cids 
) const
Remarks
Produces a partial result also in case of failure

◆ TryConvertToUtf8()

bool PdfEncoding::TryConvertToUtf8 ( const PdfString encodedStr,
std::string &  str 
) const
Remarks
Produces a partial result also in case of failure

The documentation for this class was generated from the following files: