1

I use Ubuntu 14.0.4. I want to use a file with UTF8 by a command of ImageMagick. Here you can see:

If the UTF-8 text you wanting to draw has already been generated you can read it directly from a file using '@filename'.For example here I create a Chinese label from a UTF-8 encoded Chinese text file (without a final newline in the file).

 convert -background lightblue -fill blue -pointsize 48 \
          -font ZenKaiUni label:@chinese_words.utf8   label_utf8.gif

Now I test a command that is look like above command for a text file with name label1.txt which it's content is a Persian word:

سلام

Command is:

convert -background lightblue -fill blue -pointsize 48 label:@label1.txt   label_utf8.png

But I got this image:

enter image description here

You can see ? characters instead of desired ones. How can I solve this problem?

hasanghaforian
  • 13,858
  • 11
  • 76
  • 167
  • You have omitted the `-font ...` – Mark Setchell Sep 10 '16 at 10:01
  • @MarkSetchell Which `font` I have to use? – hasanghaforian Sep 10 '16 at 10:03
  • One that can do Persian characters - sorry, I don't know any myself. – Mark Setchell Sep 10 '16 at 10:04
  • @MarkSetchell I try to use for example `KacstArt` as value of `-font` option, but I got this error:`convert.im6: unable to read font `KacstArt' @ warning/annotate.c/RenderType/853.` – hasanghaforian Sep 10 '16 at 10:08
  • Does your font file have an extension? Try adding that. Also, try `identify -list font | grep -i KacstArt` to see if that font is known to ImageMagick. If not, try http://stackoverflow.com/a/24701602/2836621 – Mark Setchell Sep 10 '16 at 10:20
  • @MarkSetchell OK! I try your recommended command to test if the font is known for to ImageMagick and found that complete name of the font is `KacstArt-Medium`. Please add your comments as answer, so I can accept that. – hasanghaforian Sep 10 '16 at 10:47

1 Answers1

1

Firstly, you need to specify the font for ImageMagick to use, so you want something like:

convert -background lightblue -fill blue -pointsize 48 -font XYZ ...

In order to make sure that your selected font is known to ImageMagick, you need to look in the list of known fonts:

identify -list font

or, more specifically in your case:

identify -list font | grep -i Kacst

If the font is listed, use that name. If not listed, refer to this answer.

Community
  • 1
  • 1
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432