Class Magick::RVG::Utility::LRTextStrategy
In: lib/rvg/misc.rb
Parent: TextStrategy
Enum GeometryValue Stylable RVG\n[lib/rvg/clippath.rb\nlib/rvg/container.rb\nlib/rvg/deep_equal.rb\nlib/rvg/describable.rb\nlib/rvg/embellishable.rb\nlib/rvg/misc.rb\nlib/rvg/paint.rb\nlib/rvg/pathdata.rb\nlib/rvg/rvg.rb\nlib/rvg/stretchable.rb\nlib/rvg/stylable.rb\nlib/rvg/text.rb\nlib/rvg/transformable.rb\nlib/rvg/units.rb] Transformable Stretchable Embellishable Describable Duplicatable Comparable Image ImageList Array Geometry HatchFill Draw lib/RMagick.rb lib/rvg/rvg.rb Magick Module: Magick

Methods

Public Instance methods

[Source]

     # 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

[Source]

     # 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

[Source]

     # 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

[Validate]