Font Class Documentation
class FontNamespace:datalogics_interface
Detailed Description
Represents a font. Defines the typeface, size, style (bold, italic), Unicode values, and other details.
The Font class represents a font installed on the system.
Referenced by
Constructor & Destructor Documentation
Font
Font(const std::string & font_name)Parameters
font_name: const std::string &
Default constructor.
Direct construction is prohibited.
Font
Font(const std::string & font_name, FontCreateFlags flags)Parameters
font_name: const std::string &flags: FontCreateFlags
Default constructor.
Direct construction is prohibited.
Font
Font(const std::string & font_name, FontCreateFlags flags, WritingMode mode)Parameters
font_name: const std::string &flags: FontCreateFlagsmode: WritingMode
Default constructor.
Direct construction is prohibited.
Font
Font(Font && )Parameters
: Font &&
~Font
~Font()Member Function Documentation
embed_now
void embed_now(Document & doc)Parameters
doc: Document &the Document the Font is embedded into
Returns:
voidEmbeds the Font.
find_index_of_first_unrepresentable_char
unsigned int find_index_of_first_unrepresentable_char(const std::string & text)Parameters
text: const std::string &the text to check
Returns:
unsigned intThe index of the first character that cannot be represented in this font.
Find the index of the first character that cannot be represented in this font. This will return the index of the first character in the string for which the font has no glyph. If all characters can be represented (i.e. if IsTextRepresentable() would return true), this will return the length of the string.
get_ascent
double get_ascent()Returns:
doubleThe Ascent value of the font in glyph space units.
the Ascent value from the font descriptor. This is the maximum height above the baseline reached by glyphs in this font, excluding the height of glyphs for accented characters.
get_avg_width
double get_avg_width()Returns:
doubleThe AvgWidth value of the font in glyph space units, or 0 if not defined.
the AvgWidth value from the font descriptor. This is the average width of glyphs in the font, or 0 if the value is not defined in the font descriptor.
get_bbox
Rect get_bbox()Returns:
RectThe bounding box of the font as a Rect, in glyph space units.
The Bounding Box rectangle of the font.
get_cap_height
double get_cap_height()Returns:
doubleThe CapHeight value of the font in glyph space units, or 0 if not defined.
the CapHeight value from the font descriptor. This is the vertical coordinate of the top of flat capital letters, measured from the baseline, or 0 if the value is not defined in the font descriptor.
get_cid_font_type
std::string get_cid_font_type()Returns:
std::stringThe CID font type, or an empty string if not a CID font.
Get the CID font type of the font.
get_descent
double get_descent()Returns:
doubleThe descent value of the font.
the Descent value from the font descriptor. This is the maximum depth below the baseline reached by glyphs in this font. The value is a negative number.
get_embedded
bool get_embedded()Returns:
booltrue if the font is embedded, false if it is not.
Tests whether the font is embedded in the document it was created for.
get_encoding
std::string get_encoding()Returns:
std::stringThe encoding of the font, eg: WinAnsiEncoding MacRomanEncoding
Return the encoding of the font.
For a font created from a system font by name, this is the encoding PDFL gives the font when it is written to a document: WinAnsiEncoding on Windows and Linux, MacRomanEncoding on macOS, or Identity-H/V for a Type0 font. Symbolic fonts (Symbol, ZapfDingbats, Wingdings) use their own built-in encoding and return an empty string.
get_encoding_info
std::unique_ptr< EncodingInfo > get_encoding_info()Returns:
std::unique_ptr< EncodingInfo >The EncodingInfo object containing encoding details for this font.
Get the populated CEncodingInfo object.
get_flags
FontFlags get_flags()Returns:
FontFlagsThe font descriptor flags as a CFontFlags bitmask.
Get the font flags for a font.
get_font_list
static std::vector< Font > get_font_list()Returns:
std::vector< Font >The list of available fonts.
Get a list of available fonts.
get_full_name
std::string get_full_name()Returns:
std::stringThe Full Name of the font. Note: This method only returns a meaningful result for TrueType-based technology fonts.
Get the Full Name of the font.
get_glyph_widths
std::vector< double > get_glyph_widths()Returns:
std::vector< double >256 glyph advances in 1000-em character-space units.
Retrieve the glyph width table for the font's single-byte encoding.
Retrieve the 256-entry glyph width table for this font's single-byte encoding. Values are in character-space units (1000 per em); for the user-space width of character code c at font size s use widths[c] * s / 1000.0. Only meaningful for simple single-byte fonts; CID/Type-0 fonts should use measure_text_width.
Returns the 256-entry glyph advance table in character-space units (1000 units per em). For the user-space width of character code c at font size s: widths[c] * s / 1000.0.
The returned vector always has 256 entries; positions outside the font's defined encoding are filled with whatever advance the font reports for unmapped codes (typically zero or the missing-glyph advance). This API is therefore only meaningful for simple single-byte fonts — Type 1, TrueType with a simple encoding, etc. CID / Type 0 fonts need per-glyph measurement via MeasureTextWidth instead.
get_italic_angle
double get_italic_angle()Returns:
doubleThe ItalicAngle value of the font in degrees.
the ItalicAngle value from the font descriptor. This is the angle, expressed in degrees counterclockwise from the vertical, of the dominant vertical strokes of the font, defined in the font descriptor.
get_leading
double get_leading()Returns:
doubleThe leading value of the font, or 0 if not present.
the Leading value from the font descriptor. This is the spacing between baselines of consecutive lines of text, or 0 if the value is not defined in the font descriptor.
get_max_width
double get_max_width()Returns:
doubleThe MaxWidth value of the font in glyph space units, or 0 if not present.
the MaxWidth value from the font descriptor. This is the maximum glyph width present in the font, or 0 if the value is not defined in the font descriptor.
get_missing_width
double get_missing_width()Returns:
doubleThe MissingWidth value of the font in glyph space units, or 0 if not present.
the MissingWidth value from the font descriptor. This is the width given to characters that do not have corresponding glyphs defined in the font, or 0 if the value is not defined in the font descriptor.
get_name
std::string get_name()Returns:
std::stringThe name of the font.
Get the name of the font.
get_pdf_dict
PDFDict get_pdf_dict()Returns:
PDFDictThe PDFDict for this font's COS dictionary object.
Retrieve the PDFDict representation of this font.
get_stem_h
double get_stem_h()Returns:
doubleThe StemH value of the font in glyph space units, or 0 if not present.
the StemH value from the font descriptor. This is the vertical thickness of the dominant horizontal stems of the font's glyphs, or 0 if the value is not defined in the font descriptor.
get_stem_v
double get_stem_v()Returns:
doubleThe StemV value of the font in glyph space units, or 0 if not present.
the StemV value from the font descriptor. This is the horizontal thickness of the dominant vertical stems of the font's glyphs, or 0 if the value is not defined in the font descriptor.
get_type
std::string get_type()Returns:
std::stringThe type of the font. Type0 Type1 MMType1 TrueType
Get the type of the font.
get_writing_mode
WritingMode get_writing_mode()Returns:
WritingModeThe WritingMode of the font.
Get the writing mode of the font. The writing mode of the fontwhether it will place glyphs horizontally or vertically. Text written with this font will run in the direction of the writing mode.
get_x_height
double get_x_height()Returns:
doubleThe XHeight value of the font in glyph space units, or 0 if not present.
the XHeight value from the font descriptor. This is the vertical coordinate of the top of flat nonascending lowercase letters in fonts that have Latin characters, as measured from the baseline, or 0 if the value is not defined in the font descriptor.
is_from_doc
bool is_from_doc()Returns:
booltrue if the font was loaded from a document, false if it was created from a system font.
Determine whether this font was obtained from an existing document rather than the system.
is_text_representable
bool is_text_representable(const std::string & text)Parameters
text: const std::string &the text to check
Returns:
booltrue if all characters in the text have corresponding glyphs in this font.
Is this text representable in this font?
measure_text_width
double measure_text_width(const std::string & text, double font_size)Parameters
text: const std::string &the Text to be measured
font_size: doublethe Font size to be used
Returns:
doubleThe width of the text in points.
Measures the width of the specified text in points, using the Font at the specified size.
operator=
Parameters
: Font &&