Unicode characters render with Rmagick but not with Minimagick

£可爱£侵袭症+ 提交于 2019-12-08 11:17:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!