[cairo-commit] rcairo/samples text2.rb,1.3,1.4

Kouhei Sutou commit at pdx.freedesktop.org
Mon Jan 8 02:29:17 PST 2007


Committed by: kou

Update of /cvs/cairo/rcairo/samples
In directory kemper:/tmp/cvs-serv30276/samples

Modified Files:
	text2.rb 
Log Message:
* samples/text2.rb (render_layout): used
  Pango::LayoutIter#line_extents and Pango::LayoutIter#line_yrange.


Index: text2.rb
===================================================================
RCS file: /cvs/cairo/rcairo/samples/text2.rb,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- text2.rb	1 Jan 2007 14:55:45 -0000	1.3
+++ text2.rb	8 Jan 2007 10:29:13 -0000	1.4
@@ -58,23 +58,21 @@
 def render_layout(cr, layout, margin_left, margin_top, body_height)
   x = margin_left
   y = margin_top
-  rest_height = body_height
+  limit_y = margin_top + body_height
 
   iter = layout.iter
   prev_baseline = iter.baseline / Pango::SCALE
   begin
     line = iter.line
-    ink_rect, logical_rect = line.pixel_extents
-    line_height = logical_rect.height
-    baseline = iter.baseline / Pango::SCALE
-    if rest_height < line_height
+    ink_rect, logical_rect = iter.line_extents
+    y_begin, y_end = iter.line_yrange
+    if limit_y < (y + y_end / Pango::SCALE)
       cr.show_page
       y = margin_top - prev_baseline
-      rest_height = body_height
     end
-    cr.move_to(x + logical_rect.x, y + baseline)
+    baseline = iter.baseline / Pango::SCALE
+    cr.move_to(x + logical_rect.x / Pango::SCALE, y + baseline)
     cr.show_pango_layout_line(line)
-    rest_height -= line_height
     prev_baseline = baseline
   end while iter.next_line!
 end



More information about the cairo-commit mailing list