12#include "PdfTextState.h"
14#include "PdfEncoding.h"
15#include "PdfElement.h"
16#include "PdfFontMetrics.h"
22struct PODOFO_API PdfFontCreateParams final
28struct PODOFO_API PdfSplittedString final
31 bool IsSeparator =
false;
44class PODOFO_API
PdfFont :
public PdfDictionaryElement
48 friend class PdfFontObject;
53 friend class PdfFontBuiltinType1Encoding;
85 static bool TryCreateFromObject(
const PdfObject&
obj, std::unique_ptr<const PdfFont>&
font);
150 double GetStringLength(
const std::string_view&
str,
const PdfTextState&
state)
const;
156 bool TryGetStringLength(
const std::string_view&
str,
const PdfTextState&
state,
double&
width)
const;
185 double GetWordSpacingLength(
const PdfTextState&
state)
const;
193 double GetHardSpacingLength(
const PdfTextState&
state)
const;
201 double GetSpaceCharLength(
const PdfTextState&
state)
const;
228 bool HasCIDSubset()
const;
233 double GetCIDWidth(
unsigned cid)
const;
238 double GetLineSpacing(
const PdfTextState&
state)
const;
244 double GetUnderlineThickness(
const PdfTextState&
state)
const;
250 double GetUnderlinePosition(
const PdfTextState&
state)
const;
256 double GetStrikeThroughPosition(
const PdfTextState&
state)
const;
262 double GetStrikeThroughThickness(
const PdfTextState&
state)
const;
271 double GetAscent(
const PdfTextState&
state)
const;
281 double GetDescent(
const PdfTextState&
state)
const;
283 virtual bool SupportsSubsetting()
const;
285 bool IsStandard14Font()
const;
287 bool IsStandard14Font(PdfStandard14FontType&
std14Font)
const;
289 static std::string_view GetStandard14FontName(PdfStandard14FontType
stdFont);
306 bool IsCIDFont()
const;
311 virtual bool IsObjectLoaded()
const;
320 inline bool IsEmbeddingEnabled()
const {
return m_EmbeddingEnabled; }
326 inline std::string_view GetSubsetPrefix()
const;
345 inline const std::string&
GetName()
const {
return m_Name; }
349 inline bool IsProxy()
const {
return m_IsProxy; }
363 bool tryMapCIDToGIDLoadedMetrics(
unsigned cid,
unsigned&
gid)
const;
367 bool tryMapCIDToGIDNormal(
unsigned cid,
unsigned&
gid)
const;
378 bool TryGetSubstituteCIDEncoding(std::unique_ptr<PdfEncodingMap>&
cidEncodingMap)
const;
380 PdfCIDSystemInfo GetCIDSystemInfo()
const;
384 std::vector<PdfCharGIDInfo> GetCharGIDInfos()
const;
386 virtual PdfObject* getDescendantFontObject();
390 virtual void initImported();
392 virtual void embedFont();
394 virtual void embedFontSubset();
430 std::unique_ptr<std::set<PdfCharCode>> GetCharCodeSubset()
const;
448 double getStringLength(
const std::vector<PdfCID>&
cids,
const PdfTextState&
state)
const;
456 void initSpacingDescriptors();
458 void initSpaceCharLength();
463 using PdfCharCodeList = std::vector<PdfCharCode>;
465 struct PODOFO_API CIDSubsetInfo
final
468 PdfCharCodeList Codes;
471 using CIDSubsetMap = std::map<unsigned, CIDSubsetInfo>;
475 std::string m_SubsetPrefix;
477 bool m_EmbeddingEnabled;
479 bool m_SubsettingEnabled;
481 std::unique_ptr<CIDSubsetMap> m_SubsetCIDMap;
482 std::unique_ptr<std::unordered_map<unsigned, unsigned>> m_subsetGIDToCIDMap;
483 const PdfCIDToGIDMap* m_fontProgCIDToGIDMap;
484 double m_WordSpacingLengthRaw;
485 double m_SpaceCharLengthRaw;
488 PdfFontMetricsConstPtr m_Metrics;
489 std::unique_ptr<PdfEncoding> m_Encoding;
490 std::shared_ptr<PdfCharCodeMap> m_DynamicCIDMap;
491 std::shared_ptr<PdfCharCodeMap> m_DynamicToUnicodeMap;
SPDX-FileCopyrightText: (C) 2005 Dominik Seichter domseichter@web.de SPDX-FileCopyrightText: (C) 2020...
An interface for writing blocks of data to a data source.
Definition OutputStream.h:18
This class represents a PdfArray Use it for all arrays that are written to a PDF file.
Definition PdfArray.h:81
The PDF dictionary data type of PoDoFo (inherits from PdfDataContainer, the base class for such repre...
Definition PdfDictionary.h:82
PdfDocument is the core interface for working with PDF documents.
Definition PdfDocument.h:111
Basic PdfEncodingMap implementation using a PdfCharCodeMap.
Definition PdfEncodingMap.h:215
PdfEncodingMap used by legacy encodings like PdfBuiltInEncoding or PdfDifferenceEncoding that can def...
Definition PdfEncodingMap.h:254
A PdfEncoding is in PdfFont to transform a text string into a representation so that it can be displa...
Definition PdfEncoding.h:58
A PdfFont that represents a CID-keyed font.
Definition PdfFontCID.h:17
This class assists PdfDocument with caching font information.
Definition PdfFontManager.h:54
This abstract class provides access to font metrics information.
Definition PdfFontMetrics.h:36
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:45
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:345
const PdfFontMetrics & GetMetrics() const
Returns a handle to the fontmetrics object of this font.
Definition PdfFont.h:338
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:331
bool IsSubsettingEnabled() const
Check if this is a subsetting font.
Definition PdfFont.h:318
bool IsProxy() const
True if the font is substitute for embedding.
Definition PdfFont.h:349
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:24
This class represents a PDF indirect Object in memory.
Definition PdfObject.h:35
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
PdfGlyphAccess
When accessing a glyph, there may be a difference in the glyph ID to retrieve the widths or to index ...
Definition PdfDeclarations.h:323
@ 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:19
PdfFontCreateFlags
Font init flags.
Definition PdfDeclarations.h:340
std::shared_ptr< const PdfFontMetrics > PdfFontMetricsConstPtr
Convenience typedef for a const PdfEncoding shared ptr.
Definition PdfFontMetrics.h:27
PdfFontType
Enum specifying the type of the font.
Definition PdfDeclarations.h:286
Represent a CID (Character ID) with full code unit information.
Definition PdfEncodingCommon.h:49
A character code unit.
Definition PdfEncodingCommon.h:20
Represents a GID (Glyph ID) with PDF metrics identifier.
Definition PdfEncodingCommon.h:71