2 * pangofc-fontmap.h: Base fontmap type for fontconfig-based backends
4 * Copyright (C) 2003 Red Hat Software
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.
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.
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.
22 #ifndef __PANGO_FC_FONT_MAP_H__
23 #define __PANGO_FC_FONT_MAP_H__
25 #include <fontconfig/fontconfig.h>
26 #include <pango/pango-fontmap.h>
27 #include <pango/pangofc-decoder.h>
28 #include <pango/pangofc-font.h>
33 #ifdef PANGO_ENABLE_BACKEND
38 * An opaque structure containing all the information needed for
39 * loading a fontset with the PangoFc fontmap.
43 typedef struct _PangoFcFontsetKey PangoFcFontsetKey;
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);
55 * An opaque structure containing all the information needed for
56 * loading a font with the PangoFc fontmap.
60 typedef struct _PangoFcFontKey PangoFcFontKey;
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);
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))
77 typedef struct _PangoFcFontMap PangoFcFontMap;
78 typedef struct _PangoFcFontMapClass PangoFcFontMapClass;
79 typedef struct _PangoFcFontMapPrivate PangoFcFontMapPrivate;
81 #ifdef PANGO_ENABLE_BACKEND
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))
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.
96 struct _PangoFcFontMap
98 PangoFontMap parent_instance;
100 PangoFcFontMapPrivate *priv;
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
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
124 * @context_key_copy: Copies a context key. Pango uses this
125 * to make a persistant copy of the value returned from
127 * @context_key_free: Frees a context key copied with
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.
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.
144 * Class structure for #PangoFcFontMap.
146 struct _PangoFcFontMapClass
149 PangoFontMapClass parent_class;
152 /* Deprecated in favor of fontset_key_substitute */
153 void (*default_substitute) (PangoFcFontMap *fontmap,
155 /* Deprecated in favor of create_font */
156 PangoFcFont *(*new_font) (PangoFcFontMap *fontmap,
159 double (*get_resolution) (PangoFcFontMap *fcfontmap,
160 PangoContext *context);
162 gconstpointer (*context_key_get) (PangoFcFontMap *fcfontmap,
163 PangoContext *context);
164 gpointer (*context_key_copy) (PangoFcFontMap *fcfontmap,
166 void (*context_key_free) (PangoFcFontMap *fcfontmap,
168 guint32 (*context_key_hash) (PangoFcFontMap *fcfontmap,
170 gboolean (*context_key_equal) (PangoFcFontMap *fcfontmap,
172 gconstpointer key_b);
174 void (*fontset_key_substitute)(PangoFcFontMap *fontmap,
175 PangoFcFontsetKey *fontsetkey,
177 PangoFcFont *(*create_font) (PangoFcFontMap *fontmap,
178 PangoFcFontKey *fontkey);
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);
188 #ifndef PANGO_DISABLE_DEPRECATED
189 PangoContext * pango_fc_font_map_create_context (PangoFcFontMap *fcfontmap);
191 void pango_fc_font_map_shutdown (PangoFcFontMap *fcfontmap);
195 GType pango_fc_font_map_get_type (void) G_GNUC_CONST;
197 void pango_fc_font_map_cache_clear (PangoFcFontMap *fcfontmap);
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()
204 * Callback function passed to pango_fc_font_map_add_decoder_find_func().
206 * Return value: a new reference to a custom decoder for this pattern,
207 * or %NULL if the default decoder handling should be used.
209 typedef PangoFcDecoder * (*PangoFcDecoderFindFunc) (FcPattern *pattern,
212 void pango_fc_font_map_add_decoder_find_func (PangoFcFontMap *fcfontmap,
213 PangoFcDecoderFindFunc findfunc,
215 GDestroyNotify dnotify);
216 PangoFcDecoder *pango_fc_font_map_find_decoder (PangoFcFontMap *fcfontmap,
219 PangoFontDescription *pango_fc_font_description_from_pattern (FcPattern *pattern,
220 gboolean include_size);
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.
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.
235 #define PANGO_FC_GRAVITY "pangogravity"
240 * String representing a fontconfig property name that Pango sets on any
241 * fontconfig pattern it passes to fontconfig.
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).
251 #define PANGO_FC_VERSION "pangoversion"
256 * String representing a fontconfig property name that Pango sets on any
257 * fontconfig pattern it passes to fontconfig.
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.
266 #define PANGO_FC_PRGNAME "pangoprgname"
270 #endif /* __PANGO_FC_FONT_MAP_H__ */