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