Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
FontInstance Class Reference

FontInstance provides metrics, OpenType data, and glyph curves/pixbufs for a font. More...

#include <font-instance.h>

Classes

struct  CtorException
 Exception thrown if construction fails. More...
 
struct  Data
 

Public Member Functions

 FontInstance (PangoFont *p_font, PangoFontDescription *descr)
 Constructor; takes ownership of both arguments, which must be non-null. Throws CtorException on failure.
 
 ~FontInstance ()
 
unsigned int MapUnicodeChar (gunichar c) const
 
FontGlyph const * LoadGlyph (unsigned int glyph_id)
 
Geom::PathVector const * PathVector (unsigned int glyph_id)
 
Geom::Rect BBoxExact (unsigned int glyph_id)
 
Geom::Rect BBoxPick (unsigned int glyph_id)
 
Geom::Rect BBoxDraw (unsigned int glyph_id)
 
bool FontHasSVG () const
 
auto const & get_opentype_varaxes () const
 
std::map< Glib::ustring, OTSubstitution > const & get_opentype_tables ()
 
Inkscape::Pixbuf const * PixBuf (unsigned int glyph_id)
 
double Advance (unsigned int glyph_id, bool vertical)
 
std::shared_ptr< void const > share_data () const
 
double GetTypoAscent () const
 
double GetTypoDescent () const
 
double GetXHeight () const
 
double GetMaxAscent () const
 
double GetMaxDescent () const
 
const double * GetBaselines () const
 
int GetDesignUnits () const
 
Glib::ustring GetFilename () const
 Attempt to get the ttf filename for this font instance.
 
bool FontMetrics (double &ascent, double &descent, double &leading) const
 
bool FontDecoration (double &underline_position, double &underline_thickness, double &linethrough_position, double &linethrough_thickness) const
 
bool FontSlope (double &run, double &rise) const
 
bool IsOutlineFont () const
 
bool has_vertical () const
 
auto get_descr () const
 
auto get_font () const
 
bool is_fixed_width () const
 
bool is_oblique () const
 
unsigned short family_class () const
 

Private Member Functions

void acquire (PangoFont *p_font, PangoFontDescription *descr)
 
void release ()
 
void init_face ()
 
void find_font_metrics ()
 

Private Attributes

PangoFontDescriptiondescr
 
PangoFontp_font
 
hb_font_t * hb_font
 
hb_font_t * hb_font_copy
 
hb_face_t * hb_face
 
FT_Face face
 
bool has_svg = false
 
double _ascent
 
double _descent
 
double _xheight
 
double _ascent_max
 
double _descent_max
 
int _design_units
 
double _italic_angle = 0.0
 
bool _fixed_width = false
 
bool _oblique = false
 
unsigned short _family_class = 0
 
double _baselines [SP_CSS_BASELINE_SIZE]
 
std::unordered_set< std::string > openTypeTableList
 
std::shared_ptr< Datadata
 

Detailed Description

FontInstance provides metrics, OpenType data, and glyph curves/pixbufs for a font.

Most data is loaded upon construction. Some rarely-used OpenType tables are lazy-loaded, as are the curves/pixbufs for each glyph.

Although FontInstance can be used on its own, in practice it is always obtained through a FontFactory.

Note: The font size is a scale factor in the transform matrix of the style.

Definition at line 42 of file font-instance.h.

Constructor & Destructor Documentation

◆ FontInstance()

◆ ~FontInstance()

FontInstance::~FontInstance ( )

Definition at line 136 of file font-instance.cpp.

References release().

Member Function Documentation

◆ acquire()

void FontInstance::acquire ( PangoFont p_font,
PangoFontDescription descr 
)
private

Definition at line 146 of file font-instance.cpp.

References descr, face, hb_face, hb_font, hb_font_copy, p_font, and release().

Referenced by FontInstance().

◆ Advance()

double FontInstance::Advance ( unsigned int  glyph_id,
bool  vertical 
)

Definition at line 722 of file font-instance.cpp.

References LoadGlyph().

◆ BBoxDraw()

Geom::Rect FontInstance::BBoxDraw ( unsigned int  glyph_id)

Definition at line 585 of file font-instance.cpp.

References LoadGlyph().

◆ BBoxExact()

Geom::Rect FontInstance::BBoxExact ( unsigned int  glyph_id)

