convert unable to read font

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
stretch
Posts: 1
Joined: 2018-10-21T07:23:59-07:00
Authentication code: 1152

convert unable to read font

Post by stretch » 2018-10-21T07:27:42-07:00

Hi

I'm trying to run convert on my ubuntu box and i'm getting

convert -background white -pointsize 20 -gravity center label:"test" /var/www/html/test.png

Code: Select all

convert-im6.q16: unable to read font `(null)' @ error/annotate.c/RenderFreetype/1362.
convert-im6.q16: no images defined `/var/www/html/hello.png' @ error/convert.c/ConvertImageCommand/3258.
convert -list font

Code: Select all

Path: System Fonts
  Font: DejaVu-Sans
    family: DejaVu Sans
    style: Normal
    stretch: Normal
    weight: 400
    glyphs: /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
  Font: DejaVu-Sans-Bold
    family: DejaVu Sans
    style: Normal
    stretch: Normal
    weight: 700
    glyphs: /usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf
  Font: DejaVu-Sans-Mono
    family: DejaVu Sans Mono
    style: Normal
    stretch: Normal
    weight: 400
    glyphs: /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf
  Font: DejaVu-Sans-Mono-Bold
    family: DejaVu Sans Mono
    style: Normal
    stretch: Normal
    weight: 700
    glyphs: /usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf
  Font: DejaVu-Serif
    family: DejaVu Serif
    style: Normal
    stretch: Normal
    weight: 400
    glyphs: /usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf
  Font: DejaVu-Serif-Bold
    family: DejaVu Serif
    style: Normal
    stretch: Normal
    weight: 700
    glyphs: /usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf
  Font: FontAwesome
    family: FontAwesome
    style: Normal
    stretch: Normal
    weight: 400
    glyphs: /usr/share/fonts/truetype/font-awesome/fontawesome-webfont.ttf
also tried

apt-get install ghostscript

Code: Select all

Reading package lists... Done
Building dependency tree
Reading state information... Done
ghostscript is already the newest version (9.25~dfsg+1-0ubuntu0.18.04.1).
If you don't specify a font what one is used by default?

User avatar
fmw42
Posts: 24730
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert unable to read font

Post by fmw42 » 2018-10-21T11:02:55-07:00

If you don't specify a font what one is used by default?
I think it relies on the system default font, but am not 100% sure of that. In the font family documentation https://imagemagick.org/script/command- ... php#family it seems to say it is Arial. But that only works if you have arial on your system. You do not seem to have any default set. I know little about Linux, but on my Mac, it is Arial.

One can find the default, if it is set by adding -debug annotate to your command:

Code: Select all

convert -debug annotate -background white -pointsize 20 -gravity center label:"test" null:
But why would you rely upon some default font? You should always provide the font you want by name if it is set in your type.xml file or by path to the font file. -font arial or -font /path/to/arial.ttf

See https://imagemagick.org/script/resources.php for the type.xml file.

See https://imagemagick.org/Usage/scripts/imagick_type_gen for a script to load all the appropriate fonts on your system into the type.xml file so you can reference them by name.

You can also specify MAGICK_FONT_PATH. See https://imagemagick.org/script/resources.php

Post Reply