In Files

Class Index [+]

Quicksearch

Magick::RVG::Utility::LRTextStrategy

Public Instance Methods

get_letter_spacing(glyph) click to toggle source
     # File lib/rvg/misc.rb, line 184
184:                 def get_letter_spacing(glyph)
185:                     gx, gy = glyph_metrics(@ctx.text_attrs.glyph_orientation_horizontal, glyph)
186:                     [gx+@ctx.text_attrs.letter_spacing, gy]
187:                 end
get_word_spacing() click to toggle source
     # File lib/rvg/misc.rb, line 179
179:                 def get_word_spacing()
180:                     @word_space ||= glyph_metrics(@ctx.text_attrs.glyph_orientation_horizontal, ' ')[0]
181:                     [@word_space + @ctx.text_attrs.word_spacing, 0]
182:                 end
render(x, y, text) click to toggle source
     # File lib/rvg/misc.rb, line 189
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:                     # We're handling the anchoring.
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:                     # Align the first glyph
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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.