Definition at line 565 of file font-instance.cpp.

References LoadGlyph().

◆ BBoxPick()

Geom::Rect FontInstance::BBoxPick ( unsigned int  glyph_id)

Definition at line 575 of file font-instance.cpp.

References LoadGlyph().

◆ family_class()

unsigned short FontInstance::family_class ( ) const
inline

Definition at line 117 of file font-instance.h.

References _family_class.

◆ find_font_metrics()

◆ FontDecoration()

bool FontInstance::FontDecoration ( double &  underline_position,
double &  underline_thickness,
double &  linethrough_position,
double &  linethrough_thickness 
) const

Definition at line 533 of file font-instance.cpp.

References face.

◆ FontHasSVG()

bool FontInstance::FontHasSVG ( ) const
inline

Definition at line 75 of file font-instance.h.

References has_svg.

◆ FontMetrics()

bool FontInstance::FontMetrics ( double &  ascent,
double &  descent,
double &  leading 
) const

Definition at line 524 of file font-instance.cpp.

References _ascent, _descent, and _xheight.

◆ FontSlope()

bool FontInstance::FontSlope ( double &  run,
double &  rise 
) const

Definition at line 546 of file font-instance.cpp.

References face.

◆ get_descr()

auto FontInstance::get_descr ( ) const
inline

Definition at line 112 of file font-instance.h.

References descr.

Referenced by FontFactory::ConstructFontSpecification().

◆ get_font()

auto FontInstance::get_font ( ) const
inline

Definition at line 113 of file font-instance.h.

References p_font.

◆ get_opentype_tables()

std::map< Glib::ustring, OTSubstitution > const & FontInstance::get_opentype_tables ( )

Definition at line 732 of file font-instance.cpp.

References data, hb_font, p_font, and readOpenTypeGsubTable().

◆ get_opentype_varaxes()

auto const & FontInstance::get_opentype_varaxes ( ) const
inline

Definition at line 77 of file font-instance.h.

References data.

◆ GetBaselines()

const double * FontInstance::GetBaselines ( ) const
inline

Definition at line 97 of file font-instance.h.

References _baselines.

◆ GetDesignUnits()

int FontInstance::GetDesignUnits ( ) const
inline

Definition at line 98 of file font-instance.h.

References _design_units.

◆ GetFilename()

Glib::ustring FontInstance::GetFilename ( ) const

Attempt to get the ttf filename for this font instance.

If this is a memory font, then blank will be returned.

Definition at line 504 of file font-instance.cpp.

References p_font.

◆ GetMaxAscent()

double FontInstance::GetMaxAscent ( ) const
inline

Definition at line 95 of file font-instance.h.

References _ascent_max.

Referenced by Inkscape::Text::Layout::FontMetrics::set().

◆ GetMaxDescent()

double FontInstance::GetMaxDescent ( ) const
inline

Definition at line 96 of file font-instance.h.

References _descent_max.

Referenced by Inkscape::Text::Layout::FontMetrics::set().

◆ GetTypoAscent()

double FontInstance::GetTypoAscent ( ) const
inline

Definition at line 92 of file font-instance.h.

References _ascent.

Referenced by Inkscape::Text::Layout::FontMetrics::set().

◆ GetTypoDescent()

double FontInstance::GetTypoDescent ( ) const
inline

Definition at line 93 of file font-instance.h.

References _descent.

Referenced by Inkscape::Text::Layout::FontMetrics::set().

◆ GetXHeight()

double FontInstance::GetXHeight ( ) const
inline

Definition at line 94 of file font-instance.h.

References _xheight.

Referenced by Inkscape::Text::Layout::FontMetrics::set().

◆ has_vertical()

bool FontInstance::has_vertical ( ) const
inline

Definition at line 110 of file font-instance.h.

References face.

◆ init_face()

void FontInstance::init_face ( )
private

◆ is_fixed_width()

bool FontInstance::is_fixed_width ( ) const
inline

Definition at line 115 of file font-instance.h.

References _fixed_width.

◆ is_oblique()

bool FontInstance::is_oblique ( ) const
inline

Definition at line 116 of file font-instance.h.

References _oblique.

◆ IsOutlineFont()

bool FontInstance::IsOutlineFont ( ) const
inline

Definition at line 109 of file font-instance.h.

References face.

