pango 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +27 -5
  3. data/ext/pango/depend +2 -2
  4. data/ext/pango/extconf.rb +32 -28
  5. data/ext/pango/pango.def +0 -16
  6. data/ext/pango/rb-pango-attr-list.c +64 -0
  7. data/ext/pango/rb-pango-attribute.c +147 -0
  8. data/ext/pango/rb-pango-context.c +79 -0
  9. data/ext/pango/{rbpangoconversions.h → rb-pango-conversions.h} +4 -6
  10. data/ext/pango/rb-pango-private.h +27 -0
  11. data/ext/pango/rb-pango.c +32 -0
  12. data/ext/pango/rb-pango.h +29 -0
  13. data/extconf.rb +25 -9
  14. data/lib/pango.rb +24 -68
  15. data/lib/pango/cairo-loader.rb +63 -0
  16. data/lib/pango/color.rb +31 -0
  17. data/lib/pango/deprecated.rb +37 -0
  18. data/lib/pango/font-description.rb +29 -0
  19. data/lib/pango/language.rb +29 -0
  20. data/lib/pango/layout.rb +41 -0
  21. data/lib/pango/loader.rb +87 -0
  22. data/lib/pango/markup.rb +31 -0
  23. data/lib/pango/matrix.rb +64 -0
  24. data/lib/pango/rectangle.rb +28 -0
  25. data/lib/pango/version.rb +30 -0
  26. data/test/pango-test-utils.rb +7 -7
  27. data/test/run-test.rb +34 -8
  28. data/test/test-attr-list.rb +28 -0
  29. data/test/test-color.rb +1 -3
  30. data/test/test-context.rb +4 -4
  31. data/test/test-enum.rb +37 -0
  32. data/test/test-font-description.rb +31 -0
  33. data/test/test-language.rb +2 -1
  34. data/test/test-layout.rb +12 -0
  35. data/test/test-markup.rb +30 -0
  36. data/test/test-matrix.rb +131 -5
  37. data/test/test-rectangle.rb +16 -3
  38. metadata +42 -56
  39. data/README +0 -32
  40. data/ext/pango/rbpango.c +0 -356
  41. data/ext/pango/rbpango.h +0 -95
  42. data/ext/pango/rbpangoanalysis.c +0 -218
  43. data/ext/pango/rbpangoattribute.c +0 -506
  44. data/ext/pango/rbpangoattriterator.c +0 -141
  45. data/ext/pango/rbpangoattrlist.c +0 -101
  46. data/ext/pango/rbpangocairo.c +0 -122
  47. data/ext/pango/rbpangocairocontext.c +0 -131
  48. data/ext/pango/rbpangocolor.c +0 -120
  49. data/ext/pango/rbpangocontext.c +0 -344
  50. data/ext/pango/rbpangocoverage.c +0 -106
  51. data/ext/pango/rbpangoengine.c +0 -73
  52. data/ext/pango/rbpangofont.c +0 -110
  53. data/ext/pango/rbpangofontdescription.c +0 -282
  54. data/ext/pango/rbpangofontface.c +0 -73
  55. data/ext/pango/rbpangofontfamily.c +0 -79
  56. data/ext/pango/rbpangofontmap.c +0 -102
  57. data/ext/pango/rbpangofontmetrics.c +0 -85
  58. data/ext/pango/rbpangofontset.c +0 -69
  59. data/ext/pango/rbpangofontsetsimple.c +0 -60
  60. data/ext/pango/rbpangoglyphinfo.c +0 -123
  61. data/ext/pango/rbpangoglyphitem.c +0 -125
  62. data/ext/pango/rbpangoglyphstring.c +0 -151
  63. data/ext/pango/rbpangogravity.c +0 -54
  64. data/ext/pango/rbpangoitem.c +0 -95
  65. data/ext/pango/rbpangolanguage.c +0 -94
  66. data/ext/pango/rbpangolayout.c +0 -583
  67. data/ext/pango/rbpangolayoutiter.c +0 -189
  68. data/ext/pango/rbpangolayoutline.c +0 -243
  69. data/ext/pango/rbpangologattr.c +0 -109
  70. data/ext/pango/rbpangomatrix.c +0 -143
  71. data/ext/pango/rbpangoprivate.h +0 -49
  72. data/ext/pango/rbpangorectangle.c +0 -170
  73. data/ext/pango/rbpangorenderer.c +0 -193
  74. data/ext/pango/rbpangoscript.c +0 -84
  75. data/ext/pango/rbpangoscriptiter.c +0 -92
  76. data/ext/pango/rbpangotabarray.c +0 -128
  77. data/sample/attribute.rb +0 -82
  78. data/sample/break.rb +0 -28
  79. data/sample/gdk_layout.rb +0 -27
  80. data/sample/glyphstring.rb +0 -61
  81. data/sample/item.rb +0 -37
  82. data/sample/label.rb +0 -23
  83. data/sample/layout.rb +0 -102
  84. data/sample/pango_cairo.rb +0 -66
  85. data/sample/parse.rb +0 -33
  86. data/sample/sample.txt +0 -10
  87. data/sample/script.rb +0 -23
