pango 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/ChangeLog +662 -0
  2. data/README +33 -0
  3. data/Rakefile +86 -0
  4. data/extconf.rb +68 -0
  5. data/sample/attribute.rb +82 -0
  6. data/sample/break.rb +26 -0
  7. data/sample/gdk_layout.rb +27 -0
  8. data/sample/glyphstring.rb +61 -0
  9. data/sample/item.rb +35 -0
  10. data/sample/label.rb +23 -0
  11. data/sample/layout.rb +102 -0
  12. data/sample/pango_cairo.rb +66 -0
  13. data/sample/parse.rb +33 -0
  14. data/sample/sample.txt +10 -0
  15. data/sample/script.rb +21 -0
  16. data/src/lib/pango.rb +60 -0
  17. data/src/makeinits.rb +48 -0
  18. data/src/rbpango.c +27 -0
  19. data/src/rbpango.h +97 -0
  20. data/src/rbpangoanalysis.c +197 -0
  21. data/src/rbpangoattribute.c +557 -0
  22. data/src/rbpangoattriterator.c +137 -0
  23. data/src/rbpangoattrlist.c +104 -0
  24. data/src/rbpangocairo.c +229 -0
  25. data/src/rbpangocolor.c +121 -0
  26. data/src/rbpangocontext.c +341 -0
  27. data/src/rbpangocoverage.c +104 -0
  28. data/src/rbpangoengine.c +65 -0
  29. data/src/rbpangofont.c +123 -0
  30. data/src/rbpangofontdescription.c +300 -0
  31. data/src/rbpangofontface.c +71 -0
  32. data/src/rbpangofontfamily.c +74 -0
  33. data/src/rbpangofontmap.c +104 -0
  34. data/src/rbpangofontmetrics.c +85 -0
  35. data/src/rbpangofontset.c +68 -0
  36. data/src/rbpangofontsetsimple.c +53 -0
  37. data/src/rbpangoglyphinfo.c +119 -0
  38. data/src/rbpangoglyphitem.c +129 -0
  39. data/src/rbpangoglyphstring.c +162 -0
  40. data/src/rbpangogravity.c +43 -0
  41. data/src/rbpangoinits.c +71 -0
  42. data/src/rbpangoitem.c +110 -0
  43. data/src/rbpangolanguage.c +88 -0
  44. data/src/rbpangolayout.c +593 -0
  45. data/src/rbpangolayoutiter.c +202 -0
  46. data/src/rbpangolayoutline.c +256 -0
  47. data/src/rbpangologattr.c +107 -0
  48. data/src/rbpangomain.c +213 -0
  49. data/src/rbpangomatrix.c +155 -0
  50. data/src/rbpangorectangle.c +178 -0
  51. data/src/rbpangorenderer.c +204 -0
  52. data/src/rbpangoscript.c +80 -0
  53. data/src/rbpangoscriptiter.c +91 -0
  54. data/src/rbpangotabarray.c +128 -0
  55. data/src/rbpangoversion.h +24 -0
  56. data/test/pango-test-utils.rb +9 -0
  57. data/test/run-test.rb +27 -0
  58. data/test/test-attribute.rb +19 -0
  59. data/test/test-language.rb +7 -0
  60. data/test/test_layout.rb +20 -0
  61. metadata +158 -0
