I have downloaded font by running
wget http://www.fontsquirrel.com/fonts/download/amatic
inside my ec2 instance. Then I created a .fonts director and unzipped those files inside it. Then I ls .fonts
and there were the font files. Then I ran fc-cache -f -v
and it gave me this output
/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
Then I went to see in the browser if the font had been applied but it is still not applied. When I run fc-list
I can see that my font is listed there but it is not being show in my rails app.however i found out that when I ran a ruby script ruby test.rb
, in which was the same code for image manipulation , it worked fine and the fonts was also the one i wanted but the only problem is in my rails app. I have restarted my rails app but the problem is still persisting.
I am using that font for image manipulation.
This is my code
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')