Kudos to this great library but sometimes you are stuck with certain tasks where you have to look for some workarounds.
One of the common tasks is to wrap the text on in image.
You can accomplish it very well like this
image = Image.read("caption: text goes here")
You can specify other arguments by setting Image::Info attributes in the optional block like this
image = Image.read("caption: text goes here") do
self.size = "200x"
self.pointsize = 20
self.font = "Tahoma"
end
But the Image::Info class is a bit restricted e.g you can't set the font weight, style and a lot more things that you can do you using the Draw class.
So the best workaround is to insert "\n"s into the text.
To do this create your draw class object and call its method get_type_metrics and pass it the text and the image where you want to draw the text or any temporary image.
# create draw object
draw_title = Magick::Draw.new
# set the attributes
draw_title.stroke('transparent')
draw_title.font_family('Georgia')
draw_title.pointsize(17)
draw_title.font_stretch(Magick::UltraCondensedStretch)
draw_title.font_style(Magick::NormalStyle)
draw_title.font_weight(500)
draw_title.fill = '#000000'
tmp_img = Magick::Image.new(600,600)
tmp = draw_title.get_type_metrics(tmp_img, "You text goes here").
You can easily find where to put the "\n" by looking at tmp.width.