问题
Due to the performance advantages of Minimagick of Rmagick (and the fact the Rmagik is on the way out) I would like to be able to able to perform the following operation in Minimagick. By default it seems that Minimagick does not handle unicode character well, but Rmagick has no roblem at all (this code works fine):
def getimage
bg = Magick::ImageList.new("#{Rails.root}/app/assets/images/template.png")
text = Magick::Draw.new
text.encoding = "Unicode"
text.text(23,14,"ÿüñCe#43535r(*&^%$#ð")
text.draw(bg)
send_data(bg.to_blob, :type => 'image/png', :disposition => 'inline')
end
回答1:
I'm still struggling to understand what exactly does work for you and what doesn't, and where your actual problem is....
Nevertheless, my first stab into the fog is this. Swap the following two lines:
text.text(23,14,"ÿüñCe#43535r(*&^%$#ð")
text.draw(bg)
and make them read this:
text.draw(bg)
text.text(23,14,"ÿüñCe#43535r(*&^%$#ð")
That is: first draw the background, then draw the text. (Minimagick most likely executes the drawing statements in the stated order, because the commandline's behavior is the same -- and Minimagick is only a wrapper around the commandline...)
来源:https://stackoverflow.com/questions/11917561/unicode-characters-render-with-rmagick-but-not-with-minimagick