# File lib/rvg/misc.rb, line 253 253: def get_letter_spacing(glyph) 254: gx, gy = glyph_metrics(@ctx.text_attrs.glyph_orientation_vertical, glyph) 255: [gx, gy+@ctx.text_attrs.letter_spacing] 256: end
# File lib/rvg/misc.rb, line 248 248: def get_word_spacing() 249: @word_space ||= glyph_metrics(@ctx.text_attrs.glyph_orientation_vertical, ' ')[1] 250: [0, @word_space + @ctx.text_attrs.word_spacing] 251: end
# File lib/rvg/misc.rb, line 258 258: def render(x, y, text) 259: x_rel_coords, y_rel_coords = text_rel_coords(text) 260: dx = x_rel_coords.max 261: dy = y_rel_coords.inject(0) {|sum, a| sum + a} 262: 263: # We're handling the anchoring. 264: @ctx.gc.push() 265: @ctx.gc.text_anchor(Magick::StartAnchor) 266: if @ctx.text_attrs.text_anchor == :end 267: y -= dy 268: elsif @ctx.text_attrs.text_anchor == :middle 269: y -= dy / 2 270: end 271: 272: # Align the first glyph such that its center 273: # is aligned on x and its top is aligned on y. 274: 275: case @ctx.text_attrs.glyph_orientation_vertical 276: when 0 277: x -= x_rel_coords.max / 2 278: y += y_rel_coords[0] 279: when 90 280: x -= x_rel_coords.max / 2 281: when 180 282: x += x_rel_coords.max / 2 283: when 270 284: x += x_rel_coords.max / 2 285: y += y_rel_coords.shift 286: y_rel_coords << 0 # since we used an element we need to add a dummy 287: end 288: 289: x -= shift_baseline(@ctx.text_attrs.glyph_orientation_vertical, text[0,1]) 290: 291: first_word = true 292: text.split(::Magick::RVG::WORD_SEP).each do |word| 293: unless first_word 294: y += y_rel_coords.shift 295: x_rel_coords.shift 296: end 297: first_word = false 298: word.split('').each do |glyph| 299: case @ctx.text_attrs.glyph_orientation_vertical.to_i 300: when 0, 90, 270 301: x_shift = (dx - x_rel_coords.shift) / 2 302: when 180 303: x_shift = -(dx - x_rel_coords.shift) / 2 304: end 305: 306: render_glyph(@ctx.text_attrs.glyph_orientation_vertical, x+x_shift, y, glyph) 307: y += y_rel_coords.shift 308: end 309: end 310: 311: @ctx.gc.pop() 312: [0, dy] 313: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.