10#include "PdfTextState.h"
12#include "PdfEncoding.h"
13#include "PdfElement.h"
14#include "PdfFontMetrics.h"
20struct PODOFO_API PdfFontCreateParams final
26struct PODOFO_API PdfSplittedString final
29 bool IsSeparator =
false;
41class PODOFO_API
PdfFont :
public PdfDictionaryElement
45 friend class PdfFontObject;
50 friend class PdfFontBuiltinType1Encoding;
79 static bool TryCreateFromObject(
const PdfObject&
obj, std::unique_ptr<const PdfFont>&
font);
137 double GetStringLength(
const std::string_view&
str,
const PdfTextState&
state)
const;
143 bool TryGetStringLength(
const std::string_view&
str,
const PdfTextState&
state,
double&
width)
const;
170 double GetWordSpacingLength(
const PdfTextState&
state)
const;
176 double GetHardSpacingLength(
const PdfTextState&
state)
const;
182 double GetSpaceCharLength(
const PdfTextState&
state)
const;
220 bool HasCIDSubset()
const;
223 double GetCIDWidth(
unsigned cid)
const;
227 double GetLineSpacing(
const PdfTextState&
state)
const;
232 double GetUnderlineThickness(
const PdfTextState&
state)
const;
237 double GetUnderlinePosition(
const PdfTextState&
state)
const;
242 double GetStrikeThroughPosition(
const PdfTextState&
state)
const;
247 double GetStrikeThroughThickness(
const PdfTextState&
state)
const;
255 double GetAscent(
const PdfTextState&
state)
const;
264 double GetDescent(
const PdfTextState&
state)
const;
266 virtual bool SupportsSubsetting()
const;
268 bool IsStandard14Font()
const;
270 bool IsStandard14Font(PdfStandard14FontType&
std14Font)
const;
272 static std::string_view GetStandard14FontName(PdfStandard14FontType
stdFont);
286 bool IsCIDFont()
const;
289 virtual bool IsObjectLoaded()
const;
297 inline bool IsEmbeddingEnabled()
const {
return m_EmbeddingEnabled; }
301 inline std::string_view GetSubsetPrefix()
const;
317 inline const std::string&
GetName()
const {
return m_Name; }
320 inline bool IsProxy()
const {
return m_IsProxy; }
333 bool tryMapCIDToGIDLoadedMetrics(
unsigned cid,
unsigned&
gid)
const;
336 bool tryMapCIDToGIDNormal(
unsigned cid,
unsigned&
gid)
const;
345 bool TryGetSubstituteCIDEncoding(std::unique_ptr<PdfEncodingMap>&
cidEncodingMap)
const;
347 PdfCIDSystemInfo GetCIDSystemInfo()
const;
350 std::vector<PdfCharGIDInfo> GetCharGIDInfos()
const;
352 virtual PdfObject* getDescendantFontObject();
355 virtual void initImported();
357 virtual void embedFont();
359 virtual void embedFontSubset();
389 std::unique_ptr<std::set<PdfCharCode>> GetCharCodeSubset()
const;
405 double getStringLength(
const std::vector<PdfCID>&
cids,
const PdfTextState&
state)
const;
413 void initSpacingDescriptors();
415 void initSpaceCharLength();
420 using PdfCharCodeList = std::vector<PdfCharCode>;
422 struct PODOFO_API CIDSubsetInfo
final
425 PdfCharCodeList Codes;
428 using CIDSubsetMap = std::map<unsigned, CIDSubsetInfo>;
432 std::string m_SubsetPrefix;
434 bool m_EmbeddingEnabled;
436 bool m_SubsettingEnabled;
438 std::unique_ptr<CIDSubsetMap> m_SubsetCIDMap;
439 std::unique_ptr<std::unordered_map<unsigned, unsigned>> m_subsetGIDToCIDMap;
440 const PdfCIDToGIDMap* m_fontProgCIDToGIDMap;
441 double m_WordSpacingLengthRaw;
442 double m_SpaceCharLengthRaw;
445 PdfFontMetricsConstPtr m_Metrics;
446 std::unique_ptr<PdfEncoding> m_Encoding;
447 PdfCharCodeMap* m_DynamicCIDMap;
448 PdfCharCodeMap* m_DynamicToUnicodeMap;
This file should be included as the FIRST file in every header of PoDoFo lib.
An interface for writing blocks of data to a data source.
Definition OutputStream.h:15
This class represents a PdfArray Use it for all arrays that are written to a PDF file.
Definition PdfArray.h:76
The PDF dictionary data type of PoDoFo (inherits from PdfDataContainer, the base class for such repre...
Definition PdfDictionary.h:77
PdfDocument is the core interface for working with PDF documents.
Definition PdfDocument.h:108
Basic PdfEncodingMap implementation using a PdfCharCodeMap.
Definition PdfEncodingMap.h:180
PdfEncodingMap used by legacy encodings like PdfBuiltInEncoding or PdfDifferenceEncoding that can def...
Definition PdfEncodingMap.h:217
A PdfEncoding is in PdfFont to transform a text string into a representation so that it can be displa...
Definition PdfEncoding.h:51
A PdfFont that represents a CID-keyed font.
Definition PdfFontCID.h:14
This class assists PdfDocument with caching font information.
Definition PdfFontManager.h:50
This abstract class provides access to font metrics information.
Definition PdfFontMetrics.h:31
This is a common base class for simple, non CID-keyed fonts like Type1, TrueType and Type3.
Definition PdfFontSimple.h:17
Before you can draw text on a PDF document, you have to create a font object first.
Definition PdfFont.h:42
static bool IsStandard14Font(const std::string_view &fontName, bool useAltNames, PdfStandard14FontType &stdFont)
Determine if font name is a Standard14 font.
const std::string & GetName() const
Get the base font name of this font.
Definition PdfFont.h:317
const PdfFontMetrics & GetMetrics() const
Returns a handle to the fontmetrics object of this font.
Definition PdfFont.h:311
static bool TryCreateFromObject(PdfObject &obj, std::unique_ptr< PdfFont > &font)
Create a new PdfFont from an existing font in a PDF file.
const PdfEncoding & GetEncoding() const
Returns a reference to the fonts encoding.
Definition PdfFont.h:305
bool IsSubsettingEnabled() const
Check if this is a subsetting font.
Definition PdfFont.h:295
bool IsProxy() const
True if the font is substitute for embedding.
Definition PdfFont.h:320
static bool IsStandard14Font(const std::string_view &fontName, PdfStandard14FontType &stdFont)
Determine if font name is a Standard14 font.
This class represents a PdfName.
Definition PdfName.h:21
This class represents a PDF indirect Object in memory.
Definition PdfObject.h:31
A string that can be written to a PDF document.
Definition PdfString.h:21
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition basetypes.h:30
All classes, functions, types and enums of PoDoFo are members of these namespace.
Definition basetypes.h:13
cspan< char32_t > unicodeview
Unicode code point view.
Definition basetypes.h:21
PdfGlyphAccess
When accessing a glyph, there may be a difference in the glyph ID to retrieve the widths or to index ...
Definition PdfDeclarations.h:301
@ String
String datatype in PDF file. Strings have the form (Hallo World!) in PDF files.
@ Create
Create a new file or truncate existing one for writing/reading.
cspan< char > bufferview
Convenient read-only char buffer span.
Definition basetypes.h:15
PdfFontCreateFlags
Font init flags.
Definition PdfDeclarations.h:316
std::shared_ptr< const PdfFontMetrics > PdfFontMetricsConstPtr
Convenience typedef for a const PdfEncoding shared ptr.
Definition PdfFontMetrics.h:24
PdfFontType
Enum specifying the type of the font.
Definition PdfDeclarations.h:266
Represent a CID (Character ID) with full code unit information.
Definition PdfEncodingCommon.h:43
A character code unit.
Definition PdfEncodingCommon.h:16
Represents a GID (Glyph ID) with PDF metrics identifier.
Definition PdfEncodingCommon.h:60