◆ LoadGlyph()

◆ MapUnicodeChar()

unsigned int FontInstance::MapUnicodeChar ( gunichar  c) const

Definition at line 386 of file font-instance.cpp.

References c, and face.

◆ PathVector()

Geom::PathVector const * FontInstance::PathVector ( unsigned int  glyph_id)

Definition at line 595 of file font-instance.cpp.

References LoadGlyph().

◆ PixBuf()

Inkscape::Pixbuf const * FontInstance::PixBuf ( unsigned int  glyph_id)

◆ release()

void FontInstance::release ( )
private

Definition at line 173 of file font-instance.cpp.

References descr, face, hb_font_copy, and p_font.

Referenced by acquire(), and ~FontInstance().

◆ share_data()

std::shared_ptr< void const > FontInstance::share_data ( ) const
inline

Definition at line 90 of file font-instance.h.

References data.

Member Data Documentation

◆ _ascent

double FontInstance::_ascent
private

Definition at line 154 of file font-instance.h.

Referenced by find_font_metrics(), FontInstance(), FontMetrics(), and GetTypoAscent().

◆ _ascent_max

double FontInstance::_ascent_max
private

Definition at line 157 of file font-instance.h.

Referenced by find_font_metrics(), FontInstance(), GetMaxAscent(), and LoadGlyph().

◆ _baselines

double FontInstance::_baselines[SP_CSS_BASELINE_SIZE]
private

Definition at line 166 of file font-instance.h.

Referenced by find_font_metrics(), FontInstance(), and GetBaselines().

◆ _descent

double FontInstance::_descent
private

Definition at line 155 of file font-instance.h.

Referenced by find_font_metrics(), FontInstance(), FontMetrics(), and GetTypoDescent().

◆ _descent_max

double FontInstance::_descent_max
private

Definition at line 158 of file font-instance.h.

Referenced by find_font_metrics(), FontInstance(), GetMaxDescent(), and LoadGlyph().

◆ _design_units

int FontInstance::_design_units
private

Definition at line 159 of file font-instance.h.

Referenced by find_font_metrics(), GetDesignUnits(), and PixBuf().

◆ _family_class

unsigned short FontInstance::_family_class = 0
private

Definition at line 163 of file font-instance.h.

Referenced by family_class(), and find_font_metrics().

◆ _fixed_width

bool FontInstance::_fixed_width = false
private

Definition at line 161 of file font-instance.h.

Referenced by find_font_metrics(), and is_fixed_width().

◆ _italic_angle

double FontInstance::_italic_angle = 0.0
private

Definition at line 160 of file font-instance.h.

Referenced by find_font_metrics().

◆ _oblique

bool FontInstance::_oblique = false
private

Definition at line 162 of file font-instance.h.

Referenced by find_font_metrics(), and is_oblique().

◆ _xheight

double FontInstance::_xheight
private

Definition at line 156 of file font-instance.h.

Referenced by find_font_metrics(), FontInstance(), FontMetrics(), and GetXHeight().

◆ data

std::shared_ptr<Data> FontInstance::data
private

◆ descr

PangoFontDescription* FontInstance::descr
private

Definition at line 131 of file font-instance.h.

Referenced by acquire(), FontInstance(), get_descr(), init_face(), LoadGlyph(), and release().

◆ face

FT_Face FontInstance::face
private

◆ has_svg

bool FontInstance::has_svg = false
private

Definition at line 147 of file font-instance.h.

Referenced by FontHasSVG(), and init_face().

◆ hb_face

hb_face_t* FontInstance::hb_face
private

Definition at line 141 of file font-instance.h.

Referenced by acquire(), and init_face().

◆ hb_font

hb_font_t* FontInstance::hb_font
private

Definition at line 137 of file font-instance.h.

Referenced by acquire(), get_opentype_tables(), init_face(), and LoadGlyph().

◆ hb_font_copy

hb_font_t* FontInstance::hb_font_copy
private

Definition at line 138 of file font-instance.h.

Referenced by acquire(), and release().

◆ openTypeTableList

std::unordered_set<std::string> FontInstance::openTypeTableList
private

Definition at line 169 of file font-instance.h.

Referenced by init_face(), and LoadGlyph().

◆ p_font

PangoFont* FontInstance::p_font
private

The documentation for this class was generated from the following files: