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;
42class PODOFO_API
PdfFont :
public PdfDictionaryElement
46 friend class PdfFontObject;
51 friend class PdfFontBuiltinType1Encoding;
83 static bool TryCreateFromObject(
const PdfObject&
obj, std::unique_ptr<const PdfFont>&
font);
148 double GetStringLength(
const std::string_view&
str,
const PdfTextState&
state)
const;
154 bool TryGetStringLength(
const std::string_view&
str,
const PdfTextState&
state,
double&
width)
const;
183 double GetWordSpacingLength(
const PdfTextState&
state)
const;
191 double GetHardSpacingLength(
const PdfTextState&
state)
const;
199 double GetSpaceCharLength(
const PdfTextState&
state)
const;
226 bool HasCIDSubset()
const;
231 double GetCIDWidth(
unsigned cid)
const;
236 double GetLineSpacing(
const PdfTextState&
state)
const;
242 double GetUnderlineThickness(
const PdfTextState&
state)
const;
248 double GetUnderlinePosition(
const PdfTextState&
state)
const;
254 double GetStrikeThroughPosition(
const PdfTextState&
state)
const;
260 double GetStrikeThroughThickness(
const PdfTextState&
state)
const;
269 double GetAscent(
const PdfTextState&
state)
const;
279 double GetDescent(
const PdfTextState&
state)
const;
281 virtual bool SupportsSubsetting()
const;
283 bool IsStandard14Font()
const;
285 bool IsStandard14Font(PdfStandard14FontType&
std14Font)
const;
287 static std::string_view GetStandard14FontName(PdfStandard14FontType
stdFont);
304 bool IsCIDFont()
const;
309 virtual bool IsObjectLoaded()
const;
318 inline bool IsEmbeddingEnabled()
const {
return m_EmbeddingEnabled; }
324 inline std::string_view GetSubsetPrefix()
const;
343 inline const std::string&
GetName()
const {
return m_Name; }
347 inline bool IsProxy()
const {
return m_IsProxy; }
361 bool tryMapCIDToGIDLoadedMetrics(
unsigned cid,
unsigned&
gid)
const;
365 bool tryMapCIDToGIDNormal(
unsigned cid,
unsigned&
gid)
const;
376 bool TryGetSubstituteCIDEncoding(std::unique_ptr<PdfEncodingMap>&
cidEncodingMap)
const;
378 PdfCIDSystemInfo GetCIDSystemInfo()
const;
382 std::vector<PdfCharGIDInfo> GetCharGIDInfos()
const;
384 virtual PdfObject* getDescendantFontObject();
388 virtual void initImported();
390 virtual void embedFont();
392 virtual void embedFontSubset();
428 std::unique_ptr<std::set<PdfCharCode>> GetCharCodeSubset()
const;
446 double getStringLength(
const std::vector<PdfCID>&
cids,
const PdfTextState&
state)
const;
454 void initSpacingDescriptors();
456 void initSpaceCharLength();
461 using PdfCharCodeList = std::vector<PdfCharCode>;
463 struct PODOFO_API CIDSubsetInfo
final
466 PdfCharCodeList Codes;
469 using CIDSubsetMap = std::map<unsigned, CIDSubsetInfo>;
473 std::string m_SubsetPrefix;
475 bool m_EmbeddingEnabled;
477 bool m_SubsettingEnabled;
479 std::unique_ptr<CIDSubsetMap> m_SubsetCIDMap;
480 std::unique_ptr<std::unordered_map<unsigned, unsigned>> m_subsetGIDToCIDMap;
481 const PdfCIDToGIDMap* m_fontProgCIDToGIDMap;
482 double m_WordSpacingLengthRaw;
483 double m_SpaceCharLengthRaw;
486 PdfFontMetricsConstPtr m_Metrics;
487 std::unique_ptr<PdfEncoding> m_Encoding;
488 PdfCharCodeMap* m_DynamicCIDMap;
489 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:16
This class represents a PdfArray Use it for all arrays that are written to a PDF file.
Definition PdfArray.h:79
The PDF dictionary data type of PoDoFo (inherits from PdfDataContainer, the base class for such repre...
Definition PdfDictionary.h:80
PdfDocument is the core interface for working with PDF documents.
Definition PdfDocument.h:109
Basic PdfEncodingMap implementation using a PdfCharCodeMap.
Definition PdfEncodingMap.h:213
PdfEncodingMap used by legacy encodings like PdfBuiltInEncoding or PdfDifferenceEncoding that can def...
Definition PdfEncodingMap.h:252
A PdfEncoding is in PdfFont to transform a text string into a representation so that it can be displa...
Definition PdfEncoding.h:55
A PdfFont that represents a CID-keyed font.
Definition PdfFontCID.h:15
This class assists PdfDocument with caching font information.
Definition PdfFontManager.h:52
This abstract class provides access to font metrics information.
Definition PdfFontMetrics.h:34
This is a common base class for simple, non CID-keyed fonts like Type1, TrueType and Type3.
Definition PdfFontSimple.h:18
Before you can draw text on a PDF document, you have to create a font object first.
Definition PdfFont.h:43
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:343
const PdfFontMetrics & GetMetrics() const
Returns a handle to the fontmetrics object of this font.
Definition PdfFont.h:336
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:329
bool IsSubsettingEnabled() const
Check if this is a subsetting font.
Definition PdfFont.h:316
bool IsProxy() const
True if the font is substitute for embedding.
Definition PdfFont.h:347
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:22
This class represents a PDF indirect Object in memory.
Definition PdfObject.h:33
A string that can be written to a PDF document.
Definition PdfString.h:22
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition basetypes.h:35
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:24
PdfGlyphAccess
When accessing a glyph, there may be a difference in the glyph ID to retrieve the widths or to index ...
Definition PdfDeclarations.h:321
@ 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:16
PdfFontCreateFlags
Font init flags.
Definition PdfDeclarations.h:338
std::shared_ptr< const PdfFontMetrics > PdfFontMetricsConstPtr
Convenience typedef for a const PdfEncoding shared ptr.
Definition PdfFontMetrics.h:25
PdfFontType
Enum specifying the type of the font.
Definition PdfDeclarations.h:284
Represent a CID (Character ID) with full code unit information.
Definition PdfEncodingCommon.h:46
A character code unit.
Definition PdfEncodingCommon.h:17
Represents a GID (Glyph ID) with PDF metrics identifier.
Definition PdfEncodingCommon.h:68