Wednesday, November 25, 2009

Creating images from unicode text using rmagick

To create images from the unicode text, we can use the "encoding" method for the Draw object.
Example:
require "RMagick"
def show_textimg
bg = Magick::Image.new(120,20){self.background_color = "#9E9E9E"}
text = Magick::Draw.new
text.encoding = "Unicode"
text.text(23,14,"ドの半角⇔全角")
text.draw(bg)
bg.write "#{RAILS_ROOT}/public/images/text.jpg"
end
http://thinkingrails.blogspot.com/2009/08/creating-images-from-unicode-text-using.html

No comments: