pango 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +662 -0
- data/README +33 -0
- data/Rakefile +86 -0
- data/extconf.rb +68 -0
- data/sample/attribute.rb +82 -0
- data/sample/break.rb +26 -0
- data/sample/gdk_layout.rb +27 -0
- data/sample/glyphstring.rb +61 -0
- data/sample/item.rb +35 -0
- data/sample/label.rb +23 -0
- data/sample/layout.rb +102 -0
- data/sample/pango_cairo.rb +66 -0
- data/sample/parse.rb +33 -0
- data/sample/sample.txt +10 -0
- data/sample/script.rb +21 -0
- data/src/lib/pango.rb +60 -0
- data/src/makeinits.rb +48 -0
- data/src/rbpango.c +27 -0
- data/src/rbpango.h +97 -0
- data/src/rbpangoanalysis.c +197 -0
- data/src/rbpangoattribute.c +557 -0
- data/src/rbpangoattriterator.c +137 -0
- data/src/rbpangoattrlist.c +104 -0
- data/src/rbpangocairo.c +229 -0
- data/src/rbpangocolor.c +121 -0
- data/src/rbpangocontext.c +341 -0
- data/src/rbpangocoverage.c +104 -0
- data/src/rbpangoengine.c +65 -0
- data/src/rbpangofont.c +123 -0
- data/src/rbpangofontdescription.c +300 -0
- data/src/rbpangofontface.c +71 -0
- data/src/rbpangofontfamily.c +74 -0
- data/src/rbpangofontmap.c +104 -0
- data/src/rbpangofontmetrics.c +85 -0
- data/src/rbpangofontset.c +68 -0
- data/src/rbpangofontsetsimple.c +53 -0
- data/src/rbpangoglyphinfo.c +119 -0
- data/src/rbpangoglyphitem.c +129 -0
- data/src/rbpangoglyphstring.c +162 -0
- data/src/rbpangogravity.c +43 -0
- data/src/rbpangoinits.c +71 -0
- data/src/rbpangoitem.c +110 -0
- data/src/rbpangolanguage.c +88 -0
- data/src/rbpangolayout.c +593 -0
- data/src/rbpangolayoutiter.c +202 -0
- data/src/rbpangolayoutline.c +256 -0
- data/src/rbpangologattr.c +107 -0
- data/src/rbpangomain.c +213 -0
- data/src/rbpangomatrix.c +155 -0
- data/src/rbpangorectangle.c +178 -0
- data/src/rbpangorenderer.c +204 -0
- data/src/rbpangoscript.c +80 -0
- data/src/rbpangoscriptiter.c +91 -0
- data/src/rbpangotabarray.c +128 -0
- data/src/rbpangoversion.h +24 -0
- data/test/pango-test-utils.rb +9 -0
- data/test/run-test.rb +27 -0
- data/test/test-attribute.rb +19 -0
- data/test/test-language.rb +7 -0
- data/test/test_layout.rb +20 -0
- metadata +158 -0
data/README
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
Ruby/Pango
|
2
|
+
==========
|
3
|
+
Ruby/Pango is a Ruby binding of pango-1.x.
|
4
|
+
|
5
|
+
Requirements
|
6
|
+
------------
|
7
|
+
Ruby: http://www.ruby-lang.org/
|
8
|
+
GLib: http://www.gtk.org/
|
9
|
+
Pango: http://www.pango.org/
|
10
|
+
cairo/rcairo: http://cairographics.org/ (optional)
|
11
|
+
Ruby/GLib2: http://ruby-gnome2.sourceforge.net/
|
12
|
+
|
13
|
+
Install
|
14
|
+
-------
|
15
|
+
0. install ruby-1.6.x or later, GLib, Pango, Ruby/GLib2, Ruby/GTK2
|
16
|
+
(and cairo/rcairo).
|
17
|
+
1. ruby extconf.rb
|
18
|
+
(To use rcairo on Win32, set CAIRO_PATH as a environment variable first)
|
19
|
+
2. make
|
20
|
+
3. su
|
21
|
+
4. make install
|
22
|
+
|
23
|
+
Copying
|
24
|
+
-------
|
25
|
+
Copyright (c) 2002-2005 Ruby-GNOME2 Project Team
|
26
|
+
|
27
|
+
This program is free software.
|
28
|
+
You can distribute/modify this program under the terms of
|
29
|
+
the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
|
30
|
+
|
31
|
+
Project Website
|
32
|
+
---------------
|
33
|
+
http://ruby-gnome2.sourceforge.jp/
|
data/Rakefile
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
CLEAN.include '**/*.o'
|
3
|
+
CLEAN.include "**/*.#{Config::MAKEFILE_CONFIG['DLEXT']}"
|
4
|
+
CLOBBER.include 'doc'
|
5
|
+
CLOBBER.include '**/*.log'
|
6
|
+
CLOBBER.include '**/Makefile'
|
7
|
+
CLOBBER.include '**/extconf.h'
|
8
|
+
|
9
|
+
# Determine the current version of the software
|
10
|
+
def ruby_pango_version
|
11
|
+
buf = File.read('src/rbpango.h')
|
12
|
+
if buf =~ /\s*RBPANGO_MAJOR_VERSION\s*(\d.+)/
|
13
|
+
major = $1
|
14
|
+
else
|
15
|
+
major = 0
|
16
|
+
end
|
17
|
+
if buf =~ /\s*RBPANGO_MINOR_VERSION\s*(\d.+)/
|
18
|
+
minor = $1
|
19
|
+
else
|
20
|
+
minor = 0
|
21
|
+
end
|
22
|
+
if buf =~ /\s*RBPANGO_MICRO_VERSION\s*(\d.+)/
|
23
|
+
micro = $1
|
24
|
+
else
|
25
|
+
micro = 0
|
26
|
+
end
|
27
|
+
"#{major}.#{minor}.#{micro}"
|
28
|
+
end
|
29
|
+
|
30
|
+
CURRENT_VERSION = ruby_pango_version
|
31
|
+
|
32
|
+
desc "Default Task (Test project)"
|
33
|
+
task :default => :test
|
34
|
+
|
35
|
+
# Make tasks -----------------------------------------------------
|
36
|
+
make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
|
37
|
+
MAKECMD = ENV['MAKE_CMD'] || make_program
|
38
|
+
MAKEOPTS = ENV['MAKE_OPTS'] || ''
|
39
|
+
|
40
|
+
PANGO_SO = "src/pango.#{Config::MAKEFILE_CONFIG['DLEXT']}"
|
41
|
+
|
42
|
+
file 'Makefile' => 'extconf.rb' do
|
43
|
+
sh "ruby extconf.rb #{ENV['EXTCONF_OPTS']}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def make(target = '')
|
47
|
+
pid = system("#{MAKECMD} #{MAKEOPTS} #{target}")
|
48
|
+
$?.exitstatus
|
49
|
+
end
|
50
|
+
|
51
|
+
# Let make handle dependencies between c/o/so - we'll just run it.
|
52
|
+
file PANGO_SO => (['Makefile'] + Dir['src/*.c'] + Dir['src/*.h']) do
|
53
|
+
m = make
|
54
|
+
fail "Make failed (status #{m})" unless m == 0
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "Configure Pango"
|
58
|
+
task :configure => ['Makefile']
|
59
|
+
|
60
|
+
desc "Compile the shared object"
|
61
|
+
task :compile => [PANGO_SO]
|
62
|
+
|
63
|
+
desc "Run pango tests"
|
64
|
+
task :test => :compile do
|
65
|
+
sh "ruby test/run-test.rb"
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'Generate gem specification'
|
69
|
+
task :gemspec do
|
70
|
+
require 'erb'
|
71
|
+
tspec = ERB.new(File.read(File.join(File.dirname(__FILE__),'src','pango.gemspec.erb')))
|
72
|
+
File.open(File.join(File.dirname(__FILE__),'pango.gemspec'),'wb') do|f|
|
73
|
+
f << tspec.result
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
desc 'Build gem'
|
78
|
+
task :package => :gemspec do
|
79
|
+
require 'rubygems/specification'
|
80
|
+
spec_source = File.read File.join(File.dirname(__FILE__),'pango.gemspec')
|
81
|
+
spec = nil
|
82
|
+
# see: http://gist.github.com/16215
|
83
|
+
Thread.new { spec = eval("$SAFE = 3\n#{spec_source}") }.join
|
84
|
+
spec.validate
|
85
|
+
Gem::Builder.new(spec).build
|
86
|
+
end
|
data/extconf.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
=begin
|
2
|
+
extconf.rb for Ruby/Pango extention library
|
3
|
+
=end
|
4
|
+
|
5
|
+
PACKAGE_NAME = "pango"
|
6
|
+
PACKAGE_ID = "pango"
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'mkmf-gnome2'
|
10
|
+
USE_GLIB_GEM = true
|
11
|
+
TOPDIR = File.expand_path(File.dirname(__FILE__) )
|
12
|
+
SRCDIR = TOPDIR + '/src'
|
13
|
+
require 'glib2'
|
14
|
+
|
15
|
+
rescue LoadError => e
|
16
|
+
|
17
|
+
USE_GLIB_GEM = false
|
18
|
+
|
19
|
+
TOPDIR = File.expand_path(File.dirname(__FILE__) + '/..')
|
20
|
+
MKMF_GNOME2_DIR = TOPDIR + '/glib/src/lib'
|
21
|
+
SRCDIR = TOPDIR + '/pango/src'
|
22
|
+
|
23
|
+
$LOAD_PATH.unshift MKMF_GNOME2_DIR
|
24
|
+
$LOAD_PATH << "E:\\ruby\\lib\\ruby\\1.8\\i386-mswin32"
|
25
|
+
|
26
|
+
require 'mkmf-gnome2'
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
PKGConfig.have_package(PACKAGE_ID) or exit 1
|
31
|
+
setup_win32(PACKAGE_NAME)
|
32
|
+
|
33
|
+
pango_header = "pango/pango.h"
|
34
|
+
have_func("pango_layout_iter_get_type", pango_header)
|
35
|
+
have_func("pango_layout_set_ellipsize", pango_header)
|
36
|
+
have_func("pango_layout_get_font_description", pango_header)
|
37
|
+
have_func("pango_render_part_get_type", pango_header)
|
38
|
+
have_func("pango_attr_strikethrough_color_new", pango_header)
|
39
|
+
have_func("pango_attr_underline_color_new", pango_header)
|
40
|
+
have_func("pango_glyph_item_free", pango_header)
|
41
|
+
have_func("pango_glyph_item_get_type", pango_header)
|
42
|
+
have_func("pango_attr_iterator_get_attrs", pango_header)
|
43
|
+
have_func("pango_itemize_with_base_dir", pango_header)
|
44
|
+
have_func("pango_font_family_is_monospace", pango_header)
|
45
|
+
|
46
|
+
if PKGConfig.have_package('pangocairo')
|
47
|
+
check_cairo
|
48
|
+
end
|
49
|
+
|
50
|
+
if USE_GLIB_GEM
|
51
|
+
|
52
|
+
path = File.expand_path(ENV['GEM_HOME'] + "/gems/glib2-#{GLib::BINDING_VERSION.join('.')}/src")
|
53
|
+
add_depend_package("glib2", path, '/')
|
54
|
+
else
|
55
|
+
add_depend_package("glib2", "glib/src", TOPDIR)
|
56
|
+
end
|
57
|
+
|
58
|
+
add_distcleanfile("rbpangoinits.c")
|
59
|
+
|
60
|
+
make_version_header("PANGO", "pango")
|
61
|
+
|
62
|
+
create_pkg_config_file("Ruby/Pango", PACKAGE_ID)
|
63
|
+
create_makefile_at_srcdir(PACKAGE_NAME, SRCDIR, "-DRUBY_PANGO_COMPILATION") {
|
64
|
+
SRCDIR_QUOTED = SRCDIR.gsub(' ', '\ ')
|
65
|
+
system("#{$ruby} #{SRCDIR_QUOTED}/makeinits.rb #{SRCDIR_QUOTED}/*.c > rbpangoinits.c")
|
66
|
+
}
|
67
|
+
create_top_makefile
|
68
|
+
|
data/sample/attribute.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
=begin
|
2
|
+
attribute.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: attribute.rb,v 1.6 2006/06/17 13:37:01 mutoh Exp $
|
8
|
+
=end
|
9
|
+
|
10
|
+
require 'pango'
|
11
|
+
|
12
|
+
p a = Pango::AttrSize.new(1)
|
13
|
+
puts "value = #{a.value}"
|
14
|
+
puts "start_index = #{a.start_index}"
|
15
|
+
puts "end_index = #{a.end_index}"
|
16
|
+
|
17
|
+
p a = Pango::AttrStyle.new(Pango::FontDescription::STYLE_NORMAL)
|
18
|
+
puts "value = #{a.value}"
|
19
|
+
|
20
|
+
p a = Pango::AttrVariant.new(Pango::FontDescription::VARIANT_SMALL_CAPS)
|
21
|
+
puts "value = #{a.value}"
|
22
|
+
|
23
|
+
p a = Pango::AttrStretch.new(Pango::FontDescription::STRETCH_EXPANDED)
|
24
|
+
puts "value = #{a.value}"
|
25
|
+
|
26
|
+
p a = Pango::AttrWeight.new(Pango::FontDescription::WEIGHT_BOLD)
|
27
|
+
puts "value = #{a.value}"
|
28
|
+
|
29
|
+
p a = Pango::AttrRise.new(10)
|
30
|
+
puts "value = #{a.value}"
|
31
|
+
|
32
|
+
p a = Pango::AttrLanguage.new(Pango::Language.new("ja"))
|
33
|
+
p a.value
|
34
|
+
p a.value.to_str
|
35
|
+
|
36
|
+
p a = Pango::AttrFamily.new("family")
|
37
|
+
p a.value
|
38
|
+
|
39
|
+
p b = Pango::FontDescription.new
|
40
|
+
p b.to_str
|
41
|
+
p a = Pango::AttrFontDescription.new(b)
|
42
|
+
p a.value
|
43
|
+
p a.value.to_str
|
44
|
+
|
45
|
+
p a = Pango::AttrForeground.new(10, 20, 30)
|
46
|
+
p a.value
|
47
|
+
p a.value.to_a
|
48
|
+
|
49
|
+
p a = Pango::AttrBackground.new(20, 30, 40)
|
50
|
+
p a.value
|
51
|
+
p a.value.to_a
|
52
|
+
|
53
|
+
p a = Pango::AttrStrikethrough.new(true)
|
54
|
+
p a.value
|
55
|
+
|
56
|
+
p Pango::AttrUnderline::SINGLE
|
57
|
+
p a = Pango::AttrUnderline.new(Pango::AttrUnderline::SINGLE)
|
58
|
+
p a.value
|
59
|
+
|
60
|
+
p ink = Pango::Rectangle.new(1, 2, 3, 4)
|
61
|
+
p log = Pango::Rectangle.new(5, 6, 7, 8)
|
62
|
+
p a = Pango::AttrShape.new(ink, log)
|
63
|
+
p a.value[0].to_a
|
64
|
+
p a.value[1].to_a
|
65
|
+
|
66
|
+
p a = Pango::AttrScale.new(2.3)
|
67
|
+
p a.value
|
68
|
+
|
69
|
+
begin
|
70
|
+
require 'gtk2'
|
71
|
+
rescue
|
72
|
+
p "Ruby/GTK2 is not existed."
|
73
|
+
exit 0
|
74
|
+
end
|
75
|
+
p a = Gdk::PangoAttrEmbossed.new(true)
|
76
|
+
p a.value
|
77
|
+
|
78
|
+
mask = Gdk::Pixmap.new(Gtk::Window.new.realize.window, 100, 100, 1)
|
79
|
+
p a = Gdk::PangoAttrStipple.new(mask)
|
80
|
+
p a.value
|
81
|
+
|
82
|
+
|
data/sample/break.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
=begin
|
2
|
+
break.rb - Ruby/Pango 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: break.rb,v 1.1 2005/09/17 17:09:12 mutoh Exp $
|
8
|
+
=end
|
9
|
+
|
10
|
+
require 'pango'
|
11
|
+
|
12
|
+
attr = Pango.break("Hello Worldです\n2nd line", Pango::Analysis.new)
|
13
|
+
|
14
|
+
p attr.length
|
15
|
+
attr.each do |v|
|
16
|
+
print "line_break:#{v.line_break?}"
|
17
|
+
print ", mandatory_break:#{v.mandatory_break?}"
|
18
|
+
print ", char_break:#{v.char_break?}"
|
19
|
+
print ", white:#{v.white?}"
|
20
|
+
print ", cursor_position:#{v.cursor_position?}"
|
21
|
+
print ", word_start:#{v.word_start?}"
|
22
|
+
print ", word_end:#{v.word_end?}"
|
23
|
+
print ", sentence_boundary:#{v.sentence_boundary?}"
|
24
|
+
print ", sentence_start:#{v.sentence_start?}"
|
25
|
+
print ", sentence_end:#{v.sentence_end?}\n"
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
=begin
|
2
|
+
gdk_layout.rb - Ruby/Pango sample script.
|
3
|
+
|
4
|
+
Copyright (c) 2003-2006 Ruby-GNOME2 Project
|
5
|
+
This program is licenced under the same licence as Ruby-GNOME2.
|
6
|
+
|
7
|
+
$Id: gdk_layout.rb,v 1.7 2006/06/17 13:36:11 mutoh Exp $
|
8
|
+
=end
|
9
|
+
|
10
|
+
require 'gtk2'
|
11
|
+
|
12
|
+
window = Gtk::Window.new("Ruby/Pango sample")
|
13
|
+
window.signal_connect("destroy"){Gtk.main_quit}
|
14
|
+
window.realize
|
15
|
+
|
16
|
+
gdkwin = window.window
|
17
|
+
gc = Gdk::GC.new(gdkwin)
|
18
|
+
|
19
|
+
layout = window.create_pango_layout
|
20
|
+
layout.set_markup(File.readlines("sample.txt").to_s, "$")
|
21
|
+
window.signal_connect("expose_event") do
|
22
|
+
gdkwin.draw_layout(gc, 10, 10, layout)
|
23
|
+
end
|
24
|
+
|
25
|
+
window.set_default_size(500,400).show_all
|
26
|
+
|
27
|
+
Gtk.main
|
@@ -0,0 +1,61 @@
|
|
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[0])
|
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
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
=begin
|
2
|
+
item.rb - Ruby/Pango 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: item.rb,v 1.3 2006/06/17 13:37:01 mutoh Exp $
|
8
|
+
=end
|
9
|
+
|
10
|
+
require 'gtk2'
|
11
|
+
|
12
|
+
str = "Ruby-GNOME2こんにちわ"
|
13
|
+
win = Gtk::Window.new("Ruby/Pango sample")
|
14
|
+
win.realize
|
15
|
+
|
16
|
+
p screen = Gdk::Screen.default
|
17
|
+
p context = Gdk::Pango.context(screen)
|
18
|
+
p attrlist = Pango::AttrList.new
|
19
|
+
|
20
|
+
p a = Pango::AttrBackground.new(65535, 0, 0)
|
21
|
+
|
22
|
+
attrlist.insert(Pango::AttrBackground.new(65535, 0,0))
|
23
|
+
|
24
|
+
attrs = [Pango::AttrBackground.new(65535, 0,0), Pango::AttrForeground.new(65535, 0,0)]
|
25
|
+
|
26
|
+
items = context.itemize(Pango::Context::DIRECTION_RTL, str, 0, 40, attrlist)
|
27
|
+
|
28
|
+
items.each do |v|
|
29
|
+
ana = v.analysis
|
30
|
+
puts "shape_engine = #{ana.shape_engine}, lang_engine = #{ana.lang_engine}, font = #{ana.font}, level = #{ana.level}"
|
31
|
+
puts "language = #{ana.language}"
|
32
|
+
p ana.font.get_glyph_extents("a"[0])[0].to_a
|
33
|
+
ana.set_extra_attrs(attrs)
|
34
|
+
p ana.extra_attrs
|
35
|
+
end
|
data/sample/label.rb
ADDED
@@ -0,0 +1,23 @@
|
|
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.readlines("sample.txt").to_s
|
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
|