安装的字体在 Rails 应用程序的 ec2 中不起作用

安装的字体在 Rails 应用程序的 ec2 中不起作用

我已经通过运行下载了字体

wget http://www.fontsquirrel.com/fonts/download/amatic

在我的 ec2 实例内。然后我创建了一个 .fonts 目录并将这些文件解压在其中。然后ls .fonts是字体文件。然后我跑了fc-cache -f -v,它给了我这个输出

    /usr/share/fonts: caching, new cache contents: 0 fonts, 3 dirs
/usr/share/fonts/cmap: caching, new cache contents: 0 fonts, 5 dirs
/usr/share/fonts/cmap/adobe-cns1: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/cmap/adobe-gb1: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/cmap/adobe-japan1: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/cmap/adobe-japan2: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/cmap/adobe-korea1: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/truetype: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/truetype/dejavu: caching, new cache contents: 6 fonts, 0 dirs
/usr/share/fonts/type1: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/type1/gsfonts: caching, new cache contents: 35 fonts, 0 dirs
/usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs
/home/ubuntu/.local/share/fonts: skipping, no such directory
/home/ubuntu/.fonts: caching, new cache contents: 2 fonts, 0 dirs
/usr/share/fonts: caching, new cache contents: 0 fonts, 3 dirs
/usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs
/home/ubuntu/.local/share/fonts: skipping, no such directory
/home/ubuntu/.fonts: caching, new cache contents: 2 fonts, 0 dirs
/var/cache/fontconfig: not cleaning unwritable cache directory
/home/ubuntu/.cache/fontconfig: cleaning cache directory
/home/ubuntu/.fontconfig: not cleaning non-existent cache directory
fc-cache: succeeded

然后我去浏览器中查看字体是否已经应用,但仍然没有应用。当我运行时,fc-list我可以看到我的字体列在那里,但它没有显示在我的 Rails 应用程序中。但是我发现,当我运行 ruby​​ 脚本(ruby test.rb其中包含相同的图像处理代码)时,它运行良好并且字体也是我想要的,但唯一的问题是在我的 Rails 应用程序中。我已经重新启动了 Rails 应用程序,但问题仍然存在。

我正在使用该字体进行图像处理。

这是我的代码

txt = "Sushant"

overlay = Magick::Image.read("stamp.png").first

 title = Magick::Draw.new
if txt.length <= 7


  title.annotate(overlay, 0,0,120,200, txt) {
    self.font_family = 'Amatic SC'
    self.fill = 'white'
    self.pointsize = 160
  }
else



  title.annotate(overlay, 0,0,0,200, txt) {
    self.font_family = 'Amatic SC'
    self.fill = 'white'
    self.pointsize = 155
  }

end

  img = overlay.write('newimg.gif')

相关内容