Forum: Ruby-Gnome 2 The variant attribute seems not to work well.

Posted by ashbb shoeser (satoshi_a)
on 2011-11-21 15:48
Hi folks,

I read this: http://ruby-gnome2.sourceforge.jp/hiki.cgi?pango-markup

And I ran the following snippet on Windows 7.
# I'm using Ruby 1.9.3p0. The gtk2, cairo and pango are all 1.0.3.

require 'cairo'
require 'pango'
require 'gtk2'
win = Gtk::Window.new
surface = Cairo::ImageSurface.new Cairo::FORMAT_ARGB32, 300, 300
context = Cairo::Context.new surface
layout = context.create_pango_layout
markup = "<span variant='smallcaps'>small-CAPS</span>\n<span
size='smaller'>SMALL</span>-CAPS"
attr_list, text = Pango.parse_markup(markup)
layout.text = text
layout.attributes = attr_list
context.show_pango_layout layout
context.show_page
surface.write_to_png 'hello.png'
img = Gtk::Image.new 'hello.png'
canvas = Gtk::Layout.new
canvas.put img, 0, 0
win.add canvas
win.show_all
Gtk.main

I expected that it'd show the same two 'SMALL-CAPS's.
But I got this: http://www.rin-shun.com/tmp/smallcaps.png

The variant attribute seems not to work well...
Please correct me if I'm wrong.

ashbb
Posted by Kouhei Sutou (Guest)
on 2011-12-04 05:38
(Received via mailing list)
Hi,

In <2aa94818fb77525150d12f69038f4f49@ruby-forum.com>
  "[ruby-gnome2-devel-en] The variant attribute seems not to work well." 
on Mon, 21 Nov 2011 15:48:45 +0100,
  "Satoshi A." <ruby-forum-incoming@andreas-s.net> wrote:

> context = Cairo::Context.new surface
> canvas = Gtk::Layout.new
> canvas.put img, 0, 0
> win.add canvas
> win.show_all
> Gtk.main
>
> I expected that it'd show the same two 'SMALL-CAPS's.
> But I got this: http://www.rin-shun.com/tmp/smallcaps.png
>
> The variant attribute seems not to work well...
> Please correct me if I'm wrong.

I looked at Pango's source code and noticed that Pango
doesn't implement variant... Pango just accepts 'normal' or
'smallcaps'. So you can't use variant in Pango markup.


Thanks,
--
kou
Posted by ashbb shoeser (satoshi_a)
on 2011-12-21 11:38
Hi Kou,

Thank you so much for taking your time to figure out the problem.
Okay, I'm looking forward to see Pango's update in the future. :)

ashbb
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.