pango 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/pango/extconf.rb +3 -0
- data/ext/pango/rbpango.c +312 -12
- data/ext/pango/rbpango.h +33 -22
- data/ext/pango/rbpangoanalysis.c +98 -58
- data/ext/pango/rbpangoattribute.c +94 -85
- data/ext/pango/rbpangoattriterator.c +39 -28
- data/ext/pango/rbpangoattrlist.c +42 -32
- data/ext/pango/rbpangocairo.c +38 -172
- data/ext/pango/rbpangocairocontext.c +151 -0
- data/ext/pango/rbpangocolor.c +49 -38
- data/ext/pango/rbpangocontext.c +109 -102
- data/ext/pango/rbpangoconversions.h +111 -0
- data/ext/pango/rbpangocoverage.c +45 -37
- data/ext/pango/rbpangoengine.c +22 -12
- data/ext/pango/rbpangofont.c +52 -43
- data/ext/pango/rbpangofontdescription.c +102 -91
- data/ext/pango/rbpangofontface.c +32 -21
- data/ext/pango/rbpangofontfamily.c +31 -20
- data/ext/pango/rbpangofontmap.c +44 -36
- data/ext/pango/rbpangofontmetrics.c +41 -30
- data/ext/pango/rbpangofontset.c +32 -21
- data/ext/pango/rbpangofontsetsimple.c +34 -24
- data/ext/pango/rbpangoglyphinfo.c +48 -35
- data/ext/pango/rbpangoglyphitem.c +43 -33
- data/ext/pango/rbpangoglyphstring.c +59 -59
- data/ext/pango/rbpangogravity.c +34 -23
- data/ext/pango/rbpangoitem.c +43 -34
- data/ext/pango/rbpangolanguage.c +44 -34
- data/ext/pango/rbpangolayout.c +167 -160
- data/ext/pango/rbpangolayoutiter.c +70 -59
- data/ext/pango/rbpangolayoutline.c +106 -71
- data/ext/pango/rbpangologattr.c +42 -31
- data/ext/pango/rbpangomatrix.c +47 -35
- data/ext/pango/rbpangoprivate.h +53 -0
- data/ext/pango/rbpangorectangle.c +58 -49
- data/ext/pango/rbpangorenderer.c +81 -70
- data/ext/pango/rbpangoscript.c +37 -27
- data/ext/pango/rbpangoscriptiter.c +32 -22
- data/ext/pango/rbpangotabarray.c +48 -37
- metadata +12 -12
- data/ChangeLog +0 -721
- data/ext/pango/rbpangoinits.c +0 -72
- data/ext/pango/rbpangomain.c +0 -202
data/ext/pango/extconf.rb
CHANGED
@@ -30,6 +30,9 @@ rescue LoadError
|
|
30
30
|
require 'mkmf-gnome2'
|
31
31
|
end
|
32
32
|
|
33
|
+
ruby_header = "ruby.h"
|
34
|
+
have_func("rb_errinfo", ruby_header)
|
35
|
+
|
33
36
|
["glib2"].each do |package|
|
34
37
|
directory = "#{package}#{version_suffix}"
|
35
38
|
build_dir = "#{directory}/tmp/#{RUBY_PLATFORM}/#{package}/#{RUBY_VERSION}"
|
data/ext/pango/rbpango.c
CHANGED
@@ -1,27 +1,327 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2002-2005 Masao Mutoh
|
5
|
+
*
|
6
|
+
* This library is free software; you can redistribute it and/or
|
7
|
+
* modify it under the terms of the GNU Lesser General Public
|
8
|
+
* License as published by the Free Software Foundation; either
|
9
|
+
* version 2.1 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
|
+
* Lesser General Public License for more details.
|
15
|
+
*
|
16
|
+
* You should have received a copy of the GNU Lesser General Public
|
17
|
+
* License along with this library; if not, write to the Free Software
|
18
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
+
* MA 02110-1301 USA
|
20
|
+
*/
|
3
21
|
|
4
|
-
|
22
|
+
#include "rbpangoprivate.h"
|
5
23
|
|
6
|
-
|
7
|
-
$Date: 2005/09/28 18:04:21 $
|
24
|
+
#define RG_TARGET_NAMESPACE mPango
|
8
25
|
|
9
|
-
|
10
|
-
************************************************/
|
26
|
+
VALUE RG_TARGET_NAMESPACE;
|
11
27
|
|
12
|
-
|
28
|
+
extern void Init_pango(void);
|
13
29
|
|
14
|
-
|
30
|
+
/*
|
31
|
+
* Rendering
|
32
|
+
*/
|
33
|
+
|
34
|
+
struct rpango_reorder_items_args {
|
35
|
+
PangoItem *item;
|
36
|
+
VALUE ary;
|
37
|
+
long n;
|
38
|
+
GList *result;
|
39
|
+
};
|
40
|
+
|
41
|
+
static VALUE
|
42
|
+
rpango_reorder_items_body(VALUE value)
|
43
|
+
{
|
44
|
+
struct rpango_reorder_items_args *args = (struct rpango_reorder_items_args *)value;
|
45
|
+
long i;
|
46
|
+
GList *result;
|
47
|
+
|
48
|
+
for (i = 0; i < args->n; i++)
|
49
|
+
args->result = g_list_append(args->result,
|
50
|
+
RVAL2PANGOITEM(RARRAY_PTR(args->ary)[i]));
|
51
|
+
|
52
|
+
result = pango_reorder_items(args->result);
|
53
|
+
g_list_free(args->result);
|
54
|
+
|
55
|
+
return GLIST2ARY2(result, PANGO_TYPE_ITEM);
|
56
|
+
}
|
57
|
+
|
58
|
+
static VALUE
|
59
|
+
rpango_reorder_items_ensure(VALUE value)
|
60
|
+
{
|
61
|
+
g_list_free(((struct rpango_reorder_items_args *)value)->result);
|
62
|
+
|
63
|
+
return Qnil;
|
64
|
+
}
|
65
|
+
|
66
|
+
static VALUE
|
67
|
+
rg_m_reorder_items(G_GNUC_UNUSED VALUE self, VALUE attrs)
|
68
|
+
{
|
69
|
+
struct rpango_reorder_items_args args;
|
70
|
+
args.ary = rb_ary_to_ary(attrs);
|
71
|
+
args.n = RARRAY_LEN(args.ary);
|
72
|
+
args.result = NULL;
|
73
|
+
|
74
|
+
return rb_ensure(rpango_reorder_items_body, (VALUE)&args,
|
75
|
+
rpango_reorder_items_ensure, (VALUE)&args);
|
76
|
+
}
|
77
|
+
|
78
|
+
#if PANGO_CHECK_VERSION(1,4,0)
|
79
|
+
static VALUE
|
80
|
+
rg_m_unichar_direction(G_GNUC_UNUSED VALUE self, VALUE ch)
|
81
|
+
{
|
82
|
+
return PANGODIRECTION2RVAL(pango_unichar_direction(NUM2UINT(ch)));
|
83
|
+
}
|
84
|
+
|
85
|
+
static VALUE
|
86
|
+
rg_m_find_base_dir(G_GNUC_UNUSED VALUE self, VALUE text)
|
87
|
+
{
|
88
|
+
StringValue(text);
|
89
|
+
return PANGODIRECTION2RVAL(pango_find_base_dir(RSTRING_PTR(text), RSTRING_LEN(text)));
|
90
|
+
}
|
91
|
+
#endif
|
92
|
+
|
93
|
+
struct rbg_pangologattrs2rval_free_args {
|
94
|
+
PangoLogAttr *attrs;
|
95
|
+
long n;
|
96
|
+
};
|
97
|
+
|
98
|
+
static VALUE
|
99
|
+
rbg_pangologattrs2rval_free_body(VALUE value)
|
100
|
+
{
|
101
|
+
struct rbg_pangologattrs2rval_free_args *args = (struct rbg_pangologattrs2rval_free_args *)value;
|
102
|
+
long i;
|
103
|
+
VALUE ary = rb_ary_new();
|
104
|
+
|
105
|
+
for (i = 0; i < args->n; i++)
|
106
|
+
rb_ary_push(ary, PANGOLOGATTR2RVAL(&args->attrs[i]));
|
107
|
+
|
108
|
+
return ary;
|
109
|
+
}
|
110
|
+
|
111
|
+
static VALUE
|
112
|
+
rbg_pangologattrs2rval_free_ensure(VALUE value)
|
113
|
+
{
|
114
|
+
g_free(((struct rbg_pangologattrs2rval_free_args *)value)->attrs);
|
115
|
+
|
116
|
+
return Qnil;
|
117
|
+
}
|
118
|
+
|
119
|
+
static VALUE
|
120
|
+
rbg_pangologattrs2rval_free(PangoLogAttr *attrs, long n)
|
121
|
+
{
|
122
|
+
struct rbg_pangologattrs2rval_free_args args = { attrs, n };
|
123
|
+
|
124
|
+
return rb_ensure(rbg_pangologattrs2rval_free_body, (VALUE)&args,
|
125
|
+
rbg_pangologattrs2rval_free_ensure, (VALUE)&args);
|
126
|
+
}
|
127
|
+
|
128
|
+
#define PANGOLOGATTRS2RVAL_FREE(attrs, n) rbg_pangologattrs2rval_free(attrs, n)
|
129
|
+
|
130
|
+
static VALUE
|
131
|
+
rg_m_break(G_GNUC_UNUSED VALUE self, VALUE rbtext, VALUE rbanalysis)
|
132
|
+
{
|
133
|
+
const gchar *text = RVAL2CSTR(rbtext);
|
134
|
+
long length = RSTRING_LEN(rbtext);
|
135
|
+
PangoAnalysis *analysis = RVAL2PANGOANALYSIS(rbanalysis);
|
136
|
+
long n = g_utf8_strlen(text, length) + 1;
|
137
|
+
PangoLogAttr *attrs = g_new(PangoLogAttr, n);
|
138
|
+
|
139
|
+
pango_break(text, length, analysis, attrs, n);
|
140
|
+
|
141
|
+
return PANGOLOGATTRS2RVAL_FREE(attrs, n);
|
142
|
+
}
|
143
|
+
|
144
|
+
static VALUE
|
145
|
+
rg_m_get_log_attrs(G_GNUC_UNUSED VALUE self, VALUE rbtext, VALUE rblevel, VALUE rblanguage)
|
146
|
+
{
|
147
|
+
const gchar *text = RVAL2CSTR(rbtext);
|
148
|
+
long length = RSTRING_LEN(rbtext);
|
149
|
+
int level = NUM2INT(rblevel);
|
150
|
+
PangoLanguage *language = RVAL2PANGOLANGUAGE(rblanguage);
|
151
|
+
long n = g_utf8_strlen(text, length) + 1;
|
152
|
+
PangoLogAttr *attrs = g_new(PangoLogAttr, n);
|
153
|
+
|
154
|
+
pango_get_log_attrs(text, length, level, language, attrs, n);
|
155
|
+
|
156
|
+
return PANGOLOGATTRS2RVAL_FREE(attrs, n);
|
157
|
+
}
|
158
|
+
|
159
|
+
static VALUE
|
160
|
+
rg_m_find_paragraph_boundary(G_GNUC_UNUSED VALUE self, VALUE text)
|
161
|
+
{
|
162
|
+
gint paragraph_delimiter_index, next_paragraph_start;
|
163
|
+
|
164
|
+
StringValue(text);
|
165
|
+
pango_find_paragraph_boundary(RSTRING_PTR(text), RSTRING_LEN(text),
|
166
|
+
¶graph_delimiter_index,
|
167
|
+
&next_paragraph_start);
|
168
|
+
return rb_ary_new3(2, INT2NUM(paragraph_delimiter_index),
|
169
|
+
INT2NUM(next_paragraph_start));
|
170
|
+
}
|
171
|
+
|
172
|
+
/*
|
173
|
+
Don't need to implement this. Use pango_break instead.
|
174
|
+
void pango_default_break (const gchar *text,
|
175
|
+
int length,
|
176
|
+
PangoAnalysis *analysis,
|
177
|
+
PangoLogAttr *attrs,
|
178
|
+
int attrs_len);
|
179
|
+
*/
|
180
|
+
|
181
|
+
static VALUE
|
182
|
+
rpango_shape_result(VALUE value)
|
183
|
+
{
|
184
|
+
return PANGOGLYPHSTRING2RVAL((PangoGlyphString *)value);
|
185
|
+
}
|
186
|
+
|
187
|
+
static VALUE
|
188
|
+
rpango_shape_ensure(VALUE value)
|
189
|
+
{
|
190
|
+
pango_glyph_string_free((PangoGlyphString *)value);
|
191
|
+
|
192
|
+
return Qnil;
|
193
|
+
}
|
194
|
+
|
195
|
+
static VALUE
|
196
|
+
rg_m_shape(G_GNUC_UNUSED VALUE self, VALUE rbtext, VALUE rbanalysis)
|
197
|
+
{
|
198
|
+
const gchar *text = RVAL2CSTR(rbtext);
|
199
|
+
long length = RSTRING_LEN(rbtext);
|
200
|
+
PangoAnalysis *analysis = RVAL2PANGOANALYSIS(rbanalysis);
|
201
|
+
PangoGlyphString *glyphs = pango_glyph_string_new();
|
202
|
+
|
203
|
+
pango_shape(text, length, analysis, glyphs);
|
204
|
+
|
205
|
+
return rb_ensure(rpango_shape_result, (VALUE)glyphs,
|
206
|
+
rpango_shape_ensure, (VALUE)glyphs);
|
207
|
+
}
|
208
|
+
|
209
|
+
/* This method is from rbpangoattribute.c */
|
210
|
+
static VALUE
|
211
|
+
rg_m_parse_markup(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
|
212
|
+
{
|
213
|
+
VALUE markup_text, accel_marker;
|
214
|
+
PangoAttrList *pattr_list;
|
215
|
+
gchar* gtext;
|
216
|
+
gunichar accel_char;
|
217
|
+
GError *error = NULL;
|
218
|
+
gboolean ret;
|
219
|
+
char c;
|
220
|
+
VALUE text = Qnil;
|
221
|
+
VALUE attr_list = Qnil;
|
222
|
+
|
223
|
+
rb_scan_args(argc, argv, "11", &markup_text, &accel_marker);
|
224
|
+
|
225
|
+
if (NIL_P(markup_text)) rb_raise(rb_eRuntimeError, "1st argument can't accept nil");
|
226
|
+
|
227
|
+
StringValue(markup_text);
|
228
|
+
ret = pango_parse_markup(RSTRING_PTR(markup_text),
|
229
|
+
RSTRING_LEN(markup_text),
|
230
|
+
NIL_P(accel_marker) ? 0 : NUM2CHR(accel_marker),
|
231
|
+
&pattr_list, >ext, &accel_char, &error);
|
232
|
+
|
233
|
+
if (!ret) RAISE_GERROR(error);
|
234
|
+
|
235
|
+
if (pattr_list){
|
236
|
+
attr_list = PANGOATTRLIST2RVAL(pattr_list);
|
237
|
+
pango_attr_list_unref(pattr_list);
|
238
|
+
}
|
239
|
+
|
240
|
+
c = (char)accel_char;
|
241
|
+
if (text){
|
242
|
+
text = CSTR2RVAL(gtext);
|
243
|
+
g_free(gtext);
|
244
|
+
}
|
245
|
+
return rb_ary_new3(3, attr_list, text,
|
246
|
+
accel_char ? rb_str_new(&c, 1) : Qnil);
|
247
|
+
}
|
248
|
+
|
249
|
+
static VALUE
|
250
|
+
rg_m_pixels(G_GNUC_UNUSED VALUE self, VALUE pixels)
|
251
|
+
{
|
252
|
+
return rb_float_new(PANGO_PIXELS(NUM2DBL(pixels)));
|
253
|
+
}
|
254
|
+
|
255
|
+
static VALUE
|
256
|
+
rg_m_cairo_available_p(G_GNUC_UNUSED VALUE self)
|
257
|
+
{
|
258
|
+
#ifdef CAIRO_AVAILABLE
|
259
|
+
return Qtrue;
|
260
|
+
#else
|
261
|
+
return Qfalse;
|
262
|
+
#endif
|
263
|
+
}
|
15
264
|
|
16
265
|
void
|
17
|
-
Init_pango()
|
266
|
+
Init_pango(void)
|
18
267
|
{
|
19
|
-
|
268
|
+
RG_TARGET_NAMESPACE = rb_define_module("Pango");
|
20
269
|
|
21
|
-
rb_define_const(
|
270
|
+
rb_define_const(RG_TARGET_NAMESPACE, "BUILD_VERSION",
|
22
271
|
rb_ary_new3(3,
|
23
272
|
INT2FIX(PANGO_MAJOR_VERSION),
|
24
273
|
INT2FIX(PANGO_MINOR_VERSION),
|
25
274
|
INT2FIX(PANGO_MICRO_VERSION)));
|
26
|
-
|
275
|
+
|
276
|
+
RG_DEF_MODFUNC(reorder_items, 1);
|
277
|
+
|
278
|
+
#if PANGO_CHECK_VERSION(1,4,0)
|
279
|
+
RG_DEF_MODFUNC(unichar_direction, 1);
|
280
|
+
RG_DEF_MODFUNC(find_base_dir, 1);
|
281
|
+
#endif
|
282
|
+
RG_DEF_MODFUNC(break, 2);
|
283
|
+
RG_DEF_MODFUNC(get_log_attrs, 3);
|
284
|
+
RG_DEF_MODFUNC(find_paragraph_boundary, 1);
|
285
|
+
RG_DEF_MODFUNC(shape, 2);
|
286
|
+
RG_DEF_MODFUNC(parse_markup, -1);
|
287
|
+
RG_DEF_MODFUNC(pixels, 1);
|
288
|
+
|
289
|
+
rb_define_const(RG_TARGET_NAMESPACE, "SCALE", INT2FIX(PANGO_SCALE));
|
290
|
+
|
291
|
+
RG_DEF_MODFUNC_P(cairo_available, 0);
|
292
|
+
|
293
|
+
Init_pango_analysis(RG_TARGET_NAMESPACE);
|
294
|
+
Init_pango_attribute(RG_TARGET_NAMESPACE);
|
295
|
+
Init_pango_attriterator(RG_TARGET_NAMESPACE);
|
296
|
+
Init_pango_attrlist(RG_TARGET_NAMESPACE);
|
297
|
+
Init_pango_cairo(RG_TARGET_NAMESPACE);
|
298
|
+
Init_pango_cairo_context(RG_TARGET_NAMESPACE);
|
299
|
+
Init_pango_color(RG_TARGET_NAMESPACE);
|
300
|
+
Init_pango_context(RG_TARGET_NAMESPACE);
|
301
|
+
Init_pango_coverage(RG_TARGET_NAMESPACE);
|
302
|
+
Init_pango_engine(RG_TARGET_NAMESPACE);
|
303
|
+
Init_pango_font(RG_TARGET_NAMESPACE);
|
304
|
+
Init_pango_font_description(RG_TARGET_NAMESPACE);
|
305
|
+
Init_pango_font_face(RG_TARGET_NAMESPACE);
|
306
|
+
Init_pango_font_family(RG_TARGET_NAMESPACE);
|
307
|
+
Init_pango_font_map(RG_TARGET_NAMESPACE);
|
308
|
+
Init_pango_font_metrics(RG_TARGET_NAMESPACE);
|
309
|
+
Init_pango_fontset(RG_TARGET_NAMESPACE);
|
310
|
+
Init_pango_fontset_simple(RG_TARGET_NAMESPACE);
|
311
|
+
Init_pango_glyph_info(RG_TARGET_NAMESPACE);
|
312
|
+
Init_pango_glyph_item(RG_TARGET_NAMESPACE);
|
313
|
+
Init_pango_glyph_string(RG_TARGET_NAMESPACE);
|
314
|
+
Init_pango_gravity(RG_TARGET_NAMESPACE);
|
315
|
+
Init_pango_item(RG_TARGET_NAMESPACE);
|
316
|
+
Init_pango_language(RG_TARGET_NAMESPACE);
|
317
|
+
Init_pango_layout(RG_TARGET_NAMESPACE);
|
318
|
+
Init_pango_layout_iter(RG_TARGET_NAMESPACE);
|
319
|
+
Init_pango_layout_line(RG_TARGET_NAMESPACE);
|
320
|
+
Init_pango_logattr(RG_TARGET_NAMESPACE);
|
321
|
+
Init_pango_matrix(RG_TARGET_NAMESPACE);
|
322
|
+
Init_pango_rectangle(RG_TARGET_NAMESPACE);
|
323
|
+
Init_pangorenderer(RG_TARGET_NAMESPACE);
|
324
|
+
Init_pango_script(RG_TARGET_NAMESPACE);
|
325
|
+
Init_pango_script_iter(RG_TARGET_NAMESPACE);
|
326
|
+
Init_pango_array(RG_TARGET_NAMESPACE);
|
27
327
|
}
|
data/ext/pango/rbpango.h
CHANGED
@@ -1,29 +1,40 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2002-2005 Masao Mutoh
|
5
|
+
*
|
6
|
+
* This library is free software; you can redistribute it and/or
|
7
|
+
* modify it under the terms of the GNU Lesser General Public
|
8
|
+
* License as published by the Free Software Foundation; either
|
9
|
+
* version 2.1 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
|
+
* Lesser General Public License for more details.
|
15
|
+
*
|
16
|
+
* You should have received a copy of the GNU Lesser General Public
|
17
|
+
* License along with this library; if not, write to the Free Software
|
18
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
+
* MA 02110-1301 USA
|
20
|
+
*/
|
11
21
|
|
12
22
|
#include "ruby.h"
|
13
23
|
#define PANGO_ENABLE_ENGINE
|
14
24
|
#define PANGO_ENABLE_BACKEND
|
15
25
|
#include <pango/pango.h>
|
16
26
|
|
17
|
-
#
|
27
|
+
#ifdef HAVE_FREETYPE2
|
18
28
|
#include <pango/pangofc-font.h>
|
19
29
|
#endif
|
20
30
|
|
21
31
|
#include "rbgobject.h"
|
22
32
|
#include "rbpangoversion.h"
|
33
|
+
#include "rbpangoconversions.h"
|
23
34
|
|
24
35
|
#if PANGO_CHECK_VERSION(1,10,0)
|
25
36
|
#include <pango/pangocairo.h>
|
26
|
-
#
|
37
|
+
# ifdef HAVE_RB_CAIRO_H
|
27
38
|
#include <rb_cairo.h>
|
28
39
|
# endif
|
29
40
|
#endif
|
@@ -72,21 +83,21 @@ RUBY_PANGO_VAR VALUE mPango;
|
|
72
83
|
extern VALUE pango_make_attribute(PangoAttribute* attr);
|
73
84
|
extern PangoAttribute* pango_get_attribute(VALUE attr);
|
74
85
|
|
75
|
-
extern GType pango_item_get_type();
|
76
|
-
extern GType pango_analysis_get_type();
|
77
|
-
extern GType pango_log_attr_get_type();
|
78
|
-
extern GType pango_layout_iter_get_type();
|
79
|
-
extern GType pango_layout_line_get_type();
|
80
|
-
extern GType pango_rectangle_get_type();
|
81
|
-
extern GType pango_attr_iter_get_type();
|
82
|
-
extern GType pango_coverage_get_type();
|
83
|
-
extern GType pango_glyph_info_get_type();
|
86
|
+
extern GType pango_item_get_type(void);
|
87
|
+
extern GType pango_analysis_get_type(void);
|
88
|
+
extern GType pango_log_attr_get_type(void);
|
89
|
+
extern GType pango_layout_iter_get_type(void);
|
90
|
+
extern GType pango_layout_line_get_type(void);
|
91
|
+
extern GType pango_rectangle_get_type(void);
|
92
|
+
extern GType pango_attr_iter_get_type(void);
|
93
|
+
extern GType pango_coverage_get_type(void);
|
94
|
+
extern GType pango_glyph_info_get_type(void);
|
84
95
|
#ifndef HAVE_PANGO_GLYPH_ITEM_GET_TYPE
|
85
|
-
extern GType pango_glyph_item_get_type();
|
96
|
+
extern GType pango_glyph_item_get_type(void);
|
86
97
|
#endif
|
87
98
|
|
88
99
|
#if PANGO_CHECK_VERSION(1,4,0)
|
89
|
-
extern GType pango_script_iter_get_type();
|
100
|
+
extern GType pango_script_iter_get_type(void);
|
90
101
|
#endif
|
91
102
|
|
92
103
|
extern VALUE pango_get_attribute_klass(VALUE attr_type);
|
data/ext/pango/rbpangoanalysis.c
CHANGED
@@ -1,17 +1,28 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2003-2005 Masao Mutoh
|
5
|
+
*
|
6
|
+
* This library is free software; you can redistribute it and/or
|
7
|
+
* modify it under the terms of the GNU Lesser General Public
|
8
|
+
* License as published by the Free Software Foundation; either
|
9
|
+
* version 2.1 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
|
+
* Lesser General Public License for more details.
|
15
|
+
*
|
16
|
+
* You should have received a copy of the GNU Lesser General Public
|
17
|
+
* License along with this library; if not, write to the Free Software
|
18
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
+
* MA 02110-1301 USA
|
20
|
+
*/
|
21
|
+
|
22
|
+
#include "rbpangoprivate.h"
|
23
|
+
|
24
|
+
#define RG_TARGET_NAMESPACE cAnalysis
|
25
|
+
#define _SELF(s) (RVAL2PANGOANALYSIS(s))
|
15
26
|
|
16
27
|
/**********************************/
|
17
28
|
static PangoAnalysis*
|
@@ -23,12 +34,12 @@ ana_copy(const PangoAnalysis* val)
|
|
23
34
|
*new_val = *val;
|
24
35
|
return new_val;
|
25
36
|
}
|
26
|
-
|
37
|
+
|
27
38
|
GType
|
28
39
|
pango_analysis_get_type(void)
|
29
40
|
{
|
30
41
|
static GType our_type = 0;
|
31
|
-
|
42
|
+
|
32
43
|
if (our_type == 0)
|
33
44
|
our_type = g_boxed_type_register_static ("PangoAnalysis",
|
34
45
|
(GBoxedCopyFunc)ana_copy,
|
@@ -38,22 +49,22 @@ pango_analysis_get_type(void)
|
|
38
49
|
/**********************************/
|
39
50
|
|
40
51
|
static VALUE
|
41
|
-
|
52
|
+
rg_initialize(VALUE self)
|
42
53
|
{
|
43
|
-
PangoAnalysis ana = { NULL, NULL, NULL, 0 };
|
54
|
+
PangoAnalysis ana = { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL };
|
44
55
|
G_INITIALIZE(self, &ana);
|
45
56
|
return Qnil;
|
46
57
|
}
|
47
58
|
|
48
59
|
#if PANGO_CHECK_VERSION(1,4,0)
|
49
60
|
static VALUE
|
50
|
-
|
61
|
+
rg_set_shape_engine(VALUE self, VALUE engine)
|
51
62
|
{
|
52
|
-
_SELF(self)->shape_engine =
|
63
|
+
_SELF(self)->shape_engine = RVAL2PANGOENGINESHAPE(engine);
|
53
64
|
return self;
|
54
65
|
}
|
55
66
|
static VALUE
|
56
|
-
|
67
|
+
rg_shape_engine(VALUE self)
|
57
68
|
{
|
58
69
|
VALUE ret;
|
59
70
|
if (_SELF(self)->shape_engine){
|
@@ -69,13 +80,13 @@ ana_get_shape_engine(VALUE self)
|
|
69
80
|
}
|
70
81
|
|
71
82
|
static VALUE
|
72
|
-
|
83
|
+
rg_set_lang_engine(VALUE self, VALUE engine)
|
73
84
|
{
|
74
|
-
_SELF(self)->lang_engine =
|
85
|
+
_SELF(self)->lang_engine = RVAL2PANGOENGINELANG(engine);
|
75
86
|
return self;
|
76
87
|
}
|
77
88
|
static VALUE
|
78
|
-
|
89
|
+
rg_lang_engine(VALUE self)
|
79
90
|
{
|
80
91
|
VALUE ret;
|
81
92
|
if (_SELF(self)->lang_engine){
|
@@ -92,61 +103,90 @@ ana_get_lang_engine(VALUE self)
|
|
92
103
|
#endif
|
93
104
|
|
94
105
|
static VALUE
|
95
|
-
|
106
|
+
rg_set_font(VALUE self, VALUE font)
|
96
107
|
{
|
97
|
-
_SELF(self)->font =
|
108
|
+
_SELF(self)->font = RVAL2PANGOFONT(font);
|
98
109
|
return self;
|
99
110
|
}
|
100
111
|
|
101
112
|
static VALUE
|
102
|
-
|
113
|
+
rg_font(VALUE self)
|
103
114
|
{
|
104
115
|
return GOBJ2RVAL(_SELF(self)->font);
|
105
116
|
}
|
106
117
|
|
107
118
|
static VALUE
|
108
|
-
|
119
|
+
rg_set_level(VALUE self, VALUE level)
|
109
120
|
{
|
110
121
|
_SELF(self)->level = NUM2UINT(level);
|
111
122
|
return self;
|
112
123
|
}
|
113
124
|
|
114
125
|
static VALUE
|
115
|
-
|
126
|
+
rg_level(VALUE self)
|
116
127
|
{
|
117
128
|
return UINT2NUM(_SELF(self)->level);
|
118
129
|
}
|
119
130
|
|
120
131
|
static VALUE
|
121
|
-
|
132
|
+
rg_set_language(VALUE self, VALUE lang)
|
122
133
|
{
|
123
|
-
_SELF(self)->language =
|
134
|
+
_SELF(self)->language = RVAL2PANGOLANGUAGE(lang);
|
124
135
|
return self;
|
125
136
|
}
|
126
137
|
|
127
138
|
static VALUE
|
128
|
-
|
139
|
+
rg_language(VALUE self)
|
129
140
|
{
|
130
|
-
return
|
141
|
+
return PANGOLANGUAGE2RVAL(_SELF(self)->language);
|
131
142
|
}
|
132
143
|
|
144
|
+
struct ana_set_extra_attrs_args {
|
145
|
+
PangoAnalysis *analysis;
|
146
|
+
VALUE ary;
|
147
|
+
long n;
|
148
|
+
GSList *result;
|
149
|
+
};
|
150
|
+
|
133
151
|
static VALUE
|
134
|
-
|
152
|
+
ana_set_extra_attrs_body(VALUE value)
|
135
153
|
{
|
136
|
-
|
137
|
-
|
138
|
-
GSList* gattrs = NULL;
|
154
|
+
struct ana_set_extra_attrs_args *args = (struct ana_set_extra_attrs_args *)value;
|
155
|
+
long i;
|
139
156
|
|
140
|
-
for (i = 0; i <
|
141
|
-
|
142
|
-
|
157
|
+
for (i = 0; i < args->n; i++)
|
158
|
+
args->result = g_slist_append(args->result, RVAL2ATTR(RARRAY_PTR(args->ary)[i]));
|
159
|
+
|
160
|
+
args->analysis->extra_attrs = args->result;
|
161
|
+
|
162
|
+
return Qnil;
|
163
|
+
}
|
164
|
+
|
165
|
+
static G_GNUC_NORETURN VALUE
|
166
|
+
ana_set_extra_attrs_rescue(VALUE value)
|
167
|
+
{
|
168
|
+
g_slist_free(((struct ana_set_extra_attrs_args *)value)->result);
|
169
|
+
|
170
|
+
rb_exc_raise(rb_errinfo());
|
171
|
+
}
|
172
|
+
|
173
|
+
static VALUE
|
174
|
+
rg_set_extra_attrs(VALUE self, VALUE attrs)
|
175
|
+
{
|
176
|
+
struct ana_set_extra_attrs_args args;
|
177
|
+
args.analysis = _SELF(self);
|
178
|
+
args.ary = rb_ary_to_ary(attrs);
|
179
|
+
args.n = RARRAY_LEN(args.ary);
|
180
|
+
args.result = NULL;
|
181
|
+
|
182
|
+
rb_rescue(ana_set_extra_attrs_body, (VALUE)&args,
|
183
|
+
ana_set_extra_attrs_rescue, (VALUE)&args);
|
143
184
|
|
144
|
-
_SELF(self)->extra_attrs = gattrs;
|
145
185
|
return self;
|
146
186
|
}
|
147
187
|
|
148
188
|
static VALUE
|
149
|
-
|
189
|
+
rg_extra_attrs(VALUE self)
|
150
190
|
{
|
151
191
|
VALUE ary = rb_ary_new();
|
152
192
|
GSList* list = _SELF(self)->extra_attrs;
|
@@ -159,26 +199,26 @@ ana_get_extra_attrs(VALUE self)
|
|
159
199
|
}
|
160
200
|
|
161
201
|
void
|
162
|
-
Init_pango_analysis()
|
202
|
+
Init_pango_analysis(VALUE mPango)
|
163
203
|
{
|
164
|
-
VALUE
|
165
|
-
|
166
|
-
|
204
|
+
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(PANGO_TYPE_ANALYSIS, "Analysis", mPango);
|
205
|
+
|
206
|
+
RG_DEF_METHOD(initialize, 0);
|
167
207
|
#if PANGO_CHECK_VERSION(1,4,0)
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
208
|
+
RG_DEF_METHOD(set_shape_engine, 1);
|
209
|
+
RG_DEF_METHOD(shape_engine, 0);
|
210
|
+
RG_DEF_METHOD(set_lang_engine, 1);
|
211
|
+
RG_DEF_METHOD(lang_engine, 0);
|
172
212
|
#endif
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
213
|
+
RG_DEF_METHOD(set_font, 1);
|
214
|
+
RG_DEF_METHOD(font, 0);
|
215
|
+
RG_DEF_METHOD(set_level, 1);
|
216
|
+
RG_DEF_METHOD(level, 0);
|
217
|
+
RG_DEF_METHOD(set_language, 1);
|
218
|
+
RG_DEF_METHOD(language, 0);
|
179
219
|
|
180
|
-
|
181
|
-
|
220
|
+
RG_DEF_METHOD(set_extra_attrs, 1);
|
221
|
+
RG_DEF_METHOD(extra_attrs, 0);
|
182
222
|
|
183
|
-
G_DEF_SETTERS(
|
223
|
+
G_DEF_SETTERS(RG_TARGET_NAMESPACE);
|
184
224
|
}
|