pdfmm 0.9.20
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
mm::PdfFontMetrics Class Referenceabstract

#include <PdfFontMetrics.h>

Inheritance diagram for mm::PdfFontMetrics:
mm::PdfFontMetricsStandard14

Public Member Functions

double GetGlyphWidth (unsigned gid) const
 
virtual void SubstituteGIDs (std::vector< unsigned > &gids, std::vector< unsigned char > &backwardMap) const
 
unsigned GetGID (char32_t codePoint) const
 
virtual void GetBoundingBox (std::vector< double > &bbox) const =0
 
virtual double GetLineSpacing () const =0
 
virtual double GetUnderlineThickness () const =0
 
virtual double GetUnderlinePosition () const =0
 
virtual double GetStrikeOutPosition () const =0
 
virtual double GetStrikeOutThickness () const =0
 
virtual double GetAscent () const =0
 
virtual double GetDescent () const =0
 
virtual std::string_view GetFontData () const
 
virtual const PdfObjectGetFontDataObject () const
 
std::string GetFontNameSafe (bool baseFirst=false) const
 
virtual std::string GetBaseFontName () const
 
virtual std::string GetFontName () const
 
virtual unsigned GetWeight () const =0
 
virtual double GetCapHeight () const =0
 
virtual double GetXHeight () const =0
 
virtual double GetStemV () const =0
 
virtual double GetItalicAngle () const =0
 
virtual bool IsBold () const =0
 
virtual bool IsItalic () const =0
 
virtual bool FontNameHasBoldItalicInfo () const
 
PdfFontMetricsType GetType () const
 
virtual bool IsSymbol () const =0
 

Static Public Member Functions

static PdfFontMetricsType GetFontMetricsTypeFromFilename (const std::string_view &filename)
 

Protected Member Functions

void SetType (PdfFontMetricsType eFontType)
 

Detailed Description

This abstract class provides access to font metrics information.

The class doesn't know anything about CIDs (Character IDs), it just index glyphs, or GIDs where the terminology applies

Member Function Documentation

◆ FontNameHasBoldItalicInfo()

bool PdfFontMetrics::FontNameHasBoldItalicInfo ( ) const
virtual

State whether font name reports if the font is bold or italic, such has in "Helvetica-Bold"

Reimplemented in mm::PdfFontMetricsStandard14.

◆ GetAscent()

virtual double mm::PdfFontMetrics::GetAscent ( ) const
pure virtual

Get the ascent of this font in PDF units for the current font size.

Returns
the ascender for this font
See also
GetAscent

Implemented in mm::PdfFontMetricsStandard14.

◆ GetBaseFontName()

string PdfFontMetrics::GetBaseFontName ( ) const
virtual

Get a base name for the font that can be used to compose the final name, eg. "Arial"

Return empty string by default

Reimplemented in mm::PdfFontMetricsStandard14.

◆ GetBoundingBox()

virtual void mm::PdfFontMetrics::GetBoundingBox ( std::vector< double > &  bbox) const
pure virtual

Create the bounding box vector in PDF units

Parameters
bboxwrite the bounding box to this vector

Implemented in mm::PdfFontMetricsStandard14.

◆ GetCapHeight()

virtual double mm::PdfFontMetrics::GetCapHeight ( ) const
pure virtual

The vertical coordinate of the top of flat capital letters, measured from the baseline

Implemented in mm::PdfFontMetricsStandard14.

◆ GetDescent()

virtual double mm::PdfFontMetrics::GetDescent ( ) const
pure virtual

Get the descent of this font in PDF units for the current font size. This value is usually negative!

Returns
the descender for this font
See also
GetDescent

Implemented in mm::PdfFontMetricsStandard14.

◆ GetFontData()

string_view PdfFontMetrics::GetFontData ( ) const
virtual

Get the actual font data for a file loaded font, if available

For font data coming from the /FontFile keys, use GetFontDataObject()

Returns
a binary buffer of data containing the font data

Reimplemented in mm::PdfFontMetricsStandard14.

◆ GetFontDataObject()

const PdfObject * PdfFontMetrics::GetFontDataObject ( ) const
virtual

Get the actual font data object from a /FontFile like key, if available

For font data coming from a file loaded font, see GetFontData()

Returns
a binary buffer of data containing the font data

◆ GetFontMetricsTypeFromFilename()

PdfFontMetricsType PdfFontMetrics::GetFontMetricsTypeFromFilename ( const std::string_view &  filename)
static

Try to detect the internal fonttype from the file extension of a fontfile.

Parameters
filenamemust be the filename of a font file
Returns
font type

◆ GetFontName()

string PdfFontMetrics::GetFontName ( ) const
virtual

Get the actual /FontName, eg. "AAAAAA+Arial,Bold", if available

By default return empty string

Returns
the postscript name of the font or empty string if no postscript name is available.

