189: def render(x, y, text)
190: x_rel_coords, y_rel_coords = text_rel_coords(text)
191: dx = x_rel_coords.inject(0) {|sum, a| sum + a}
192: dy = y_rel_coords.max
193:
194:
195: @ctx.gc.push()
196: @ctx.gc.text_anchor(Magick::StartAnchor)
197: if @ctx.text_attrs.text_anchor == :end
198: x -= dx
199: elsif @ctx.text_attrs.text_anchor == :middle
200: x -= dx / 2
201: end
202:
203:
204: case @ctx.text_attrs.glyph_orientation_horizontal
205: when 0
206: ;
207: when 90
208: y -= dy
209: when 180
210: x += x_rel_coords.shift
211: x_rel_coords << 0
212: y -= dy
213: when 270
214: x += x_rel_coords[0]
215: end
216:
217: y += shift_baseline(@ctx.text_attrs.glyph_orientation_horizontal, text[0,1])
218:
219: first_word = true
220: text.split(::Magick::RVG::WORD_SEP).each do |word|
221: unless first_word
222: x += x_rel_coords.shift
223: end
224: first_word = false
225: word.split('').each do |glyph|
226: render_glyph(@ctx.text_attrs.glyph_orientation_horizontal, x, y, glyph)
227: x += x_rel_coords.shift
228: end
229: end
230:
231: @ctx.gc.pop()
232: [dx, 0]
233: end