def render(x, y, text)
x_rel_coords, y_rel_coords = text_rel_coords(text)
dx = x_rel_coords.max
dy = y_rel_coords.inject(0) {|sum, a| sum + a}
@ctx.gc.push
@ctx.gc.text_anchor(Magick::StartAnchor)
if @ctx.text_attrs.text_anchor == :end
y -= dy
elsif @ctx.text_attrs.text_anchor == :middle
y -= dy / 2
end
case @ctx.text_attrs.glyph_orientation_vertical
when 0
x -= x_rel_coords.max / 2
y += y_rel_coords[0]
when 90
x -= x_rel_coords.max / 2
when 180
x += x_rel_coords.max / 2
when 270
x += x_rel_coords.max / 2
y += y_rel_coords.shift
y_rel_coords << 0
end
x -= shift_baseline(@ctx.text_attrs.glyph_orientation_vertical, text[0,1])
first_word = true
text.split(::Magick::RVG::WORD_SEP).each do |word|
unless first_word
y += y_rel_coords.shift
x_rel_coords.shift
end
first_word = false
word.split('').each do |glyph|
case @ctx.text_attrs.glyph_orientation_vertical.to_i
when 0, 90, 270
x_shift = (dx - x_rel_coords.shift) / 2
when 180
x_shift = -(dx - x_rel_coords.shift) / 2
end
render_glyph(@ctx.text_attrs.glyph_orientation_vertical, x+x_shift, y, glyph)
y += y_rel_coords.shift
end
end
@ctx.gc.pop
[0, dy]
end