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