PoDoFo 0.9.20
|
#include <PdfFont.h>
Public Member Functions | |
bool | TryGetSubstituteFont (PdfFont *&substFont) const |
void | WriteStringToStream (OutputStream &stream, const std::string_view &str) const |
unsigned | GetGID (char32_t codePoint, PdfGlyphAccess access) const |
double | GetStringLength (const std::string_view &str, const PdfTextState &state) const |
bool | TryGetStringLength (const std::string_view &str, const PdfTextState &state, double &width) const |
double | GetEncodedStringLength (const PdfString &encodedStr, const PdfTextState &state) const |
bool | TryGetEncodedStringLength (const PdfString &encodedStr, const PdfTextState &state, double &length) const |
bool | TryScanEncodedString (const PdfString &encodedStr, const PdfTextState &state, std::string &utf8str, std::vector< double > &lengths, std::vector< unsigned > &positions) const |
double | GetWordSpacingLength (const PdfTextState &state) const |
double | GetCharLength (char32_t codePoint, const PdfTextState &state, bool ignoreCharSpacing=false) const |
void | AddSubsetGIDs (const PdfString &encodedStr) |
double | GetLineSpacing (const PdfTextState &state) const |
double | GetUnderlineThickness (const PdfTextState &state) const |
double | GetUnderlinePosition (const PdfTextState &state) const |
double | GetStrikeThroughPosition (const PdfTextState &state) const |
double | GetStrikeThroughThickness (const PdfTextState &state) const |
double | GetAscent (const PdfTextState &state) const |
double | GetDescent (const PdfTextState &state) const |
bool | IsCIDKeyed () const |
virtual bool | IsObjectLoaded () 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 bool | TryCreateFromObject (PdfObject &obj, std::unique_ptr< PdfFont > &font) |
static bool | IsStandard14Font (const std::string_view &fontName, PdfStandard14FontType &stdFont) |
static bool | IsStandard14Font (const std::string_view &fontName, bool useAltNames, PdfStandard14FontType &stdFont) |
Protected Member Functions | |
PdfFont (PdfDocument &doc, const PdfFontMetricsConstPtr &metrics, const PdfEncoding &encoding) | |
double | GetCIDLengthRaw (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 |
void PdfFont::AddSubsetGIDs | ( | const PdfString & | encodedStr | ) |
Split the given string by white spaces
If the subsetting is not enabled it's a no-op
|
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::GetCharLength | ( | 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!
double PdfFont::GetEncodedStringLength | ( | 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 |
|
inline |
Returns a reference to the fonts encoding
unsigned PdfFont::GetGID | ( | char32_t | codePoint, |
PdfGlyphAccess | access | ||
) | const |
Get the GID by the codePoint
codePoint | unicode codepoint |
|
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::GetStrikeThroughPosition | ( | const PdfTextState & | state | ) | const |
Return the position of the strikethrough for the current font size in PDF units
double PdfFont::GetStrikeThroughThickness | ( | const PdfTextState & | state | ) | const |
Get the width of the strikethrough for the current font size in PDF units
double PdfFont::GetStringLength | ( | const std::string_view & | str, |
const PdfTextState & | state | ||
) | const |
Retrieve the width of a given text string in PDF units when drawn with the current font
str | a utf8 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
double PdfFont::GetWordSpacingLength | ( | const PdfTextState & | state | ) | const |
|
protectedvirtual |
Inititialization tasks for imported/created from scratch fonts
Reimplemented in PoDoFo::PdfFontCID, and PoDoFo::PdfFontSimple.
bool PdfFont::IsCIDKeyed | ( | ) | const |
True if the font is CID keyed
|
virtual |
True if the font is loaded from a PdfObject
|
static |
Determine if font name is a Standard14 font
fontName | the unprocessed font name |
|
static |
Determine if font name is a Standard14 font
By default use both standard names and alternative ones (Arial, TimesNewRoman, CourierNew)
fontName | the unprocessed font name |
|
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::TryGetEncodedStringLength | ( | const PdfString & | encodedStr, |
const PdfTextState & | state, | ||
double & | length | ||
) | const |
bool PdfFont::TryGetStringLength | ( | const std::string_view & | str, |
const PdfTextState & | state, | ||
double & | width | ||
) | const |
str | a utf8 string of which the width should be calculated |
bool PdfFont::TryGetSubstituteFont | ( | PdfFont *& | substFont | ) | const |
Try get a replacement font based on this font characteristics
substFont | the created substitute font |
bool PdfFont::TryScanEncodedString | ( | const PdfString & | encodedStr, |
const PdfTextState & | state, | ||
std::string & | utf8str, | ||
std::vector< double > & | lengths, | ||
std::vector< unsigned > & | positions | ||
) | const |
Scan string decoding unicode codepoints and obtaining glyphs lengths
lengths | lengths of the glyphs |
positions | position of the CIDs in the utf8string |
void PdfFont::WriteStringToStream | ( | OutputStream & | stream, |
const std::string_view & | str | ||
) | const |
Write a string to a PdfObjectStream 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 |