Ubuntu – ImageMagick “convert” command cannot use fonts!

convert-commandfontsimagemagick

convert -size 300x50 xc:none -font Arial -pointsize 20 -gravity center -draw "fill white text 1,1 \"$1\" text 0,0 \"$1\" fill black text -1,-1 \"$1\"" $WATERMARK_FILE

Above command results following error:

convert.im6: unable to read font `Arial' @ warning/annotate.c/RenderType/853.

I searched the web and find that many users saw this error, but did not find any solution. Can anyone help?

NOTE 1: Arial font is installed on my system:

$ fc-list | grep -i arial
/usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf: Arial:style=Italic,Cursiva,kurzíva,kursiv,Πλάγια,Kursivoitu,Italique,Dőlt,Corsivo,Cursief,Kursywa,Itálico,Курсив,İtalik,Poševno,nghiêng,Etzana
/usr/share/fonts/truetype/msttcorefonts/ariblk.ttf: Arial Black:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/truetype/msttcorefonts/Arial.ttf: Arial:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,thường,Arrunta
/usr/share/fonts/truetype/msttcorefonts/arialbd.ttf: Arial:style=Bold,Negreta,tučné,fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,đậm,Lodia
/usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf: Arial:style=Bold Italic,Negreta cursiva,tučné kurzíva,fed kursiv,Fett Kursiv,Έντονα Πλάγια,Negrita Cursiva,Lihavoitu Kursivoi,Gras Italique,Félkövér dőlt,Grassetto Corsivo,Vet Cursief,Halvfet Kursiv,Pogrubiona kursywa,Negrito Itálico,Полужирный Курсив,Tučná kurzíva,Fet Kursiv,Kalın İtalik,Krepko poševno,nghiêng đậm,Lodi etzana
/usr/share/fonts/truetype/msttcorefonts/arialbi.ttf: Arial:style=Bold Italic,Negreta cursiva,tučné kurzíva,fed kursiv,Fett Kursiv,Έντονα Πλάγια,Negrita Cursiva,Lihavoitu Kursivoi,Gras Italique,Félkövér dőlt,Grassetto Corsivo,Vet Cursief,Halvfet Kursiv,Pogrubiona kursywa,Negrito Itálico,Полужирный Курсив,Tučná kurzíva,Fet Kursiv,Kalın İtalik,Krepko poševno,nghiêng đậm,Lodi etzana
/usr/share/fonts/truetype/msttcorefonts/Arial_Black.ttf: Arial Black:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf: Arial:style=Bold,Negreta,tučné,fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,đậm,Lodia
/usr/share/fonts/truetype/msttcorefonts/ariali.ttf: Arial:style=Italic,Cursiva,kurzíva,kursiv,Πλάγια,Kursivoitu,Italique,Dőlt,Corsivo,Cursief,Kursywa,Itálico,Курсив,İtalik,Poševno,nghiêng,Etzana

NOTE 2: Changing the case in font name (arial instead of Arial)does not help.

NOTE 3: Using absolute font file path with complete font file name (filename.fileextension) removes the error:

convert -size 300x50 xc:none -font "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf" -pointsize 20 -gravity center -draw "fill white text 1,1 \"$1\" text 0,0 \"$1\" fill black text -1,-1 \"$1\"" $WATERMARK_FILE

Best Answer

Arial is not a free font. Its terms of use on open source platforms like Linux and Ubuntu make it impossible to distribute as part of an installation. You should use one of the free/open alternatives such as Liberation.

You can list the fonts you have with convert -list font. Eg:

$ convert -list font|grep Liberation-Sans
Font: Liberation-Sans-Bold
Font: Liberation-Sans-Bold-Italic
Font: Liberation-Sans-Italic
Font: Liberation-Sans-Narrow-Bold
Font: Liberation-Sans-Narrow-Bold-Italic
Font: Liberation-Sans-Narrow-Italic
Font: Liberation-Sans-Narrow-Regular
Font: Liberation-Sans-Regular