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/misc.rb Application ObjectData Pre_ObjectData_Descriptor Envelope Post_ObjectData_Descriptor IPTC Magick dot/m_14_0.png

Methods

Public Instance methods

[Source]

     # File lib/rvg/misc.rb, line 183
183:                 def get_letter_spacing(glyph)
184:                     gx, gy = glyph_metrics(@ctx.text_attrs.glyph_orientation_horizontal, glyph)
185:                     [gx+@ctx.text_attrs.letter_spacing, gy]
186:                 end

[Source]

     # File lib/rvg/misc.rb, line 178
178:                 def get_word_spacing()
179:                     @word_space ||= glyph_metrics(@ctx.text_attrs.glyph_orientation_horizontal, ' ')[0]
180:                     [@word_space + @ctx.text_attrs.word_spacing, 0]
181:                 end

[Source]

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

[Validate]