[cairo-commit] rcairo/samples text2.rb,1.2,1.3
Kouhei Sutou
commit at pdx.freedesktop.org
Mon Jan 1 06:55:49 PST 2007
Committed by: kou
Update of /cvs/cairo/rcairo/samples
In directory kemper:/tmp/cvs-serv28531/samples
Modified Files:
text2.rb
Log Message:
* samples/text2.rb: used Pango::LayoutIter.LayoutIter
Index: text2.rb
===================================================================
RCS file: /cvs/cairo/rcairo/samples/text2.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- text2.rb 20 Oct 2006 14:41:49 -0000 1.2
+++ text2.rb 1 Jan 2007 14:55:45 -0000 1.3
@@ -55,24 +55,28 @@
cr.set_source(fade_out)
end
-def render_layout(cr, layout, initial_x, initial_y, initial_rest_height)
- x = initial_x
- y = initial_y
- rest_height = initial_rest_height
+def render_layout(cr, layout, margin_left, margin_top, body_height)
+ x = margin_left
+ y = margin_top
+ rest_height = body_height
- layout.lines.each do |line|
+ 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
cr.show_page
- y = initial_y
- rest_height = initial_rest_height
+ y = margin_top - prev_baseline
+ rest_height = body_height
end
- cr.move_to(x + logical_rect.x, y - logical_rect.y)
+ cr.move_to(x + logical_rect.x, y + baseline)
cr.show_pango_layout_line(line)
- y += line_height
rest_height -= line_height
- end
+ prev_baseline = baseline
+ end while iter.next_line!
end
def render(options, output, surface_class)
More information about the cairo-commit
mailing list