1

I try to use ImageMagick to handle a Chinese character to a image on my MacBook.

I use command to check the Chinese fonts available on my system.

convert -list font | grep Font

I did not get any.

Seen from the ImageMagick guide Text to Image Handling, Chinese font seems like supported , such as ZenKaiUni

And seen from the application Font Album of my MacBook. There are so many Chinese fonts.

I think it is OK. How to figure it out?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
dengApro
  • 3,848
  • 2
  • 27
  • 41
  • 1
    To get anything back from `convert -list font`, you must edit your type.xml file to include the fonts you want or use the perl script at http://www.imagemagick.org/Usage/scripts/imagick_type_gen to automatically load fonts from your font directory into the type.xml file. – fmw42 Dec 13 '17 at 00:30

3 Answers3

2

You can either tell ImageMagick about all the fonts on your system, like this and then they will show up if you do:

convert -list font

Then you can use shorthand:

convert -font Arial ...

Or, you can just tell ImageMagick the full path to any font on a per-invocation basis:

printf "Hello" | convert -pointsize 72 \
   -font "/Applications/iMovie.app/Contents/Frameworks/Flexo.framework/Versions/A/Resources/Fonts/Zingende Regular.ttf" \
   label:@- result.png

You would probably put Unicode for Chinese characters in place of my "Hello".

enter image description here

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • Could you answer my another question: https://superuser.com/questions/1276446/how-to-use-imagemagick-on-chinese-text-to-image-handling – dengApro Dec 12 '17 at 15:10
2

I do not have any chinese fonts on my system, but here is an example of what I would suggest using the symbol font. First download a proper UTF-8 chinese font, i.e. one that supports UTF-8 characters. Then open a UTF-8 compatible text editor, choose that font and type your string. For example, here is a screensnap of the symbols.txt file that I created using the symbol font in my BBEdit UTF-8 compatible text editor on my Mac.

enter image description here


Then using ImageMagick,

convert -size 100x -font "/library/fonts/GreekMathSymbols Normal.ttf" label:@symbols.txt symbol.gif


And the resulting symbol.gif image is:

enter image description here


Adding .utf8 as suffix to your file is not adequate. You must create a text file in a UTF-8 compatible text editor using a UTF-8 compatible font.

Furthermore, most terminal windows do not support UTF-8 characters / fonts. So typing your characters directly into the command line in the terminal window does not always work. See http://www.imagemagick.org/Usage/text/#unicode

fmw42
  • 46,825
  • 10
  • 62
  • 80
  • You may not have any Chinese fonts (although macOS comes with at least one as standard) but you'll definitely have many fonts that support the Chinese character set. – Matt Sephton Dec 13 '17 at 12:27
1

You can't do it in ImagMagick as the font information it uses doesn't include language support, but it's easy with Font Book.app by creating a Smart Collection as follows:

enter image description here

On my Mac I have 35 fonts which include Chinese characters.

enter image description here

(The dimmed/greyed fonts are available but will need to be downloaded from Apple servers before I can use them, an automatic process done when selecting those fonts in any app.)

Matt Sephton
  • 3,711
  • 4
  • 35
  • 46