~ubuntu-branches/ubuntu/precise/inkscape/precise-updates

« back to all changes in this revision

Viewing changes to src/libnrtype/font-instance.h

  • Committer: Bazaar Package Importer
  • Author(s): Alex Valavanis
  • Date: 2010-09-12 19:44:58 UTC
  • mfrom: (1.1.12 upstream) (45.1.3 maverick)
  • Revision ID: james.westby@ubuntu.com-20100912194458-4sjwmbl7dlsrk5dc
Tags: 0.48.0-1ubuntu1
* Merge with Debian unstable (LP: #628048, LP: #401567, LP: #456248, 
  LP: #463602, LP: #591986)
* debian/control: 
  - Ubuntu maintainers
  - Promote python-lxml, python-numpy, python-uniconvertor to Recommends.
  - Demote pstoedit to Suggests (universe package).
  - Suggests ttf-dejavu instead of ttf-bitstream-vera (LP: #513319)
* debian/rules:
  - Run intltool-update on build (Ubuntu-specific).
  - Add translation domain to .desktop files (Ubuntu-specific).
* debian/dirs:
  - Add usr/share/pixmaps.  Allow inkscape.xpm installation
* drop 50-poppler-API.dpatch (now upstream)
* drop 51-paste-in-unwritable-directory.dpatch (now upstream) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#ifndef SEEN_LIBNRTYPE_FONT_INSTANCE_H
2
2
#define SEEN_LIBNRTYPE_FONT_INSTANCE_H
3
3
 
4
 
#include <ext/hash_map>
5
4
#include <map>
6
5
#include <pango/pango-types.h>
7
6
#include <pango/pango-font.h>
16
15
#include <2geom/d2.h>
17
16
 
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
21
20
// of the style
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;
26
 
};
27
 
 
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);
30
 
};
31
 
 
32
21
class font_instance {
33
22
public:
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
37
24
    PangoFont*            pFont;
38
 
                // depending on the rendering backend, different temporary data
 
25
    // depending on the rendering backend, different temporary data
39
26
 
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;
43
 
                // refcount
 
30
    // refcount
44
31
    int                   refCount;
45
 
                // font_factory owning this font_instance
 
32
    // font_factory owning this font_instance
46
33
    font_factory*         daddy;
47
34
 
48
35
    // common glyph definitions for all the rasterfonts
58
45
 
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();
64
51
 
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
68
 
                
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
 
55
 
 
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);
82
69
 
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);
91
78
 
92
 
                // attribute queries
 
79
    // attribute queries
93
80
    unsigned             Name(gchar *str, unsigned size);
94
81
    unsigned             PSName(gchar *str, unsigned size);
95
82
    unsigned             Family(gchar *str, unsigned size);
98
85
private:
99
86
    void                 FreeTheFace();
100
87
 
 
88
    // hashmap to get the raster_font for a given style
 
89
    void*                loadedPtr;
 
90
 
101
91
#ifdef USE_PANGO_WIN32
102
92
    HFONT                 theFace;
103
93
#else
104
 
    FT_Face               theFace; 
 
94
    FT_Face               theFace;
105
95
                // it's a pointer in fact; no worries to ref/unref it, pango does its magic
106
96
                // as long as pFont is valid, theFace is too
107
97
#endif