# File gtk2/sample/gtk-demo/cairo-text-extents.rb, line 21 def draw(cr) cr.select_font_face("Sans", Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_NORMAL) cr.set_font_size(0.3) extents = cr.text_extents(TEXT) x = 0.1 y = 0.6 cr.move_to(x, y) cr.show_text(TEXT) # draw helping lines cr.set_source_rgba(1, 0.2, 0.2, 0.6) cr.arc(x, y, 0.05, 0, 2 * Math::PI) cr.fill cr.move_to(x, y) cr.rel_line_to(0, -extents.height) cr.rel_line_to(extents.width, 0) cr.rel_line_to(extents.x_bearing, -extents.y_bearing) cr.stroke end
Generated with the Darkfish Rdoc Generator 2.