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_PRIVATE_H__
23#define __PANGO_FC_FONT_MAP_PRIVATE_H__
24
25#include <pango/pangofc-fontmap.h>
26#include <pango/pangofc-decoder.h>
27#include <pango/pangofc-font-private.h>
28#include <pango/pango-fontmap.h>
29#include <pango/pango-fontset.h>
30
31#include <fontconfig/fontconfig.h>
32
33G_BEGIN_DECLS
34
35
36/**
37 * PangoFcFontsetKey:
38 *
39 * An opaque structure containing all the information needed for
40 * loading a fontset with the PangoFc fontmap.
41 *
42 * Since: 1.24
43 **/
44typedef struct _PangoFcFontsetKey PangoFcFontsetKey;
45
46PANGO_AVAILABLE_IN_1_24
47PangoLanguage *pango_fc_fontset_key_get_language (const PangoFcFontsetKey *key);
48PANGO_AVAILABLE_IN_1_24
49const PangoFontDescription *pango_fc_fontset_key_get_description (const PangoFcFontsetKey *key);
50PANGO_AVAILABLE_IN_1_24
51const PangoMatrix *pango_fc_fontset_key_get_matrix (const PangoFcFontsetKey *key);
52PANGO_AVAILABLE_IN_1_24
53double pango_fc_fontset_key_get_absolute_size (const PangoFcFontsetKey *key);
54PANGO_AVAILABLE_IN_1_24
55double pango_fc_fontset_key_get_resolution (const PangoFcFontsetKey *key);
56PANGO_AVAILABLE_IN_1_24
57gpointer pango_fc_fontset_key_get_context_key (const PangoFcFontsetKey *key);
58
59/**
60 * PangoFcFontKey:
61 *
62 * An opaque structure containing all the information needed for
63 * loading a font with the PangoFc fontmap.
64 *
65 * Since: 1.24
66 **/
67typedef struct _PangoFcFontKey PangoFcFontKey;
68
69PANGO_AVAILABLE_IN_1_24
70const FcPattern *pango_fc_font_key_get_pattern (const PangoFcFontKey *key);
71PANGO_AVAILABLE_IN_1_24
72const PangoMatrix *pango_fc_font_key_get_matrix (const PangoFcFontKey *key);
73PANGO_AVAILABLE_IN_1_24
74gpointer pango_fc_font_key_get_context_key (const PangoFcFontKey *key);
75PANGO_AVAILABLE_IN_1_40
76const char *pango_fc_font_key_get_variations (const PangoFcFontKey *key);
77
78
79#define PANGO_FC_FONT_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FC_FONT_MAP, PangoFcFontMapClass))
80#define PANGO_IS_FC_FONT_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FC_FONT_MAP))
81#define PANGO_FC_FONT_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FC_FONT_MAP, PangoFcFontMapClass))
82
83/**
84 * PangoFcFontMap:
85 *
86 * `PangoFcFontMap` is a base class for font map implementations
87 * using the Fontconfig and FreeType libraries. To create a new
88 * backend using Fontconfig and FreeType, you derive from this class
89 * and implement a new_font() virtual function that creates an
90 * instance deriving from `PangoFcFont`.
91 **/
92struct _PangoFcFontMap
93{
94 PangoFontMap parent_instance;
95
96 PangoFcFontMapPrivate *priv;
97
98 /* Function to call on prepared patterns to do final
99 * config tweaking.
100 */
101 PangoFcSubstituteFunc substitute_func;
102 gpointer substitute_data;
103 GDestroyNotify substitute_destroy;
104};
105
106/**
107 * PangoFcFontMapClass:
108 * @default_substitute: (nullable): Substitutes in default
109 * values for unspecified fields in a #FcPattern. This will
110 * be called prior to creating a font for the pattern.
111 * Implementations must call substitute_func if it is
112 * defined. May be %NULL. Deprecated in favor of
113 * @font_key_substitute().
114 * @new_font: Creates a new `PangoFcFont` for the specified
115 * pattern of the appropriate type for this font map. The
116 * @pattern argument must be passed to the "pattern" property
117 * of `PangoFcFont` when you call g_object_new(). Deprecated
118 * in favor of @create_font().
119 * @get_resolution: Gets the resolution (the scale factor
120 * between logical and absolute font sizes) that the backend
121 * will use for a particular fontmap and context. @context
122 * may be null.
123 * @context_key_get: Gets an opaque key holding backend
124 * specific options for the context that will affect
125 * fonts created by @create_font(). The result must point to
126 * persistant storage owned by the fontmap. This key
127 * is used to index hash tables used to look up fontsets
128 * and fonts.
129 * @context_key_copy: Copies a context key. Pango uses this
130 * to make a persistant copy of the value returned from
131 * @context_key_get.
132 * @context_key_free: Frees a context key copied with
133 * @context_key_copy.
134 * @context_key_hash: Gets a hash value for a context key
135 * @context_key_equal: Compares two context keys for equality.
136 * @fontset_key_substitute: (nullable): Substitutes in
137 * default values for unspecified fields in a
138 * #FcPattern. This will be called prior to creating a font
139 * for the pattern. Implementations must call substitute_func
140 * if it is defined. May be %NULL. (Since: 1.24)
141 * @create_font: (nullable): Creates a new `PangoFcFont` for
142 * the specified pattern of the appropriate type for this
143 * font map using information from the font key that is
144 * passed in. The @pattern member of @font_key can be
145 * retrieved using pango_fc_font_key_get_pattern() and must
146 * be passed to the "pattern" property of `PangoFcFont` when
147 * you call g_object_new(). If %NULL, new_font() is used.
148 * (Since: 1.24)
149 *
150 * Class structure for `PangoFcFontMap`.
151 **/
152struct _PangoFcFontMapClass
153{
154 /*< private >*/
155 PangoFontMapClass parent_class;
156
157 /*< public >*/
158 /* Deprecated in favor of fontset_key_substitute */
159 void (*default_substitute) (PangoFcFontMap *fontmap,
160 FcPattern *pattern);
161 /* Deprecated in favor of create_font */
162 PangoFcFont *(*new_font) (PangoFcFontMap *fontmap,
163 FcPattern *pattern);
164
165 double (*get_resolution) (PangoFcFontMap *fcfontmap,
166 PangoContext *context);
167
168 gconstpointer (*context_key_get) (PangoFcFontMap *fcfontmap,
169 PangoContext *context);
170 gpointer (*context_key_copy) (PangoFcFontMap *fcfontmap,
171 gconstpointer key);
172 void (*context_key_free) (PangoFcFontMap *fcfontmap,
173 gpointer key);
174 guint32 (*context_key_hash) (PangoFcFontMap *fcfontmap,
175 gconstpointer key);
176 gboolean (*context_key_equal) (PangoFcFontMap *fcfontmap,
177 gconstpointer key_a,
178 gconstpointer key_b);
179 void (*fontset_key_substitute)(PangoFcFontMap *fontmap,
180
181 PangoFcFontsetKey *fontsetkey,
182 FcPattern *pattern);
183 PangoFcFont *(*create_font) (PangoFcFontMap *fontmap,
184 PangoFcFontKey *fontkey);
185 /*< private >*/
186
187 /* Padding for future expansion */
188 void (*_pango_reserved1) (void);
189 void (*_pango_reserved2) (void);
190 void (*_pango_reserved3) (void);
191 void (*_pango_reserved4) (void);
192};
193
194PangoFontDescription *font_description_from_pattern (FcPattern *pattern,
195 gboolean include_size,
196 gboolean shallow);
197
198G_END_DECLS
199
200#endif /* __PANGO_FC_FONT_MAP_PRIVATE_H__ */
201

source code of gtk/subprojects/pango/pango/pangofc-fontmap-private.h