ropensci/magick

image_annotate(): Get available fonts

matutosi opened this issue · 6 comments

I use magick package on Windows.
To use Japanese fonts with image_annotate(), fonts must be specified.
we can get the available fonts with the following command with ImageMagick.
convert -list font
Please let me know a way to do the same thing with magick package.
If not, a function to do so would be greatly appreciated.

jeroen commented

Would you need this information for debugging, or to program with? I added a function dump_option_info that internally calls the the same as convert -list so you can do:

# install latest dev version
install.packages("magick", repos = "https://ropensci.r-universe.dev")

# same as convert -list font
magick::dump_option_info("font")

This will make imagemagick print stuff to the console, so it may work in Rterm.exe and RStudio, but not in RGui.

If you need something better, can you explain how you would use the function, which information exactly you would like it to return?

THANKS. It works well.
I will use the function to specify the font as an argument to the image_annotate() function.

Sorry for the additional request.
It would be appreciated if a string of font information displayed in the console could be obtained as a return value.

jeroen commented

I can try. Do you just need the font name or also the family/path?

jeroen commented

OK I have added a new function magick_fonts(). You can install the latest magick from https://ropensci.r-universe.dev/magick

Can you let me know if this works? I personally don't know how fonts on Windows work exactly.

Thanks. The function also works on RGui.