1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
/* Pango
* pangatsui.c
*
* Copyright (C) 2005-2007 Imendio AB
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "pangoatsui.h"
#include "pangoatsui-private.h"
G_DEFINE_TYPE (PangoATSUIFont, pango_atsui_font, PANGO_TYPE_FONT);
struct _PangoATSUIFontPrivate
{
PangoATSUIFace *face;
PangoFontDescription *desc;
gpointer context_key;
CGFontRef font_id;
ATSFontRef font_ref;
PangoFontMap *fontmap;
};
static void
pango_atsui_font_finalize (GObject *object)
{
PangoATSUIFont *afont = (PangoATSUIFont *)object;
PangoATSUIFontPrivate *priv = afont->priv;
pango_font_description_free (priv->desc);
g_assert (priv->fontmap != NULL);
g_object_remove_weak_pointer (G_OBJECT (priv->fontmap), (gpointer *) (gpointer) &priv->fontmap);
priv->fontmap = NULL;
G_OBJECT_CLASS (pango_atsui_font_parent_class)->finalize (object);
}
static PangoFontDescription *
pango_atsui_font_describe (PangoFont *font)
{
PangoATSUIFont *afont = (PangoATSUIFont *)font;
PangoATSUIFontPrivate *priv = afont->priv;
return pango_font_description_copy (priv->desc);
}
static PangoCoverage *
pango_atsui_font_get_coverage (PangoFont *font,
PangoLanguage *language)
{
PangoATSUIFont *afont = (PangoATSUIFont *)font;
PangoATSUIFontPrivate *priv = afont->priv;
return pango_coverage_ref (_pango_atsui_face_get_coverage (priv->face,
language));
}
static PangoEngineShape *
pango_atsui_font_find_shaper (PangoFont *font,
PangoLanguage *language,
guint32 ch)
{
/* FIXME: Implement */
return NULL;
}
static PangoFontMap *
pango_atsui_font_get_font_map (PangoFont *font)
{
PangoATSUIFont *afont = (PangoATSUIFont *)font;
return afont->priv->fontmap;
}
static void
pango_atsui_font_init (PangoATSUIFont *afont)
{
afont->priv = G_TYPE_INSTANCE_GET_PRIVATE (afont,
PANGO_TYPE_ATSUI_FONT,
PangoATSUIFontPrivate);
}
static void
pango_atsui_font_class_init (PangoATSUIFontClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
PangoFontClass *font_class = PANGO_FONT_CLASS (class);
object_class->finalize = pango_atsui_font_finalize;
font_class->describe = pango_atsui_font_describe;
font_class->get_coverage = pango_atsui_font_get_coverage;
font_class->find_shaper = pango_atsui_font_find_shaper;
font_class->get_font_map = pango_atsui_font_get_font_map;
g_type_class_add_private (object_class, sizeof (PangoATSUIFontPrivate));
}
void
_pango_atsui_font_set_font_description (PangoATSUIFont *font,
const PangoFontDescription *desc)
{
PangoATSUIFontPrivate *priv = font->priv;
priv->desc = pango_font_description_copy (desc);
}
PangoFontDescription *
_pango_atsui_font_get_font_description (PangoATSUIFont *font)
{
PangoATSUIFontPrivate *priv = font->priv;
return priv->desc;
}
void
_pango_atsui_font_set_font_map (PangoATSUIFont *font,
PangoATSUIFontMap *fontmap)
{
PangoATSUIFontPrivate *priv = font->priv;
g_assert (priv->fontmap == NULL);
priv->fontmap = (PangoFontMap *) fontmap;
g_object_add_weak_pointer (G_OBJECT (priv->fontmap), (gpointer *) (gpointer) &priv->fontmap);
}
void
_pango_atsui_font_set_face (PangoATSUIFont *afont,
PangoATSUIFace *face)
{
PangoATSUIFontPrivate *priv = afont->priv;
priv->face = face;
}
PangoATSUIFace *
_pango_atsui_font_get_face (PangoATSUIFont *afont)
{
PangoATSUIFontPrivate *priv = afont->priv;
return priv->face;
}
gpointer
_pango_atsui_font_get_context_key (PangoATSUIFont *afont)
{
PangoATSUIFontPrivate *priv = afont->priv;
return priv->context_key;
}
void
_pango_atsui_font_set_context_key (PangoATSUIFont *afont,
gpointer context_key)
{
PangoATSUIFontPrivate *priv = afont->priv;
priv->context_key = context_key;
}
void
_pango_atsui_font_set_cgfont (PangoATSUIFont *font,
CGFontRef font_id)
{
PangoATSUIFontPrivate *priv = font->priv;
priv->font_id = font_id;
}
void
_pango_atsui_font_set_atsfont (PangoATSUIFont *font,
ATSFontRef font_ref)
{
PangoATSUIFontPrivate *priv = font->priv;
priv->font_ref = font_ref;
}
/**
* pango_atsui_font_get_cgfont:
* @font: A #PangoATSUIFont
*
* Returns the CGFontRef of a font.
*
* Return value: the CGFontRef associated to @font.
*
* Since: 1.18
*/
CGFontRef
pango_atsui_font_get_cgfont (PangoATSUIFont *font)
{
PangoATSUIFontPrivate *priv = font->priv;
return priv->font_id;
}
/**
* pango_atsui_font_get_atsfont:
* @font: A #PangoATSUIFont
*
* Returns the ATSFontRef of a font.
*
* Return value: the ATSFontRef associated to @font.
*
* Since: 1.28
*/
ATSFontRef
pango_atsui_font_get_atsfont (PangoATSUIFont *font)
{
PangoATSUIFontPrivate *priv = font->priv;
return priv->font_ref;
}
|