16
15
#include <2geom/d2.h>
18
17
// the font_instance are the template of several raster_font; they provide metrics and outlines
19
// that are drawn by the raster_font, so the raster_font needs info relative to the way the
18
// that are drawn by the raster_font, so the raster_font needs info relative to the way the
20
19
// font need to be drawn. note that fontsize is a scale factor in the transform matrix
22
// the various raster_font in use at a given time are held in a hash_map whose indices are the
23
// styles, hence the 2 following 'classes'
24
struct font_style_hash : public std::unary_function<font_style, size_t> {
25
size_t operator()(font_style const &x) const;
28
struct font_style_equal : public std::binary_function<font_style, font_style, bool> {
29
bool operator()(font_style const &a, font_style const &b);
32
21
class font_instance {
34
// hashmap to get the raster_font for a given style
35
__gnu_cxx::hash_map<font_style, raster_font*, font_style_hash, font_style_equal> loadedStyles;
36
// the real source of the font
23
// the real source of the font
38
// depending on the rendering backend, different temporary data
25
// depending on the rendering backend, different temporary data
40
// that's the font's fingerprint; this particular PangoFontDescription gives the entry at which this font_instance
41
// resides in the font_factory loadedFaces hash_map
27
// that's the font's fingerprint; this particular PangoFontDescription gives the entry at which this font_instance
28
// resides in the font_factory loadedFaces unordered_map
42
29
PangoFontDescription* descr;
45
// font_factory owning this font_instance
32
// font_factory owning this font_instance
46
33
font_factory* daddy;
48
35
// common glyph definitions for all the rasterfonts
59
46
bool IsOutlineFont(void); // utility
60
47
void InstallFace(PangoFont* iFace); // utility; should reset the pFont field if loading failed
61
// in case the PangoFont is a bitmap font, for example. that way, the calling function
62
// will be able to check the validity of the font before installing it in loadedFaces
48
// in case the PangoFont is a bitmap font, for example. that way, the calling function
49
// will be able to check the validity of the font before installing it in loadedFaces
63
50
void InitTheFace();
65
52
int MapUnicodeChar(gunichar c); // calls the relevant unicode->glyph index function
66
53
void LoadGlyph(int glyph_id); // the main backend-dependent function
67
// loads the given glyph's info
69
// nota: all coordinates returned by these functions are on a [0..1] scale; you need to multiply
70
// by the fontsize to get the real sizes
54
// loads the given glyph's info
56
// nota: all coordinates returned by these functions are on a [0..1] scale; you need to multiply
57
// by the fontsize to get the real sizes
71
58
Path* Outline(int glyph_id, Path *copyInto=NULL);
72
// queries the outline of the glyph (in livarot Path form), and copies it into copyInto instead
73
// of allocating a new Path if copyInto != NULL
59
// queries the outline of the glyph (in livarot Path form), and copies it into copyInto instead
60
// of allocating a new Path if copyInto != NULL
74
61
Geom::PathVector* PathVector(int glyph_id);
75
62
// returns the 2geom-type pathvector for this glyph. no refcounting needed, it's deallocated when the font_instance dies
76
63
double Advance(int glyph_id, bool vertical);
77
// nominal advance of the font.
64
// nominal advance of the font.
78
65
bool FontMetrics(double &ascent, double &descent, double &leading);
79
66
bool FontSlope(double &run, double &rise);
80
67
// for generating slanted cursors for oblique fonts
81
68
Geom::OptRect BBox(int glyph_id);
83
// creates a rasterfont for the given style
70
// creates a rasterfont for the given style
84
71
raster_font* RasterFont(Geom::Matrix const &trs, double stroke_width,
85
72
bool vertical = false, JoinType stroke_join = join_straight,
86
73
ButtType stroke_cap = butt_straight, float miter_limit = 4.0);
87
// the dashes array in iStyle is copied
74
// the dashes array in iStyle is copied
88
75
raster_font* RasterFont(font_style const &iStyle);
89
// private use: tells the font_instance that the raster_font 'who' has died
76
// private use: tells the font_instance that the raster_font 'who' has died
90
77
void RemoveRasterFont(raster_font *who);
93
80
unsigned Name(gchar *str, unsigned size);
94
81
unsigned PSName(gchar *str, unsigned size);
95
82
unsigned Family(gchar *str, unsigned size);