File: item.rb

package info (click to toggle)
ruby-gnome2 0.15.0-1.1
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 7,692 kB
  • ctags: 8,558
  • sloc: ansic: 69,912; ruby: 19,511; makefile: 97; xml: 35; sql: 13
file content (35 lines) | stat: -rw-r--r-- 986 bytes parent folder | download | duplicates (5)
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
=begin
  item.rb - Ruby/Pango sample script.

  Copyright (c) 2005 Ruby-GNOME2 Project
  This program is licenced under the same licence as Ruby-GNOME2.

  $Id: item.rb,v 1.3 2006/06/17 13:37:01 mutoh Exp $
=end

require 'gtk2'

str = "Ruby-GNOME2こんにちわ" 
win = Gtk::Window.new("Ruby/Pango sample")
win.realize

p screen = Gdk::Screen.default
p context = Gdk::Pango.context(screen)
p attrlist = Pango::AttrList.new

p a = Pango::AttrBackground.new(65535, 0, 0)

attrlist.insert(Pango::AttrBackground.new(65535, 0,0))

attrs = [Pango::AttrBackground.new(65535, 0,0), Pango::AttrForeground.new(65535, 0,0)]

items = context.itemize(Pango::Context::DIRECTION_RTL, str, 0, 40, attrlist)

items.each do |v|
  ana = v.analysis
  puts "shape_engine = #{ana.shape_engine}, lang_engine = #{ana.lang_engine}, font = #{ana.font}, level = #{ana.level}"
  puts "language = #{ana.language}"
  p ana.font.get_glyph_extents("a"[0])[0].to_a
  ana.set_extra_attrs(attrs)
  p ana.extra_attrs
end