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 test.rb同じ画像処理コードを含むRubyスクリプトを実行するとうまく動作し、フォントも私が望むものですが、唯一の問題は私の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')

ベストアンサー1

おすすめ記事