Open jzadra opened 5 years ago
I believe this is related to your operating system font management, not magick
. Here's result on Ubuntu
library(magick)
image_blank(500,500, color = "yellow") %>%
image_annotate("12345 TEST", location = "+0+0", font = "Roboto", size = 118, color = "black") %>%
image_annotate("12345 TEST", location = "+0+0", font = "Roboto Condensed", size = 118, color = "red")
And here's results on Windows
library(magick)
image_blank(500,500, color = "yellow") %>%
image_annotate("Arial Narrow", location = "+0+0", font = "Arial Narrow", size = 50, color = "black") %>%
image_annotate("Times New Roman", location = "+0+50", font = "Times New Roman", size = 50, color = "red") %>%
image_annotate("Comic Sans", location = "+0+100", font = "Comic Sans", size = 50, color = "green") %>%
image_annotate("Freestyle Script", location = "+0+180", font ="Freestyle Script" , size = 50, color = "blue")
Finding and rendering fonts is really specific to the OS and the version of imagemagick. Unfortunately the builds of imagemagick from homebrew are configured without fontconfig support.
However the magick
CRAN binary package should be able to find most fonts.
Sorry for the lack of info - my issues are occurring on OSX Mojave.
Magick does not properly apply fonts when given values that have spaces, despite the fonts being in types.xml and showing as a result of
convert -list font
.If you manually edit types.xml and remove the spaces from the
family
value, it applies the font correctly.It appears that what it is doing is taking the first word, and dropping the rest. So if you have a font that matches the first word, it works. But this causes problems when you have bold or italic versions of the font named things like "Roboto", "Roboto Bold", "Roboto Condensed", etc.
For example, note that specifying "Times" instead of "Times New Roman works:
Created on 2019-02-04 by the reprex package (v0.2.1)
And that specifying "Times" and "Times New Roman" produces the same font results:
Created on 2019-02-04 by the reprex package (v0.2.1)
An example of how this prevents using different versions of the same font:
Created on 2019-02-04 by the reprex package (v0.2.1)