| Class | Magick::RVG::Text |
| In: |
lib/rvg/text.rb
|
| Parent: | TextBase |
Define a text string starting at [x, y]. Use the RVG::TextConstructors#text method to create Text objects in a container.
container.text(100, 100, "Simple text").styles(:font=>'Arial')
Text objects can contain Tspan objects.
container.text(100, 100).styles(:font=>'Arial') do |t|
t.tspan("Red text").styles(:fill=>'red')
t.tspan("Blue text").styles(:fill=>'blue')
end
# File lib/rvg/text.rb, line 149
149: def initialize(x=0, y=0, text=nil, &block)
150: @cx, @cy = Magick::RVG.convert_to_float(x, y)
151: super(text, &block)
152: end
Reference a Tspan object. x and y are just like x and y in RVG::TextBase#tspan
# File lib/rvg/text.rb, line 156
156: def tref(obj, x=nil, y=nil)
157: if ! obj.kind_of?(Tspan)
158: raise ArgumentError, "wrong argument type #{obj.class} (expected Tspan)"
159: end
160: obj = obj.deep_copy
161: obj.parent = self
162: tref = Tref.new(obj, x, y, self)
163: @tspans << tref
164: return tref
165: end