◆ GetFontNameSafe()

string PdfFontMetrics::GetFontNameSafe ( bool  baseFirst = false) const

Get a string with either the actual /FontName or a base font name inferred from a font file

◆ GetGID()

unsigned PdfFontMetrics::GetGID ( char32_t  codePoint) const

Get the GID by the codePoint

Parameters
codePointunicode codepoint
Returns
the GID
Remarks
throw if not found

◆ GetGlyphWidth()

double PdfFontMetrics::GetGlyphWidth ( unsigned  gid) const

Get the width of a single glyph id

Parameters
gidid of the glyph
Returns
the width of a single glyph id

◆ GetItalicAngle()

virtual double mm::PdfFontMetrics::GetItalicAngle ( ) const
pure virtual

Get the italic angle of this font. Used to build the font dictionay

Returns
the italic angle of this font.

Implemented in mm::PdfFontMetricsStandard14.

◆ GetLineSpacing()

virtual double mm::PdfFontMetrics::GetLineSpacing ( ) const
pure virtual

Retrieve the line spacing for this font

Returns
the linespacing in PDF units

Implemented in mm::PdfFontMetricsStandard14.

◆ GetStemV()

virtual double mm::PdfFontMetrics::GetStemV ( ) const
pure virtual

The thickness, measured horizontally, of the dominant vertical stems of glyphs in the font

Implemented in mm::PdfFontMetricsStandard14.

◆ GetStrikeOutPosition()

virtual double mm::PdfFontMetrics::GetStrikeOutPosition ( ) const
pure virtual

Return the position of the strikeout for the current font size in PDF units

Returns
the underline position in PDF units

Implemented in mm::PdfFontMetricsStandard14.

◆ GetStrikeOutThickness()

virtual double mm::PdfFontMetrics::GetStrikeOutThickness ( ) const
pure virtual

Get the width of the strikeout for the current font size in PDF units

Returns
the thickness of the strikeout in PDF units

Implemented in mm::PdfFontMetricsStandard14.

◆ GetType()

PdfFontMetricsType mm::PdfFontMetrics::GetType ( ) const
inline
Returns
the fonttype of the loaded font

◆ GetUnderlinePosition()

virtual double mm::PdfFontMetrics::GetUnderlinePosition ( ) const
pure virtual

Return the position of the underline for the current font size in PDF units

Returns
the underline position in PDF units

Implemented in mm::PdfFontMetricsStandard14.

◆ GetUnderlineThickness()

virtual double mm::PdfFontMetrics::GetUnderlineThickness ( ) const
pure virtual

Get the width of the underline for the current font size in PDF units

Returns
the thickness of the underline in PDF units

Implemented in mm::PdfFontMetricsStandard14.

◆ GetWeight()

virtual unsigned mm::PdfFontMetrics::GetWeight ( ) const
pure virtual

Get the weight of this font. Used to build the font dictionay

Returns
the weight of this font (500 is normal).

Implemented in mm::PdfFontMetricsStandard14.

◆ GetXHeight()

virtual double mm::PdfFontMetrics::GetXHeight ( ) const
pure virtual

The font’s x height: the vertical coordinate of the top of flat nonascending lowercase letters (like the letter x), measured from the baseline, in fonts that have Latin characters

Implemented in mm::PdfFontMetricsStandard14.

◆ IsBold()

virtual bool mm::PdfFontMetrics::IsBold ( ) const
pure virtual

Get whether the font style is bold

Implemented in mm::PdfFontMetricsStandard14.

◆ IsItalic()

virtual bool mm::PdfFontMetrics::IsItalic ( ) const
pure virtual

Get whether the font style is italic

Implemented in mm::PdfFontMetricsStandard14.

◆ IsSymbol()

virtual bool mm::PdfFontMetrics::IsSymbol ( ) const
pure virtual

Symbol fonts do need special treatment in a few cases. Use this method to check if the current font is a symbol font. Symbold fonts are detected by checking if they use FT_ENCODING_MS_SYMBOL as internal encoding.

Returns
true if this is a symbol font

Implemented in mm::PdfFontMetricsStandard14.

◆ SetType()

void mm::PdfFontMetrics::SetType ( PdfFontMetricsType  eFontType)
inlineprotected

Set the fonttype.

Parameters
eFontTypefonttype

◆ SubstituteGIDs()

void PdfFontMetrics::SubstituteGIDs ( std::vector< unsigned > &  gids,
std::vector< unsigned char > &  backwardMap 
) const
virtual

Some fonts provides a glyph subsitution list, eg. for ligatures. OpenType fonts for example provides GSUB "Glyph Substitution Table"

Parameters
gidsgids to be substituded
backwardMaplist of gid counts to remap back substituded gids eg. { 32, 102, 105 } gets substituted in { 32, 174 } the backward map is { 1, 2 }