|
pdfmm 0.9.20
|
#include <PdfFont.h>
Public Member Functions | |
| void | WriteStringToStream (PdfStream &stream, const std::string_view &str) const |
| void | WriteStringToStream (std::ostream &stream, const std::string_view &str) const |
| double | GetStringWidth (const std::string_view &view, const PdfTextState &state) const |
| bool | TryGetStringWidth (const std::string_view &view, const PdfTextState &state, double &width) const |
| double | GetStringWidth (const PdfString &encodedStr, const PdfTextState &state) const |
| bool | TryGetStringWidth (const PdfString &encodedStr, const PdfTextState &state, double &width) const |
| double | GetCharWidth (char32_t codePoint, const PdfTextState &state, bool ignoreCharSpacing=false) const |
| double | GetLineSpacing (const PdfTextState &state) const |
| double | GetUnderlineThickness (const PdfTextState &state) const |
| double | GetUnderlinePosition (const PdfTextState &state) const |
| double | GetStrikeOutPosition (const PdfTextState &state) const |
| double | GetStrikeOutThickness (const PdfTextState &state) const |
| double | GetAscent (const PdfTextState &state) const |
| double | GetDescent (const PdfTextState &state) const |
| bool | IsLoaded () const |
| bool | IsSubsettingEnabled () const |
| const std::string & | GetSubsetPrefix () const |
| const PdfName & | GetIdentifier () const |
| const PdfEncoding & | GetEncoding () const |
| const PdfFontMetrics & | GetMetrics () const |
| const std::string & | GetName () const |
Static Public Member Functions | |
| static std::unique_ptr< PdfFont > | Create (PdfDocument &doc, const PdfFontMetricsConstPtr &metrics, const PdfEncoding &encoding, PdfFontInitOptions flags) |
| static std::unique_ptr< PdfFont > | CreateStandard14 (PdfDocument &doc, PdfStandard14FontType baseFont, const PdfEncoding &encoding, PdfFontInitOptions flags) |
| static bool | TryCreateFromObject (PdfObject &obj, std::unique_ptr< PdfFont > &font) |
| static std::string | ExtractBaseName (const std::string_view &fontName, bool &isBold, bool &isItalic) |
| static std::string | ExtractBaseName (const std::string_view &fontName) |
Protected Member Functions | |
| PdfFont (PdfDocument &doc, const PdfFontMetricsConstPtr &metrics, const PdfEncoding &encoding) | |
| virtual bool | TryMapCIDToGID (unsigned cid, unsigned &gid) const |
| virtual bool | TryMapGIDToCID (unsigned gid, unsigned &cid) const |
| double | GetCIDWidthRaw (unsigned cid) const |
| void | FillDescriptor (PdfDictionary &dict) const |
| virtual void | initImported () |
Before you can draw text on a PDF document, you have to create a font object first. You can reuse this font object as often as you want.
Use PdfDocument::CreateFont to create a new font object. It will choose a correct subclass using PdfFontFactory.
This is only an abstract base class which is implemented for different font formats.
|
protected |
Create a new PdfFont object which will introduce itself automatically to every page object it is used on.
| parent | parent of the font object |
| metrics | pointer to a font metrics object. The font in the PDF file will match this fontmetrics object. The metrics object is deleted along with the font. |
| encoding | the encoding of this font |
|
static |
Create a new PdfFont object.
| doc | the parent of the created font. |
| metrics | pointer to a font metrics object. The font in the PDF file will match this fontmetrics object. The metrics object is deleted along with the created font. In case of an error, it is deleted here. |
| encoding | the encoding of this font. |
| flags | flags for font init |
|
static |
Creates a new standard 14 font object (of class PdfFontStandard14) if the font name (has to include variant) is one of the standard 14 fonts. The font name is to be given as specified (with an ASCII hyphen).
| doc | the parent of the created font |
| baseFont | standard14 font type |
| encoding | an encoding compatible with the font |
| flags | flags for font init |
|
static |
Extract base font name, removing known bold/italic/subset prefixes/suffixes
|
static |
Extract base font name, removing known bold/italic/subset prefixes/suffixes
|
protected |
Fill the /FontDescriptor object dictionary
| double PdfFont::GetAscent | ( | const PdfTextState & | state | ) | const |
Get the ascent of this font in PDF units for the current font size.
| double PdfFont::GetCharWidth | ( | char32_t | codePoint, |
| const PdfTextState & | state, | ||
| bool | ignoreCharSpacing = false |
||
| ) | const |
|
protected |
Get the raw width of a CID identifier
| double PdfFont::GetDescent | ( | const PdfTextState & | state | ) | const |
Get the descent of this font in PDF units for the current font size. This value is usually negative!
|
inline |
Returns a reference to the fonts encoding
|
inline |
Returns the identifier of this font how it is known in the pages resource dictionary.
| double PdfFont::GetLineSpacing | ( | const PdfTextState & | state | ) | const |
Retrieve the line spacing for this font
|
inline |
Returns a handle to the fontmetrics object of this font. This can be used for size calculations of text strings when drawn using this font.
|
inline |
Get the base font name of this font
| double PdfFont::GetStrikeOutPosition | ( | const PdfTextState & | state | ) | const |
Return the position of the strikeout for the current font size in PDF units
| double PdfFont::GetStrikeOutThickness | ( | const PdfTextState & | state | ) | const |
Get the width of the strikeout for the current font size in PDF units
| double PdfFont::GetStringWidth | ( | const PdfString & | encodedStr, |
| const PdfTextState & | state | ||
| ) | const |
Retrieve the width of a given encoded PdfString in PDF units when drawn with the current font
| view | a text string of which the width should be calculated |
| double mm::PdfFont::GetStringWidth | ( | const std::string_view & | view, |
| const PdfTextState & | state | ||
| ) | const |
Retrieve the width of a given text string in PDF units when drawn with the current font
| view | a text string of which the width should be calculated |
|
inline |
| double PdfFont::GetUnderlinePosition | ( | const PdfTextState & | state | ) | const |
Return the position of the underline for the current font size in PDF units
| double PdfFont::GetUnderlineThickness | ( | const PdfTextState & | state | ) | const |
Get the width of the underline for the current font size in PDF units
|
protectedvirtual |
Inititialization tasks for imported/created from scratch fonts
Reimplemented in mm::PdfFontCIDTrueType, mm::PdfFontStandard14, mm::PdfFontTrueType, mm::PdfFontType1, and mm::PdfFontType3.
|
inline |
True if the font is loaded from a PdfObject
|
inline |
Check if this is a subsetting font.
Create a new PdfFont from an existing font in a PDF file.
| obj | a PDF font object |
| font | the created font object |
| bool PdfFont::TryGetStringWidth | ( | const PdfString & | encodedStr, |
| const PdfTextState & | state, | ||
| double & | width | ||
| ) | const |
| bool mm::PdfFont::TryGetStringWidth | ( | const std::string_view & | view, |
| const PdfTextState & | state, | ||
| double & | width | ||
| ) | const |
|
protectedvirtual |
Optional function to map a CID to a GID
Example for /Type2 CID fonts may have a /CIDToGIDMap For Standard14 fonts we have to convert CID to unicode then we retrieve the glyph index
Reimplemented in mm::PdfFontStandard14.
|
protectedvirtual |
Optional function to map a CID to a GID
Example for /Type2 CID fonts may have a /CIDToGIDMap For Standard14 fonts we have to convert CID to unicode then we retrieve the glyph index
Reimplemented in mm::PdfFontStandard14.
| void mm::PdfFont::WriteStringToStream | ( | PdfStream & | stream, |
| const std::string_view & | str | ||
| ) | const |
Write a string to a PdfStream in a format so that it can be used with this font. This is used by PdfPainter::DrawText to display a text string. The following PDF operator will be Tj
| stream | the string will be appended to stream without any leading or following whitespaces. |
| str | a unicode or ansi string which will be displayed |
| void mm::PdfFont::WriteStringToStream | ( | std::ostream & | stream, |
| const std::string_view & | str | ||
| ) | const |
Write a string to a PdfStream in a format so that it can be used with this font. This is used by PdfPainter::DrawText to display a text string. The following PDF operator will be Tj
| stream | the string will be appended to the stream without any leading or following whitespaces. |
| str | a unicode or ansi string which will be displayed |