Git init
[external/pango1.0.git] / pango / pangofc-fontmap.h
1 /* Pango
2  * pangofc-fontmap.h: Base fontmap type for fontconfig-based backends
3  *
4  * Copyright (C) 2003 Red Hat Software
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22 #ifndef __PANGO_FC_FONT_MAP_H__
23 #define __PANGO_FC_FONT_MAP_H__
24
25 #include <fontconfig/fontconfig.h>
26 #include <pango/pango-fontmap.h>
27 #include <pango/pangofc-decoder.h>
28 #include <pango/pangofc-font.h>
29
30 G_BEGIN_DECLS
31
32
33 #ifdef PANGO_ENABLE_BACKEND
34
35 /**
36  * PangoFcFontsetKey:
37  *
38  * An opaque structure containing all the information needed for
39  * loading a fontset with the PangoFc fontmap.
40  *
41  * Since: 1.24
42  **/
43 typedef struct _PangoFcFontsetKey  PangoFcFontsetKey;
44
45 PangoLanguage              *pango_fc_fontset_key_get_language      (const PangoFcFontsetKey *key);
46 const PangoFontDescription *pango_fc_fontset_key_get_description   (const PangoFcFontsetKey *key);
47 const PangoMatrix          *pango_fc_fontset_key_get_matrix        (const PangoFcFontsetKey *key);
48 double                      pango_fc_fontset_key_get_absolute_size (const PangoFcFontsetKey *key);
49 double                      pango_fc_fontset_key_get_resolution    (const PangoFcFontsetKey *key);
50 gpointer                    pango_fc_fontset_key_get_context_key   (const PangoFcFontsetKey *key);
51
52 /**
53  * PangoFcFontKey:
54  *
55  * An opaque structure containing all the information needed for
56  * loading a font with the PangoFc fontmap.
57  *
58  * Since: 1.24
59  **/
60 typedef struct _PangoFcFontKey     PangoFcFontKey;
61
62 const FcPattern   *pango_fc_font_key_get_pattern     (const PangoFcFontKey *key);
63 const PangoMatrix *pango_fc_font_key_get_matrix      (const PangoFcFontKey *key);
64 gpointer           pango_fc_font_key_get_context_key (const PangoFcFontKey *key);
65
66 #endif
67
68
69 /*
70  * PangoFcFontMap
71  */
72
73 #define PANGO_TYPE_FC_FONT_MAP              (pango_fc_font_map_get_type ())
74 #define PANGO_FC_FONT_MAP(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FC_FONT_MAP, PangoFcFontMap))
75 #define PANGO_IS_FC_FONT_MAP(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FC_FONT_MAP))
76
77 typedef struct _PangoFcFontMap        PangoFcFontMap;
78 typedef struct _PangoFcFontMapClass   PangoFcFontMapClass;
79 typedef struct _PangoFcFontMapPrivate PangoFcFontMapPrivate;
80
81 #ifdef PANGO_ENABLE_BACKEND
82
83 #define PANGO_FC_FONT_MAP_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FC_FONT_MAP, PangoFcFontMapClass))
84 #define PANGO_IS_FC_FONT_MAP_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FC_FONT_MAP))
85 #define PANGO_FC_FONT_MAP_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FC_FONT_MAP, PangoFcFontMapClass))
86
87 /**
88  * PangoFcFontMap:
89  *
90  * #PangoFcFontMap is a base class for font map implementations
91  * using the Fontconfig and FreeType libraries. To create a new
92  * backend using Fontconfig and FreeType, you derive from this class
93  * and implement a new_font() virtual function that creates an
94  * instance deriving from #PangoFcFont.
95  **/
96 struct _PangoFcFontMap
97 {
98   PangoFontMap parent_instance;
99
100   PangoFcFontMapPrivate *priv;
101 };
102
103 /**
104  * PangoFcFontMapClass:
105  * @default_substitute: Substitutes in default values for
106  *  unspecified fields in a #FcPattern. This will be called
107  *  prior to creating a font for the pattern. May be %NULL.
108  *  Deprecated in favor of @font_key_substitute().
109  * @new_font: Creates a new #PangoFcFont for the specified
110  *  pattern of the appropriate type for this font map. The
111  *  @pattern argument must be passed to the "pattern" property
112  *  of #PangoFcFont when you call g_object_new(). Deprecated
113  *  in favor of @create_font().
114  * @get_resolution: Gets the resolution (the scale factor
115  *  between logical and absolute font sizes) that the backend
116  *  will use for a particular fontmap and context. @context
117  *  may be null.
118  * @context_key_get: Gets an opaque key holding backend
119  *  specific options for the context that will affect
120  *  fonts created by create_font(). The result must point to
121  *  persistant storage owned by the fontmap. This key
122  *  is used to index hash tables used to look up fontsets
123  *  and fonts.
124  * @context_key_copy: Copies a context key. Pango uses this
125  *  to make a persistant copy of the value returned from
126  *  @context_key_get.
127  * @context_key_free: Frees a context key copied with
128  *  @context_key_copy.
129  * @context_key_hash: Gets a hash value for a context key
130  * @context_key_equal: Compares two context keys for equality.
131  * @fontset_key_substitute: Substitutes in default values for
132  *  unspecified fields in a #FcPattern. This will be called
133  *  prior to creating a font for the pattern. May be %NULL.
134  *  (Since: 1.24)
135  * @create_font: Creates a new #PangoFcFont for the specified
136  *  pattern of the appropriate type for this font map using
137  *  information from the font key that is passed in. The
138  *  @pattern member of @font_key can be retrieved using
139  *  pango_fc_font_key_get_pattern() and must be passed to
140  *  the "pattern" property of #PangoFcFont when you call
141  *  g_object_new().  If %NULL, new_font() is used.
142  *  (Since: 1.24)
143  *
144  * Class structure for #PangoFcFontMap.
145  **/
146 struct _PangoFcFontMapClass
147 {
148   /*< private >*/
149   PangoFontMapClass parent_class;
150
151   /*< public >*/
152   /* Deprecated in favor of fontset_key_substitute */
153   void         (*default_substitute) (PangoFcFontMap   *fontmap,
154                                       FcPattern        *pattern);
155   /* Deprecated in favor of create_font */
156   PangoFcFont  *(*new_font)          (PangoFcFontMap  *fontmap,
157                                       FcPattern       *pattern);
158
159   double       (*get_resolution)     (PangoFcFontMap             *fcfontmap,
160                                       PangoContext               *context);
161
162   gconstpointer (*context_key_get)   (PangoFcFontMap             *fcfontmap,
163                                       PangoContext               *context);
164   gpointer     (*context_key_copy)   (PangoFcFontMap             *fcfontmap,
165                                       gconstpointer               key);
166   void         (*context_key_free)   (PangoFcFontMap             *fcfontmap,
167                                       gpointer                    key);
168   guint32      (*context_key_hash)   (PangoFcFontMap             *fcfontmap,
169                                       gconstpointer               key);
170   gboolean     (*context_key_equal)  (PangoFcFontMap             *fcfontmap,
171                                       gconstpointer               key_a,
172                                       gconstpointer               key_b);
173
174   void         (*fontset_key_substitute)(PangoFcFontMap             *fontmap,
175                                       PangoFcFontsetKey          *fontsetkey,
176                                       FcPattern                  *pattern);
177   PangoFcFont  *(*create_font)       (PangoFcFontMap             *fontmap,
178                                       PangoFcFontKey             *fontkey);
179   /*< private >*/
180
181   /* Padding for future expansion */
182   void (*_pango_reserved1) (void);
183   void (*_pango_reserved2) (void);
184   void (*_pango_reserved3) (void);
185   void (*_pango_reserved4) (void);
186 };
187
188 #ifndef PANGO_DISABLE_DEPRECATED
189 PangoContext * pango_fc_font_map_create_context (PangoFcFontMap *fcfontmap);
190 #endif
191 void           pango_fc_font_map_shutdown       (PangoFcFontMap *fcfontmap);
192
193 #endif
194
195 GType pango_fc_font_map_get_type (void) G_GNUC_CONST;
196
197 void           pango_fc_font_map_cache_clear    (PangoFcFontMap *fcfontmap);
198
199 /**
200  * PangoFcDecoderFindFunc:
201  * @pattern: a fully resolved #FcPattern specifying the font on the system
202  * @user_data: user data passed to pango_fc_font_map_add_decoder_find_func()
203  *
204  * Callback function passed to pango_fc_font_map_add_decoder_find_func().
205  *
206  * Return value: a new reference to a custom decoder for this pattern,
207  *  or %NULL if the default decoder handling should be used.
208  **/
209 typedef PangoFcDecoder * (*PangoFcDecoderFindFunc) (FcPattern *pattern,
210                                                     gpointer   user_data);
211
212 void pango_fc_font_map_add_decoder_find_func (PangoFcFontMap        *fcfontmap,
213                                               PangoFcDecoderFindFunc findfunc,
214                                               gpointer               user_data,
215                                               GDestroyNotify         dnotify);
216 PangoFcDecoder *pango_fc_font_map_find_decoder (PangoFcFontMap *fcfontmap,
217                                                 FcPattern      *pattern);
218
219 PangoFontDescription *pango_fc_font_description_from_pattern (FcPattern *pattern,
220                                                               gboolean   include_size);
221
222 /**
223  * PANGO_FC_GRAVITY:
224  *
225  * String representing a fontconfig property name that Pango sets on any
226  * fontconfig pattern it passes to fontconfig if a #PangoGravity other
227  * than %PangoGravitySouth is desired.
228  *
229  * The property will have a #PangoGravity value as a string, like "east".
230  * This can be used to write fontconfig configuration rules to choose
231  * different fonts for horizontal and vertical writing directions.
232  *
233  * Since: 1.20
234  */
235 #define PANGO_FC_GRAVITY "pangogravity"
236
237 /**
238  * PANGO_FC_VERSION:
239  *
240  * String representing a fontconfig property name that Pango sets on any
241  * fontconfig pattern it passes to fontconfig.
242  *
243  * The property will have an integer value equal to what
244  * pango_version() returns.
245  * This can be used to write fontconfig configuration rules that only affect
246  * certain pango versions (or only pango-using applications, or only
247  * non-pango-using applications).
248  *
249  * Since: 1.20
250  */
251 #define PANGO_FC_VERSION "pangoversion"
252
253 /**
254  * PANGO_FC_PRGNAME:
255  *
256  * String representing a fontconfig property name that Pango sets on any
257  * fontconfig pattern it passes to fontconfig.
258  *
259  * The property will have a string equal to what
260  * g_get_prgname() returns.
261  * This can be used to write fontconfig configuration rules that only affect
262  * certain applications.
263  *
264  * Since: 1.24
265  */
266 #define PANGO_FC_PRGNAME "pangoprgname"
267
268 G_END_DECLS
269
270 #endif /* __PANGO_FC_FONT_MAP_H__ */