@@ -1,61 +0,0 @@
1
- #!/usr/bin/env ruby
2
- =begin
3
- glyphstring.rb - Ruby/Pango sample script.
4
-
5
- Copyright (c) 2002-2006 Ruby-GNOME2 Project Team
6
- This program is licenced under the same licence as Ruby-GNOME2.
7
-
8
- $Id: glyphstring.rb,v 1.3 2006/06/17 14:16:53 ktou Exp $
9
- =end
10
-
11
- require 'gtk2'
12
-
13
- str = "Hello World"
14
-
15
- lang = Pango::Language.new("ja_JP")
16
- fd = Pango::FontDescription.new("Sans 18")
17
-
18
- context = Gdk::Pango.context
19
- context.language = lang
20
- context.base_dir = Pango::DIRECTION_LTR
21
- context.font_description = fd
22
-
23
- p font = context.load_font(fd)
24
- family = context.families[10]
25
- puts "#{family.class}, #{family.name}"
26
-
27
- family.faces.each do |face|
28
- puts face.name
29
- end
30
-
31
- p fmap = font.font_map
32
-
33
- p fset = fmap.load_fontset(context, fd, lang)
34
-
35
-
36
- gs = Pango::GlyphString.new
37
-
38
- ink_rect, logical_rect = gs.extents(font)
39
-
40
- p ink_rect.to_a
41
- p logical_rect.to_a
42
-
43
- item = Pango::Item.new
44
- item.analysis.font = font
45
- item.analysis.shape_engine = font.find_shaper(lang, str.codepoints.first)
46
-
47
- gs = Pango.shape(str, item.analysis)
48
-
49
- ink_rect, logical_rect = gs.extents(font, 0, 11)
50
-
51
- p ink_rect.to_a
52
- p logical_rect.to_a
53
-
54
- gs.glyphs.each do |info, log_clusters|
55
- puts "Pango::GlyphInfo: log_clusters = #{log_clusters}, glyph = #{info.glyph}, geometry = #{info.geometry.inspect}, cluster_start? = #{info.cluster_start?}"
56
- end
57
-
58
- p gs.index_to_x(str, item.analysis, 3, false)
59
- p gs.x_to_index(str, item.analysis, 103)
60
-
61
- p logical_widths = gs.get_logical_widths(str, item.analysis.level)
data/sample/item.rb DELETED
@@ -1,37 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- =begin
4
- item.rb - Ruby/Pango sample script.
5
-
6
- Copyright (c) 2005 Ruby-GNOME2 Project
7
- This program is licenced under the same licence as Ruby-GNOME2.
8
-
9
- $Id: item.rb,v 1.3 2006/06/17 13:37:01 mutoh Exp $
10
- =end
11
-
12
- require 'gtk2'
13
-
14
- str = "Ruby-GNOME2こんにちわ"
15
- win = Gtk::Window.new("Ruby/Pango sample")
16
- win.realize
17
-
18
- p screen = Gdk::Screen.default
19
- p context = Gdk::Pango.context(screen)
20
- p attrlist = Pango::AttrList.new
21
-
22
- p a = Pango::AttrBackground.new(65535, 0, 0)
23
-
24
- attrlist.insert(Pango::AttrBackground.new(65535, 0,0))
25
-
26
- attrs = [Pango::AttrBackground.new(65535, 0,0), Pango::AttrForeground.new(65535, 0,0)]
27
-
28
- items = context.itemize(Pango::Context::DIRECTION_RTL, str, 0, 40, attrlist)
29
-
30
- items.each do |v|
31
- ana = v.analysis
32
- puts "shape_engine = #{ana.shape_engine}, lang_engine = #{ana.lang_engine}, font = #{ana.font}, level = #{ana.level}"
33
- puts "language = #{ana.language}"
34
- p ana.font.get_glyph_extents("a".codepoints.first)[0].to_a
35
- ana.set_extra_attrs(attrs)
36
- p ana.extra_attrs
37
- end
data/sample/label.rb DELETED
@@ -1,23 +0,0 @@
1
- =begin
2
- label.rb - Ruby/Pango sample script.
3
-
4
- Copyright (c) 2002,2003 Ruby-GNOME2 Project Team
5
- This program is licenced under the same licence as Ruby-GNOME2.
6
-
7
- $Id: label.rb,v 1.4 2006/06/17 13:36:11 mutoh Exp $
8
- =end
9
-
10
- require 'gtk2'
11
-
12
- str = File.read("sample.txt")
13
- attrs, text, accel_char = Pango.parse_markup(str, '$')
14
-
15
- #This is same as Gtk::Label#set_markup()
16
- label = Gtk::Label.new(text)
17
- label.attributes = attrs
18
-
19
- win = Gtk::Window.new
20
- win.signal_connect("destroy"){Gtk.main_quit}
21
- win.add(label).show_all
22
-
23
- Gtk.main
data/sample/layout.rb DELETED
@@ -1,102 +0,0 @@
1
- #!/usr/local/bin/ruby
2
- =begin
3
- layout.rb - Ruby/Pango sample script.
4
-
5
- Copyright (c) 2005 Ruby-GNOME2 Project Team
6
- This program is licenced under the same licence as Ruby-GNOME2.
7
-
8
- $Id: layout.rb,v 1.2 2006/06/17 13:36:11 mutoh Exp $
9
- =end
10
-
11
- require 'gtk2'
12
- require 'pp'
13
-
14
- puts
15
- puts "Start----------"
16
- puts
17
- str = File.read(File.join(__dir__, "sample.txt"))
18
- context = Gdk::Pango.context
19
- context.base_dir = Pango::Context::DIRECTION_LTR
20
- context.language = Pango::Language.new("ja_JP")
21
- fd = Pango::FontDescription.new("Sans 18")
22
- font = context.load_font(fd)
23
- font_map = context.font_map
24
-
25
- p "context: #{context}"
26
- p "font_desc: #{fd}"
27
- p "font: #{font}"
28
- p "font_map: #{font_map}"
29
-
30
- puts
31
- puts "Pango::Layout----------"
32
- puts
33
- p layout = Pango::Layout.new(context)
34
-
35
- layout.set_markup(str)
36
- layout.font_description = fd
37
- layout.auto_dir = true
38
- layout.alignment = Pango::Layout::ALIGN_LEFT
39
-
40
- p "attributes: #{layout.attributes}"
41
- p "font_description: #{layout.font_description}"
42
- p "width: #{layout.width}"
43
- p "wrap: #{layout.wrap}"
44
- p "ellipsize: #{layout.ellipsize}"
45
- p "indent: #{layout.indent}"
46
- p "spacing: #{layout.spacing}"
47
- p "justify?: #{layout.justify?}"
48
- p "auto_dir?: #{layout.auto_dir?}"
49
- p "alignment: #{layout.alignment.inspect}"
50
- p "tabs: #{layout.tabs}"
51
- p "single_paragraph_mode?: #{layout.single_paragraph_mode?}"
52
- p "size: #{layout.size}"
53
- p "pixel_size: #{layout.pixel_size}"
54
- p "line_count: #{layout.line_count}"
55
-
56
- puts "lines:"
57
- pp layout.lines
58
-
59
- puts
60
- puts "Pango::LayoutIter--------"
61
- puts
62
- iter = layout.iter
63
- p "iter: #{iter}"
64
- p "index: #{iter.index}"
65
- p "baseline: #{iter.baseline}"
66
- p "line: #{iter.line}"
67
- p "char_extents: #{iter.char_extents}"
68
- p "cluster_extents: #{iter.cluster_extents}"
69
- p "run_extents: #{iter.run_extents}"
70
- p "layout_extents: #{iter.layout_extents}"
71
- p "line_extents: #{iter.line_extents}"
72
- p "line_yrange: #{iter.line_yrange}"
73
-
74
- puts
75
- puts "Pango::GlyphItem-------"
76
- puts
77
- glyph = iter.run
78
- p "glyph: #{glyph}"
79
- p "item: #{glyph.item}"
80
- p "glyphs: #{glyph.glyphs}"
81
-
82
- puts
83
- puts "Pango::LayoutLine ----------"
84
- puts
85
-
86
- line = iter.line
87
-
88
- p "line = #{line}"
89
- p "extents: #{line.extents}"
90
- p "pixel_extents: #{line.pixel_extents}"
91
- p "index_to_x: #{line.index_to_x(1, true)}"
92
- p "x_to_index: #{line.x_to_index(1)}"
93
- p "x_ranges: #{line.get_x_ranges(0, 2)}"
94
- p "layout: #{line.layout}"
95
- p "start_index: #{line.start_index}"
96
- p "length: #{line.length}"
97
- p "paragraph_start?: #{line.paragraph_start?}"
98
- p "resolved_dir: #{line.resolved_dir}"
99
- puts "runs:"
100
- pp line.runs
101
- puts
102
- puts "End----------"
@@ -1,66 +0,0 @@
1
- =begin
2
- cairo.rb - Ruby/Pango with cairo sample script.
3
-
4
- Copyright (c) 2005 Ruby-GNOME2 Project
5
- This program is licenced under the same licence as Ruby-GNOME2.
6
-
7
- $Id: pango_cairo.rb,v 1.1 2005/10/15 07:57:52 mutoh Exp $
8
- =end
9
-
10
- require 'pango'
11
-
12
- unless Pango.cairo_available?
13
- STDERR.puts "This sample requires Pango 1.0.0 or later and cairo support"
14
- exit 1
15
- end
16
-
17
- filename = ARGV.shift
18
- filename ||= "cairo.png"
19
-
20
- RADIUS = 150
21
- N_WORDS = 10
22
- FONT = "Sans Bold 27"
23
-
24
- def draw_text(cr)
25
- # Center coordinates on the middle of the region we are drawing
26
- cr.translate(RADIUS, RADIUS);
27
-
28
- # Create a PangoLayout, set the font and text
29
- layout = cr.create_pango_layout
30
-
31
- layout.set_text("Text")
32
- desc = Pango::FontDescription.new(FONT)
33
- layout.set_font_description(desc)
34
-
35
- # Draw the layout N_WORDS times in a circle
36
- N_WORDS.times do |i|
37
- angle = (360.0 * i) / N_WORDS;
38
- cr.save do
39
- # Gradient from red at angle == 60 to blue at angle == 300
40
- red = (1 + Math.cos((angle - 60) * Math::PI / 180.0)) / 2
41
- cr.set_source_rgb(red, 0, 1.0 - red)
42
- cr.rotate(angle * Math::PI / 180.0)
43
-
44
- # Inform Pango to re-layout the text with the new transformation
45
- cr.update_pango_layout(layout)
46
-
47
- width, height = layout.size
48
- cr.move_to(-(width.to_f / Pango::SCALE) / 2, -RADIUS)
49
- cr.show_pango_layout(layout)
50
- end
51
- end
52
- end
53
-
54
- diameter = 2 * RADIUS
55
- surface = Cairo::ImageSurface.new(Cairo::FORMAT_ARGB32, diameter, diameter)
56
- cr = Cairo::Context.new(surface)
57
- cr.set_source_rgb(1.0, 1.0, 1.0)
58
- cr.rectangle(0, 0, diameter, diameter);
59
- cr.fill
60
- draw_text(cr)
61
-
62
- File.open(filename, "wb") do |f|
63
- cr.target.write_to_png(f)
64
- end
65
- # or
66
- # cr.target.write_to_png(filename)
data/sample/parse.rb DELETED
@@ -1,33 +0,0 @@
1
- #!/usr/bin/env ruby
2
- =begin
3
- parse.rb - Ruby/Pango sample script.
4
-
5
- Copyright (c) 2002,2003 Ruby-GNOME2 Project Team
6
- This program is licenced under the same licence as Ruby-GNOME2.
7
-
8
- $Id: parse.rb,v 1.4 2005/03/22 17:41:29 silicio Exp $
9
- =end
10
-
11
- require 'pango'
12
-
13
- str = File.read("sample.txt")
14
- puts str
15
- puts "------"
16
-
17
- attr_list, text, accel_char = Pango.parse_markup(str, '$')
18
- puts "attr_list = #{attr_list}"
19
- puts "text = #{text}"
20
- puts "accel_char = #{accel_char}"
21
- puts "------"
22
-
23
- iterator = attr_list.iterator
24
-
25
- attr_list.each(text) do |iterator, text, start_pos, end_pos|
26
- puts "range = #{start_pos}, #{end_pos}"
27
- puts "text = #{text}"
28
- iterator.get.each do |attr|
29
- puts "#{attr} = #{attr.value}"
30
- end
31
- puts "---"
32
- end
33
-
data/sample/sample.txt DELETED
@@ -1,10 +0,0 @@
1
- <u><span foreground="red" size="x-large" style="italic"
2
- lang="en">Hello World!</span></u> <span background="yellow" lang="ja"
3
- font_desc="Sans Italic 20" stretch="normal">こんにちわ世界!</span>
4
-
5
- <span size="xx-large" face="Serif" foreground="#006600" background="#ffffee">
6
- <span size="larger" underline="double" weight="heavy">Ruby/Pango</span> <span
7
- rise="10000" variant="normal" weight="heavy">$Ruby-GNOME2</span>
8
- </span>
9
-
10
- <span strikethrough="true" size="xx-large" style="oblique" foreground="blue">ABCDEF</span>
data/sample/script.rb DELETED
@@ -1,23 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- =begin
4
- script.rb - Ruby/Pango sample script.
5
-
6
- Copyright (c) 2005 Ruby-GNOME2 Project
7
- This program is licenced under the same licence as Ruby-GNOME2.
8
-
9
- $Id: script.rb,v 1.1 2005/09/17 17:09:12 mutoh Exp $
10
- =end
11
-
12
- require 'pango'
13
-
14
- iter = Pango::ScriptIter.new("Helloこんにちはコンニチハ안녕하세요السلام عليكمΕλληνικάவணக்கம்")
15
- begin
16
- start_pos, end_pos, script = iter.range
17
- puts "-----"
18
- puts "start : #{start_pos}"
19
- puts "end : #{end_pos}"
20
- puts "script: #{script.nick}"
21
- puts "sample_language: #{script.sample_language.to_s}"
22
- end while iter.next!
23
-