@@ -0,0 +1,71 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangofontface.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2006/12/10 15:13:10 $
8
+
9
+ Copyright (C) 2002,2003 Masao Mutoh <mutoh@highway.ne.jp>
10
+ ************************************************/
11
+
12
+ #include "rbpango.h"
13
+
14
+ #define _SELF(self) (PANGO_FONT_FACE(RVAL2GOBJ(self)))
15
+
16
+ static VALUE
17
+ font_face_get_face_name(self)
18
+ VALUE self;
19
+ {
20
+ return CSTR2RVAL(pango_font_face_get_face_name(_SELF(self)));
21
+ }
22
+
23
+ static VALUE
24
+ font_face_describe(self)
25
+ VALUE self;
26
+ {
27
+ return BOXED2RVAL(pango_font_face_describe(_SELF(self)), PANGO_TYPE_FONT_DESCRIPTION);
28
+ }
29
+
30
+ #if PANGO_CHECK_VERSION(1,4,0)
31
+ static VALUE
32
+ font_face_list_sizes(self)
33
+ VALUE self;
34
+ {
35
+ int n_sizes;
36
+ int* sizes;
37
+ int i;
38
+ VALUE result;
39
+
40
+ pango_font_face_list_sizes(_SELF(self),
41
+ &sizes,
42
+ &n_sizes);
43
+
44
+ result = rb_ary_new();
45
+ for (i = 0; i < n_sizes; i++)
46
+ rb_ary_push(result, GOBJ2RVAL(&sizes[i]));
47
+
48
+ g_free(sizes);
49
+ return result;
50
+ }
51
+ #endif
52
+
53
+ void
54
+ Init_pango_font_face()
55
+ {
56
+ VALUE pFace = G_DEF_CLASS(PANGO_TYPE_FONT_FACE, "FontFace", mPango);
57
+
58
+ rb_define_method(pFace, "name", font_face_get_face_name, 0);
59
+ rb_define_method(pFace, "describe", font_face_describe, 0);
60
+ #if PANGO_CHECK_VERSION(1,4,0)
61
+ rb_define_method(pFace, "sizes", font_face_list_sizes, 0);
62
+ #endif
63
+ G_DEF_CLASS3("PangoFcFace", "FcFace", mPango);
64
+ G_DEF_CLASS3("PangoFT2Face", "FT2Face", mPango);
65
+ G_DEF_CLASS3("PangoXftFace", "XftFace", mPango);
66
+ G_DEF_CLASS3("PangoXFace", "XFace", mPango);
67
+ G_DEF_CLASS3("PangoWin32Face", "Win32Face", mPango);
68
+ #if PANGO_CHECK_VERSION(1,12,0)
69
+ G_DEF_CLASS3("PangoATSUIFace", "ATSUIFace", mPango);
70
+ #endif
71
+ }
@@ -0,0 +1,74 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangofontfamily.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2006/12/10 15:13:10 $
8
+
9
+ Copyright (C) 2002-2005 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbpango.h"
13
+
14
+ #define _SELF(self) (PANGO_FONT_FAMILY(RVAL2GOBJ(self)))
15
+
16
+ static VALUE
17
+ font_family_get_name(self)
18
+ VALUE self;
19
+ {
20
+ return CSTR2RVAL(pango_font_family_get_name(_SELF(self)));
21
+ }
22
+
23
+ #ifdef HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE
24
+ static VALUE
25
+ font_family_is_monospace(self)
26
+ VALUE self;
27
+ {
28
+ return CBOOL2RVAL(pango_font_family_is_monospace(_SELF(self)));
29
+ }
30
+ #endif
31
+
32
+ static VALUE
33
+ font_family_list_faces(self)
34
+ VALUE self;
35
+ {
36
+ int n_faces;
37
+ PangoFontFace** faces;
38
+ int i;
39
+ VALUE result;
40
+
41
+ pango_font_family_list_faces(_SELF(self),
42
+ &faces,
43
+ &n_faces);
44
+
45
+ result = rb_ary_new2(n_faces);
46
+ for (i = 0; i < n_faces; i++)
47
+ rb_ary_store(result, i, GOBJ2RVAL(faces[i]));
48
+
49
+ g_free(faces);
50
+
51
+ return result;
52
+ }
53
+
54
+ void
55
+ Init_pango_font_family()
56
+ {
57
+ VALUE pFamily = G_DEF_CLASS(PANGO_TYPE_FONT_FAMILY, "FontFamily", mPango);
58
+
59
+ rb_define_method(pFamily, "name", font_family_get_name, 0);
60
+ #ifdef HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE
61
+ rb_define_method(pFamily, "monospace?", font_family_is_monospace, 0);
62
+ #endif
63
+ rb_define_method(pFamily, "faces", font_family_list_faces, 0);
64
+
65
+ G_DEF_CLASS3("PangoFcFamily", "FcFamily", mPango);
66
+ G_DEF_CLASS3("PangoFT2Family", "FT2Family", mPango);
67
+ G_DEF_CLASS3("PangoXftFamily", "XftFamily", mPango);
68
+ G_DEF_CLASS3("PangoXFamily", "XFamily", mPango);
69
+ G_DEF_CLASS3("PangoWin32Family", "Win32Family", mPango);
70
+ #if PANGO_CHECK_VERSION(1,12,0)
71
+ G_DEF_CLASS3("PangoATSUIFamily", "ATSUIFamily", mPango);
72
+ #endif
73
+
74
+ }
@@ -0,0 +1,104 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangofontmap.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2006/12/10 15:13:10 $
8
+
9
+ Copyright (C) 2002-2005 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbpango.h"
13
+
14
+ #define _SELF(self) (PANGO_FONT_MAP(RVAL2GOBJ(self)))
15
+ #define RVAL2DESC(d) ((PangoFontDescription*)RVAL2BOXED(d, PANGO_TYPE_FONT_DESCRIPTION))
16
+ #define RVAL2LANG(l) ((PangoLanguage*)RVAL2BOXED(l, PANGO_TYPE_LANGUAGE))
17
+
18
+ /*
19
+ static VALUE
20
+ font_map_initialize(self)
21
+ VALUE self;
22
+ {
23
+ G_INITIALIZE(self, pango_ft2_font_map_new());
24
+ return Qnil;
25
+ }
26
+ */
27
+
28
+ static VALUE
29
+ font_map_load_font(self, context, desc)
30
+ VALUE self, context, desc;
31
+ {
32
+ return GOBJ2RVAL(pango_font_map_load_font(_SELF(self),
33
+ PANGO_CONTEXT(RVAL2GOBJ(context)),
34
+ RVAL2DESC(desc)));
35
+ }
36
+
37
+ static VALUE
38
+ font_map_load_fontset(self, context, desc, lang)
39
+ VALUE self, context, desc, lang;
40
+ {
41
+ return GOBJ2RVAL(pango_font_map_load_fontset(_SELF(self),
42
+ PANGO_CONTEXT(RVAL2GOBJ(context)),
43
+ RVAL2DESC(desc),
44
+ RVAL2LANG(lang)));
45
+ }
46
+
47
+ static VALUE
48
+ font_map_list_families(self)
49
+ VALUE self;
50
+ {
51
+ int n_families;
52
+ PangoFontFamily** families;
53
+ int i;
54
+ VALUE result;
55
+
56
+ pango_font_map_list_families(_SELF(self),
57
+ &families,
58
+ &n_families);
59
+
60
+ result = rb_ary_new2(n_families);
61
+ for (i = 0; i < n_families; i++)
62
+ rb_ary_store(result, i, GOBJ2RVAL(families[i]));
63
+
64
+ g_free(families);
65
+
66
+ return result;
67
+ }
68
+
69
+ #if PANGO_CHECK_VERSION(1,4,0)
70
+ static VALUE
71
+ font_map_get_shape_engine_type(self)
72
+ VALUE self;
73
+ {
74
+ return CSTR2RVAL(pango_font_map_get_shape_engine_type(_SELF(self)));
75
+ }
76
+ #endif
77
+
78
+ void
79
+ Init_pango_font_map()
80
+ {
81
+ VALUE pMap = G_DEF_CLASS(PANGO_TYPE_FONT_MAP, "FontMap", mPango);
82
+
83
+ /*
84
+ rb_define_method(pMap, "initialize", font_map_initialize, 0);
85
+ */
86
+ rb_define_method(pMap, "load_font", font_map_load_font, 2);
87
+ rb_define_method(pMap, "load_fontset", font_map_load_fontset, 3);
88
+ rb_define_method(pMap, "families", font_map_list_families, 0);
89
+ #if PANGO_CHECK_VERSION(1,4,0)
90
+ rb_define_method(pMap, "shape_engine_type", font_map_get_shape_engine_type, 0);
91
+ #endif
92
+
93
+ G_DEF_CLASS3("PangoFcFontMap", "FcFontMap", mPango);
94
+ G_DEF_CLASS3("PangoXftFontMap", "XftFontMap", mPango);
95
+ G_DEF_CLASS3("PangoFT2FontMap", "FT2FontMap", mPango);
96
+ G_DEF_CLASS3("PangoXFontMap", "XFontMap", mPango);
97
+ G_DEF_CLASS3("PangoWin32FontMap", "Win32FontMap", mPango);
98
+ G_DEF_CLASS3("PangoCairoFcFontMap", "CairoFcFontMap", mPango);
99
+ G_DEF_CLASS3("PangoCairoWin32FontMap", "CairoWin32FontMap", mPango);
100
+ #if PANGO_CHECK_VERSION(1,12,0)
101
+ G_DEF_CLASS3("PangoATSUIFontMap", "ATSUIFontMap", mPango);
102
+ #endif
103
+ }
104
+
@@ -0,0 +1,85 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangofontmetrics.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2005/02/13 17:31:33 $
8
+
9
+ Copyright (C) 2002-2005 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbpango.h"
13
+
14
+ #define _SELF(self) ((PangoFontMetrics*)RVAL2BOXED(self, PANGO_TYPE_FONT_METRICS))
15
+
16
+ static VALUE
17
+ font_metrics_get_ascent(self)
18
+ VALUE self;
19
+ {
20
+ return INT2NUM(pango_font_metrics_get_ascent(_SELF(self)));
21
+ }
22
+
23
+ static VALUE
24
+ font_metrics_get_descent(self)
25
+ VALUE self;
26
+ {
27
+ return INT2NUM(pango_font_metrics_get_descent(_SELF(self)));
28
+ }
29
+
30
+ static VALUE
31
+ font_metrics_get_approximate_char_width(self)
32
+ VALUE self;
33
+ {
34
+ return INT2NUM(pango_font_metrics_get_approximate_char_width(_SELF(self)));
35
+ }
36
+
37
+ static VALUE
38
+ font_metrics_get_approximate_digit_width(self)
39
+ VALUE self;
40
+ {
41
+ return INT2NUM(pango_font_metrics_get_approximate_digit_width(_SELF(self)));
42
+ }
43
+
44
+ #if PANGO_CHECK_VERSION(1,6,0)
45
+ static VALUE
46
+ font_metrics_get_underline_thickness(self)
47
+ VALUE self;
48
+ {
49
+ return INT2NUM(pango_font_metrics_get_underline_thickness(_SELF(self)));
50
+ }
51
+ static VALUE
52
+ font_metrics_get_underline_position(self)
53
+ VALUE self;
54
+ {
55
+ return INT2NUM(pango_font_metrics_get_underline_position(_SELF(self)));
56
+ }
57
+ static VALUE
58
+ font_metrics_get_strikethrough_thickness(self)
59
+ VALUE self;
60
+ {
61
+ return INT2NUM(pango_font_metrics_get_strikethrough_thickness(_SELF(self)));
62
+ }
63
+ static VALUE
64
+ font_metrics_get_strikethrough_position(self)
65
+ VALUE self;
66
+ {
67
+ return INT2NUM(pango_font_metrics_get_strikethrough_position(_SELF(self)));
68
+ }
69
+ #endif
70
+ void
71
+ Init_pango_font_metrics()
72
+ {
73
+ VALUE pMetrics = G_DEF_CLASS(PANGO_TYPE_FONT_METRICS, "FontMetrics", mPango);
74
+
75
+ rb_define_method(pMetrics, "ascent", font_metrics_get_ascent, 0);
76
+ rb_define_method(pMetrics, "descent", font_metrics_get_descent, 0);
77
+ rb_define_method(pMetrics, "approximate_char_width", font_metrics_get_approximate_char_width, 0);
78
+ rb_define_method(pMetrics, "approximate_digit_width", font_metrics_get_approximate_digit_width, 0);
79
+ #if PANGO_CHECK_VERSION(1,6,0)
80
+ rb_define_method(pMetrics, "underline_thickness", font_metrics_get_underline_thickness, 0);
81
+ rb_define_method(pMetrics, "underline_position", font_metrics_get_underline_position, 0);
82
+ rb_define_method(pMetrics, "strikethrough_thickness", font_metrics_get_strikethrough_thickness, 0);
83
+ rb_define_method(pMetrics, "strikethrough_position", font_metrics_get_strikethrough_position, 0);
84
+ #endif
85
+ }
@@ -0,0 +1,68 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangofontset.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2007/07/13 16:07:33 $
8
+
9
+ Copyright (C) 2002-2005 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbpango.h"
13
+
14
+ #define _SELF(self) (PANGO_FONTSET(RVAL2GOBJ(self)))
15
+
16
+ static ID id_call;
17
+
18
+ static VALUE
19
+ fontset_get_font(self, wc)
20
+ VALUE self, wc;
21
+ {
22
+ return GOBJ2RVAL(pango_fontset_get_font(_SELF(self), NUM2UINT(wc)));
23
+ }
24
+
25
+ static VALUE
26
+ fontset_get_metrics(self)
27
+ VALUE self;
28
+ {
29
+ return BOXED2RVAL(pango_fontset_get_metrics(_SELF(self)), PANGO_TYPE_FONT_METRICS);
30
+ }
31
+
32
+ #if PANGO_CHECK_VERSION(1,4,0)
33
+ static gboolean
34
+ fontset_each(fontset, font, func)
35
+ PangoFontset* fontset;
36
+ PangoFont* font;
37
+ gpointer func;
38
+ {
39
+ return RVAL2CBOOL(rb_funcall((VALUE)func, id_call,
40
+ 2, GOBJ2RVAL(fontset), GOBJ2RVAL(font)));
41
+ }
42
+
43
+ static VALUE
44
+ fontset_foreach(self)
45
+ VALUE self;
46
+ {
47
+ VALUE func = rb_block_proc();
48
+ G_RELATIVE(self, func);
49
+ pango_fontset_foreach(_SELF(self),
50
+ (PangoFontsetForeachFunc)fontset_each,
51
+ (gpointer)func);
52
+ return self;
53
+ }
54
+ #endif
55
+
56
+ void
57
+ Init_pango_fontset()
58
+ {
59
+ VALUE pFontSet = G_DEF_CLASS(PANGO_TYPE_FONTSET, "Fontset", mPango);
60
+
61
+ id_call = rb_intern("call");
62
+
63
+ rb_define_method(pFontSet, "get_font", fontset_get_font, 1);
64
+ rb_define_method(pFontSet, "metrics", fontset_get_metrics, 0);
65
+ #if PANGO_CHECK_VERSION(1,4,0)
66
+ rb_define_method(pFontSet, "each", fontset_foreach, 0);
67
+ #endif
68
+ }
@@ -0,0 +1,53 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbpangofontsetsimple.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2005/10/14 09:55:57 $
8
+
9
+ Copyright (C) 2002,2003 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbpango.h"
13
+
14
+ #ifdef PANGO_ENABLE_BACKEND
15
+
16
+ #define _SELF(self) (PANGO_FONTSET_SIMPLE(RVAL2GOBJ(self)))
17
+ #define RVAL2LANG(v) ((PangoLanguage*)RVAL2BOXED(v, PANGO_TYPE_LANGUAGE))
18
+
19
+ static VALUE
20
+ fontset_simple_initialize(self, lang)
21
+ VALUE self, lang;
22
+ {
23
+ G_INITIALIZE(self, pango_fontset_simple_new(RVAL2LANG(lang)));
24
+ return Qnil;
25
+ }
26
+
27
+ static VALUE
28
+ fontset_simple_append(self, font)
29
+ VALUE self, font;
30
+ {
31
+ pango_fontset_simple_append(_SELF(self), PANGO_FONT(RVAL2GOBJ(font)));
32
+ return self;
33
+ }
34
+
35
+ static VALUE
36
+ fontset_simple_size(self)
37
+ VALUE self;
38
+ {
39
+ return INT2NUM(pango_fontset_simple_size(_SELF(self)));
40
+ }
41
+
42
+ #endif
43
+ void
44
+ Init_pango_fontset_simple()
45
+ {
46
+ #ifdef PANGO_ENABLE_BACKEND
47
+ VALUE pFSimple = G_DEF_CLASS(PANGO_TYPE_FONTSET_SIMPLE, "FontsetSimple", mPango);
48
+
49
+ rb_define_method(pFSimple, "initialize", fontset_simple_initialize, 1);
50
+ rb_define_method(pFSimple, "append", fontset_simple_append, 1);
51
+ rb_define_method(pFSimple, "size", fontset_simple_size, 0);
52
+ #endif
53
+ }