~ubuntu-branches/ubuntu/utopic/inkscape/utopic-proposed

« back to all changes in this revision

Viewing changes to .pc/0005-Fix_FreeType_include.patch/src/libnrtype/FontFactory.h

  • Committer: Package Import Robot
  • Author(s): Alex Valavanis
  • Date: 2014-08-19 19:10:32 UTC
  • mfrom: (1.6.5) (2.5.14 sid)
  • Revision ID: package-import@ubuntu.com-20140819191032-2eca1qihaszjk9i6
Tags: 0.48.5-2ubuntu1
* Merge with Debian Unstable (LP: #1358863). Fixes several Ubuntu bugs:
  - Illustrator CS SVG won't load: namespace URIs in entities (LP: #166371)
  - inkscape crashed with SIGSEGV in
    sp_dtw_color_profile_event() (LP: #966441)
  - inkscape crashed with SIGSEGV (LP: #1051017)
  - inkscape crashed with SIGSEGV in Inkscape::Preferences::_getNode()
    (LP: #1163241)
  - save a copy reverts to save as (LP: #529843)
  - Extension to braille not working on Xubuntu 12.10 (LP: #1090865)
* Remaining changes:
  - debian/control:
    + Set Ubuntu Developer as maintainer,
    + build-depend on dh-translation to handle Ubuntu translation,
    + demote pstoedit from Recommends to Suggests (because it's in universe),
  - debian/patches/0006_add_unity_quicklist_support.patch: add.
  - debian/patches/series: update.
  - debian/rules:
    + add dh_translation to handle Ubuntu translation
* Drop debian/patches/librevenge.patch (superseded by
    debian/patches/0006-Update_to_new_libwpg.patch)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  FontFactory.h
3
 
 *  testICU
4
 
 *
5
 
 */
6
 
 
7
 
#ifndef my_font_factory
8
 
#define my_font_factory
9
 
 
10
 
//#include <glibmm/ustring.h>
11
 
 
12
 
#include <functional>
13
 
#include <algorithm>
14
 
 
15
 
#ifdef HAVE_CONFIG_H
16
 
# include <config.h>
17
 
#endif
18
 
#ifdef _WIN32
19
 
#define USE_PANGO_WIN32
20
 
#endif
21
 
 
22
 
#include <pango/pango.h>
23
 
#include "nr-type-primitives.h"
24
 
#include "nr-type-pos-def.h"
25
 
#include "font-style-to-pos.h"
26
 
#include <libnrtype/nrtype-forward.h>
27
 
#include "../style.h"
28
 
 
29
 
/* Freetype */
30
 
#ifdef USE_PANGO_WIN32
31
 
#include <pango/pangowin32.h>
32
 
#else
33
 
#include <pango/pangoft2.h>
34
 
#include <freetype/freetype.h>
35
 
#endif
36
 
 
37
 
namespace Glib
38
 
{
39
 
    class ustring;
40
 
}
41
 
 
42
 
// the font_factory keeps a hashmap of all the loaded font_instances, and uses the PangoFontDescription
43
 
// as index (nota: since pango already does that, using the PangoFont could work too)
44
 
struct font_descr_hash : public std::unary_function<PangoFontDescription*,size_t> {
45
 
    size_t operator()(PangoFontDescription *const &x) const;
46
 
};
47
 
struct font_descr_equal : public std::binary_function<PangoFontDescription*, PangoFontDescription*, bool> {
48
 
    bool operator()(PangoFontDescription *const &a, PangoFontDescription *const &b) const;
49
 
};
50
 
 
51
 
// Comparison functions for style names
52
 
int style_name_compare(char const *aa, char const *bb);
53
 
int family_name_compare(char const *a, char const *b);
54
 
 
55
 
// Map type for gathering UI family and style strings
56
 
typedef std::map<Glib::ustring, std::list<Glib::ustring> > FamilyToStylesMap;
57
 
 
58
 
class font_factory {
59
 
public:
60
 
    static font_factory *lUsine; /**< The default font_factory; i cannot think of why we would
61
 
                                  *   need more than one.
62
 
                                  *
63
 
                                  *   ("l'usine" is french for "the factory".)
64
 
                                  */
65
 
 
66
 
    /** A little cache for fonts, so that you don't loose your time looking up fonts in the font list
67
 
     *  each font in the cache is refcounted once (and deref'd when removed from the cache). */
68
 
    struct font_entry {
69
 
        font_instance *f;
70
 
        double age;
71
 
    };
72
 
    int nbEnt;   ///< Number of entries.
73
 
    int maxEnt;  ///< Cache size.
74
 
    font_entry *ents;
75
 
 
76
 
    // Pango data.  Backend-specific structures are cast to these opaque types.
77
 
    PangoFontMap *fontServer;
78
 
    PangoContext *fontContext;
79
 
#ifdef USE_PANGO_WIN32
80
 
    PangoWin32FontCache *pangoFontCache;
81
 
    HDC hScreenDC;
82
 
#endif
83
 
    double fontSize; /**< The huge fontsize used as workaround for hinting.
84
 
                      *   Different between freetype and win32. */
85
 
 
86
 
    font_factory();
87
 
    virtual ~font_factory();
88
 
 
89
 
    /// Returns the default font_factory.
90
 
    static font_factory*  Default();
91
 
 
92
 
    /// Constructs a pango string for use with the fontStringMap (see below)
93
 
    Glib::ustring         ConstructFontSpecification(PangoFontDescription *font);
94
 
    Glib::ustring         ConstructFontSpecification(font_instance *font);
95
 
 
96
 
    /// Returns strings to be used in the UI for family and face (or "style" as the column is labeled)
97
 
    Glib::ustring         GetUIFamilyString(PangoFontDescription const *fontDescr);
98
 
    Glib::ustring         GetUIStyleString(PangoFontDescription const *fontDescr);
99
 
 
100
 
    /// Modifiers for the font specification (returns new font specification)
101
 
    Glib::ustring         ReplaceFontSpecificationFamily(const Glib::ustring & fontSpec, const Glib::ustring & newFamily);
102
 
    Glib::ustring         FontSpecificationSetItalic(const Glib::ustring & fontSpec, bool turnOn);
103
 
    Glib::ustring         FontSpecificationSetBold(const Glib::ustring & fontSpec, bool turnOn);
104
 
 
105
 
    Glib::ustring         FontSpecificationBestMatch(const Glib::ustring& fontSpec );
106
 
 
107
 
    // Gathers all strings needed for UI while storing pango information in
108
 
    // fontInstanceMap and fontStringMap
109
 
    void                  GetUIFamiliesAndStyles(FamilyToStylesMap *map);
110
 
 
111
 
    /// Retrieve a font_instance from a style object, first trying to use the font-specification, the CSS information
112
 
    font_instance*        FaceFromStyle(SPStyle const *style);
113
 
 
114
 
    // Various functions to get a font_instance from different descriptions.
115
 
    font_instance*        FaceFromDescr(char const *family, char const *style);
116
 
    font_instance*        FaceFromUIStrings(char const *uiFamily, char const *uiStyle);
117
 
    font_instance*        FaceFromPangoString(char const *pangoString);
118
 
    font_instance*        FaceFromFontSpecification(char const *fontSpecification);
119
 
    font_instance*        Face(PangoFontDescription *descr, bool canFail=true);
120
 
    font_instance*        Face(char const *family,
121
 
                               int variant=PANGO_VARIANT_NORMAL, int style=PANGO_STYLE_NORMAL,
122
 
                               int weight=PANGO_WEIGHT_NORMAL, int stretch=PANGO_STRETCH_NORMAL,
123
 
                               int size=10, int spacing=0);
124
 
    font_instance*        Face(char const *family, NRTypePosDef apos);
125
 
 
126
 
    /// Semi-private: tells the font_factory taht the font_instance 'who' has died and should be removed from loadedFaces
127
 
    void                  UnrefFace(font_instance* who);
128
 
 
129
 
    // internal
130
 
    void                  AddInCache(font_instance *who);
131
 
 
132
 
private:
133
 
    void*                 loadedPtr;
134
 
 
135
 
    // These two maps are used for translating between what's in the UI and a pango
136
 
    // font description.  This is necessary because Pango cannot always
137
 
    // reproduce these structures from the names it gave us in the first place.
138
 
 
139
 
    // Key: A string produced by font_factory::ConstructFontSpecification
140
 
    // Value: The associated PangoFontDescription
141
 
    typedef std::map<Glib::ustring, PangoFontDescription *> PangoStringToDescrMap;
142
 
    PangoStringToDescrMap fontInstanceMap;
143
 
 
144
 
    // Key: Family name in UI + Style name in UI
145
 
    // Value: The associated string that should be produced with font_factory::ConstructFontSpecification
146
 
    typedef std::map<Glib::ustring, Glib::ustring> UIStringToPangoStringMap;
147
 
    UIStringToPangoStringMap fontStringMap;
148
 
};
149
 
 
150
 
 
151
 
#endif /* my_font_factory */
152
 
 
153
 
 
154
 
/*
155
 
  Local Variables:
156
 
  mode:c++
157
 
  c-file-style:"stroustrup"
158
 
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
159
 
  indent-tabs-mode:nil
160
 
  fill-column:99
161
 
  End:
162
 
*/
163
 
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :