Inkscape
Vector Graphics Editor
|
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 | |
PangoFontDescription * | descr |
PangoFont * | p_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< Data > | data |
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.
FontInstance::FontInstance | ( | PangoFont * | p_font, |
PangoFontDescription * | descr | ||
) |
Constructor; takes ownership of both arguments, which must be non-null. Throws CtorException on failure.
Definition at line 112 of file font-instance.cpp.
References _ascent, _ascent_max, _baselines, _descent, _descent_max, _xheight, acquire(), descr, find_font_metrics(), init_face(), p_font, SP_CSS_BASELINE_ALPHABETIC, SP_CSS_BASELINE_AUTO, SP_CSS_BASELINE_CENTRAL, SP_CSS_BASELINE_HANGING, SP_CSS_BASELINE_IDEOGRAPHIC, SP_CSS_BASELINE_MATHEMATICAL, SP_CSS_BASELINE_MIDDLE, SP_CSS_BASELINE_TEXT_AFTER_EDGE, and SP_CSS_BASELINE_TEXT_BEFORE_EDGE.
FontInstance::~FontInstance | ( | ) |
Definition at line 136 of file font-instance.cpp.
References release().
|
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().
double FontInstance::Advance | ( | unsigned int | glyph_id, |
bool | vertical | ||
) |
Definition at line 722 of file font-instance.cpp.
References LoadGlyph().
Geom::Rect FontInstance::BBoxDraw | ( | unsigned int | glyph_id | ) |
Definition at line 585 of file font-instance.cpp.
References LoadGlyph().
Geom::Rect FontInstance::BBoxExact | ( | unsigned int | glyph_id | ) |
Definition at line 565 of file font-instance.cpp.
References LoadGlyph().
Geom::Rect FontInstance::BBoxPick | ( | unsigned int | glyph_id | ) |
Definition at line 575 of file font-instance.cpp.
References LoadGlyph().
|
inline |
Definition at line 117 of file font-instance.h.
References _family_class.
|
private |
Definition at line 268 of file font-instance.cpp.
References _ascent, _ascent_max, _baselines, _descent, _descent_max, _design_units, _family_class, _fixed_width, _italic_angle, _oblique, _xheight, face, FTFixedToDouble(), index, SP_CSS_BASELINE_CENTRAL, SP_CSS_BASELINE_HANGING, SP_CSS_BASELINE_IDEOGRAPHIC, SP_CSS_BASELINE_MATHEMATICAL, SP_CSS_BASELINE_MIDDLE, SP_CSS_BASELINE_TEXT_AFTER_EDGE, and SP_CSS_BASELINE_TEXT_BEFORE_EDGE.
Referenced by FontInstance().
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.
|
inline |
Definition at line 75 of file font-instance.h.
References has_svg.
bool FontInstance::FontMetrics | ( | double & | ascent, |
double & | descent, | ||
double & | leading | ||
) | const |
Definition at line 524 of file font-instance.cpp.
bool FontInstance::FontSlope | ( | double & | run, |
double & | rise | ||
) | const |
Definition at line 546 of file font-instance.cpp.
References face.
|
inline |
Definition at line 112 of file font-instance.h.
References descr.
Referenced by FontFactory::ConstructFontSpecification().
|
inline |
Definition at line 113 of file font-instance.h.
References p_font.
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().
|
inline |
Definition at line 77 of file font-instance.h.
References data.
|
inline |
Definition at line 97 of file font-instance.h.
References _baselines.
|
inline |
Definition at line 98 of file font-instance.h.
References _design_units.
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.
|
inline |
Definition at line 95 of file font-instance.h.
References _ascent_max.
Referenced by Inkscape::Text::Layout::FontMetrics::set().
|
inline |
Definition at line 96 of file font-instance.h.
References _descent_max.
Referenced by Inkscape::Text::Layout::FontMetrics::set().
|
inline |
Definition at line 92 of file font-instance.h.
References _ascent.
Referenced by Inkscape::Text::Layout::FontMetrics::set().
|
inline |
Definition at line 93 of file font-instance.h.
References _descent.
Referenced by Inkscape::Text::Layout::FontMetrics::set().
|
inline |
Definition at line 94 of file font-instance.h.
References _xheight.
Referenced by Inkscape::Text::Layout::FontMetrics::set().
|
inline |
Definition at line 110 of file font-instance.h.
References face.
|
private |
Definition at line 186 of file font-instance.cpp.
References data, descr, face, has_svg, hb_face, hb_font, name, openTypeTableList, p_font, readOpenTypeFvarAxes(), readOpenTypeSVGTable(), readOpenTypeTableList(), and w.
Referenced by FontInstance().
|
inline |
Definition at line 115 of file font-instance.h.
References _fixed_width.
|
inline |
Definition at line 116 of file font-instance.h.
References _oblique.
|
inline |
Definition at line 109 of file font-instance.h.
References face.
FontGlyph const * FontInstance::LoadGlyph | ( | unsigned int | glyph_id | ) |
Definition at line 400 of file font-instance.cpp.
References _ascent_max, _descent_max, data, descr, Geom::PathVector::empty(), face, Geom::PathIteratorSink< OutputIterator >::flush(), ft2_conic_to(), ft2_cubic_to(), ft2_line_to(), ft2_move_to(), hb_font, openTypeTableList, and Geom::PathBuilder::peek().
Referenced by Advance(), BBoxDraw(), BBoxExact(), BBoxPick(), and PathVector().
unsigned int FontInstance::MapUnicodeChar | ( | gunichar | c | ) | const |
Definition at line 386 of file font-instance.cpp.
Geom::PathVector const * FontInstance::PathVector | ( | unsigned int | glyph_id | ) |
Definition at line 595 of file font-instance.cpp.
References LoadGlyph().
Inkscape::Pixbuf const * FontInstance::PixBuf | ( | unsigned int | glyph_id | ) |
Definition at line 605 of file font-instance.cpp.
References _design_units, Inkscape::Pixbuf::create_from_buffer(), data, end, Inkscape::Pixbuf::PF_CAIRO, start, and w.
|
private |
Definition at line 173 of file font-instance.cpp.
References descr, face, hb_font_copy, and p_font.
Referenced by acquire(), and ~FontInstance().
|
inline |
Definition at line 90 of file font-instance.h.
References data.
|
private |
Definition at line 154 of file font-instance.h.
Referenced by find_font_metrics(), FontInstance(), FontMetrics(), and GetTypoAscent().
|
private |
Definition at line 157 of file font-instance.h.
Referenced by find_font_metrics(), FontInstance(), GetMaxAscent(), and LoadGlyph().
|
private |
Definition at line 166 of file font-instance.h.
Referenced by find_font_metrics(), FontInstance(), and GetBaselines().
|
private |
Definition at line 155 of file font-instance.h.
Referenced by find_font_metrics(), FontInstance(), FontMetrics(), and GetTypoDescent().
|
private |
Definition at line 158 of file font-instance.h.
Referenced by find_font_metrics(), FontInstance(), GetMaxDescent(), and LoadGlyph().
|
private |
Definition at line 159 of file font-instance.h.
Referenced by find_font_metrics(), GetDesignUnits(), and PixBuf().
|
private |
Definition at line 163 of file font-instance.h.
Referenced by family_class(), and find_font_metrics().
|
private |
Definition at line 161 of file font-instance.h.
Referenced by find_font_metrics(), and is_fixed_width().
|
private |
Definition at line 160 of file font-instance.h.
Referenced by find_font_metrics().
|
private |
Definition at line 162 of file font-instance.h.
Referenced by find_font_metrics(), and is_oblique().
|
private |
Definition at line 156 of file font-instance.h.
Referenced by find_font_metrics(), FontInstance(), FontMetrics(), and GetXHeight().
|
private |
Definition at line 197 of file font-instance.h.
Referenced by get_opentype_tables(), get_opentype_varaxes(), init_face(), LoadGlyph(), PixBuf(), and share_data().
|
private |
Definition at line 131 of file font-instance.h.
Referenced by acquire(), FontInstance(), get_descr(), init_face(), LoadGlyph(), and release().
|
private |
Definition at line 145 of file font-instance.h.
Referenced by acquire(), find_font_metrics(), FontDecoration(), FontSlope(), has_vertical(), init_face(), IsOutlineFont(), LoadGlyph(), MapUnicodeChar(), and release().
|
private |
Definition at line 147 of file font-instance.h.
Referenced by FontHasSVG(), and init_face().
|
private |
Definition at line 141 of file font-instance.h.
Referenced by acquire(), and init_face().
|
private |
Definition at line 137 of file font-instance.h.
Referenced by acquire(), get_opentype_tables(), init_face(), and LoadGlyph().
|
private |
Definition at line 138 of file font-instance.h.
|
private |
Definition at line 169 of file font-instance.h.
Referenced by init_face(), and LoadGlyph().
|
private |
Definition at line 134 of file font-instance.h.
Referenced by acquire(), FontInstance(), get_font(), get_opentype_tables(), GetFilename(), init_face(), and release().