| Class | Magick::RVG::Utility::LRTextStrategy |
| In: |
lib/rvg/misc.rb
|
| Parent: | TextStrategy |
# File lib/rvg/misc.rb, line 179
179: def get_letter_spacing(glyph)
180: gx, gy = glyph_metrics(@ctx.text_attrs.glyph_orientation_horizontal, glyph)
181: [gx+@ctx.text_attrs.letter_spacing, gy]
182: end
# File lib/rvg/misc.rb, line 174
174: def get_word_spacing()
175: @word_space ||= glyph_metrics(@ctx.text_attrs.glyph_orientation_horizontal, ' ')[0]
176: [@word_space + @ctx.text_attrs.word_spacing, 0]
177: end
# File lib/rvg/misc.rb, line 184
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: # We're handling the anchoring.
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: # Align the first glyph
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