# File pango/sample/pango_cairo.rb, line 24
def draw_text(cr)
  # Center coordinates on the middle of the region we are drawing
  cr.translate(RADIUS, RADIUS);

  # Create a PangoLayout, set the font and text
  layout = cr.create_pango_layout
  
  layout.set_text("Text")
  desc = Pango::FontDescription.new(FONT)
  layout.set_font_description(desc)

  # Draw the layout N_WORDS times in a circle
  N_WORDS.times do |i|
    angle = (360.0 * i) / N_WORDS;
    cr.save do
      # Gradient from red at angle == 60 to blue at angle == 300
      red = (1 + Math.cos((angle - 60) * Math::PI / 180.0)) / 2
      cr.set_source_rgb(red, 0, 1.0 - red)
      cr.rotate(angle * Math::PI / 180.0)
    
      # Inform Pango to re-layout the text with the new transformation
      cr.update_pango_layout(layout)
    
      width, height = layout.size
      cr.move_to(-(width.to_f / Pango::SCALE) / 2, -RADIUS)
      cr.show_pango_layout(layout)
    end
  end
end