rmagick不支持日文字符

时间:2012-03-07 14:03:41

标签: ruby encoding utf-8 character-encoding rmagick

我想通过rmagick从模板构建一个凭证,(使用utf8编码)下面只是一个小代码片段

text.annotate(template, 0, 0, 23, 155, offer_label) { self.pointsize = 16 self.font_weight = BoldWeight }

当我提供offer_label作为安価な価格でホテルを予约(日语) 所以在创建的凭证中,offer_label被视为????????????。 offer_label正确存储在数据库中

模板代码段:

<html lang="en">
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <title><%= @from_name %></title>
 <style type="text/css">
a:hover { color: #09F !important; text-decoration: underline !important; }
 </style>
</head>

我环顾了建议的问题,但没有运气。向前寻求建议。

更新: label_name在浏览器网页中正确显示,此问题仅出现在使用rmagick创建的凭证中

1 个答案:

答案 0 :(得分:0)

1)您应该将日语字体安装到运行时环境中。

您可以通过Magick.fonts检查是否已安装。

2)指定与字体相关的属性。

使用Draw#annotate并指定您要使用的字体名称/ font_family名称。

希望这有帮助。