Reputation: 4746
My Heroku app doesn't appear to want to recognize ANY kind of rmagick font family. In the following situation I would expect the font to be Times New Roman, but it is instead some system default. I've tried changing to Helvetica, and it's the same result - generic looking system font of some sort.
canvas = Magick::Image.read("caption:#{@statement.text}"){
self.size = "300x300"
self.colorspace = RGBColorspace
self.background_color = 'white'
self.font = "TimesNewRoman"
# self.font = "Helvetica"
self.gravity = CenterGravity
self.pointsize = 26
}.first
I've run identify -list font
and observed that both TimesNewRoman and Helvetica are recognized by the system, but my image refuses to use them.
Bonus context: this is for the preview image in an og:image meta tag for display in Messages/Facebook Messager/etc. If I futz with the font family and display the image directly onto an html page there's no problem and it uses the appropriate font.
Upvotes: 0
Views: 311
Reputation: 4746
Per comment in the chain above:
Wowwwwwwwwww...apparently it's as easy as adding a .fonts
folder to the root of your Heroku app and then moving your font into there - once you do that you can just reference the font directly when setting it onto ImageMagick...
So...yeah.
.fonts
| - "SF-Pro-Text-Light.otf
| - "SF-Pro-Text-Regular.otf
and
canvas = Magick::Image.read("caption:#{@statement.text}"){
self.size = "300x300"
self.colorspace = RGBColorspace
self.background_color = 'white'
self.font = "SF-Pro-Text-Light"
self.gravity = CenterGravity
self.pointsize = 26
}.first
Upvotes: 1