Unicode字符使用Rmagick呈现,但不能使用Minimagick呈现 [英] Unicode characters render with Rmagick but not with Minimagick

查看:156
本文介绍了Unicode字符使用Rmagick呈现,但不能使用Minimagick呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于Rimagick的Minimagick的性能优势(以及Rmagik即将退出的事实),我希望能够在Minimagick中执行以下操作。默认情况下,似乎Minimagick不能很好地处理unicode字符,但Rmagick根本没有roblem(此代码工作正常):

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


推荐答案

我仍在努力理解究竟什么对您有用,什么不对,以及您的实际问题在哪里是....

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)

并让他们阅读:

  text.draw(bg)
  text.text(23,14,"ÿüñCe#43535r(*&^%$#ð")

即: 首先 绘制背景, 然后 绘制文字。 (Minimagick很可能按照规定的顺序执行绘图语句,因为命令行的行为是相同的 - 而Minimagick只是命令行的一个包装器......)

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...)

这篇关于Unicode字符使用Rmagick呈现,但不能使用Minimagick呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