gpt4 book ai didi

ruby - 使用外部TTF字体使用 Prawn 生成带有日语文本的PDF

转载 作者:数据小太阳 更新时间:2023-10-29 07:14:21 25 4
gpt4 key购买 nike

Prawn在Prawn::BASEDIR}/data/fonts/下的字体数量有限

我试过 gkai00mp.ttf,但生成的 PDF 仅显示千叶的第一个字母“千”,例如。

我觉得这个字体适合汉字。

font("#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf") do
text "千葉"
end

是否可以上传和使用外部字体?如果是,从哪里可以得到这些字体?

我的环境:最新的 Ruby 和 Rails。 Prawn 版本0.12.0

最佳答案

在此分享一下解决方法。

我也在这里发布了这个问题 https://github.com/prawnpdf/prawn/issues/595建议是:

The TTF fonts that ship with Prawn are for testing and use with the manual... they're not meant for regular use. Do a web search for "Free Japanese TTF font" and I'm sure you'll probably find something.

所以,我用谷歌搜索并找到了 http://www.wazu.jp/gallery/Fonts_Japanese.html并特别测试了 mona.ttf,这很有效。

关于ruby - 使用外部TTF字体使用 Prawn 生成带有日语文本的PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20463660/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com