imagemagick convert: japanese text broken in freebsd

Nikola Lečić nikola.lecic at
Sun Dec 14 11:00:26 PST 2008

Hash: RIPEMD160

On Sat, 13 Dec 2008 20:20:23 -0800 (PST)
cuongvt <freebsd at> wrote:

> Hi,
> I know that IM support japanese text.
> On Freebsd 7.0 with latest imagemagick built from port (6.4.7) and
> msgothic.ttc copied from windows partition,
> imagick extension of PHP installed by pecl.
> in terminal (zsh) I type:
> ================
> convert origin.jpg -fill white -font
> /usr/X11R6/lib/X11/fonts/TrueType/msgothic.ttc -pointsize 125 -stroke
> blue -strokewidth 1 -draw "text 20,130 'がくせい'" straight.jpg
> ========
> IM did not informed any error, but the result is japanese text broken
> (question marks).


It works for me with ImageMagick- and ImageMagick-
First, please make sure that the cause of the problem is not something
simple, i.e. make sure that

  a) you don't have a wrong /non-UTF-8/ locale (not very likely since
     you wouldn't get question marks);

  b) you compiled ImageMagick with IMAGEMAGICK_TTF and

If these are the case, then it's almost certain that fontconfig is
somehow confused with that Microsoft font. For example, see this
thread on XeTeX mailing list about Microsoft YaHei font:

If you use -text directive without -font specified, ImageMagick will
use the fonts from


and this will produce question marks with Japanese UTF-8 string, which
seems to be the case. So, if you don't want to use some free
non-Microsoft font, you can try to do this:

  1) Regenerate fontconfig cache ('fc-cache -f -v' as root).

  2) Check if MS Gothic is visible to ImageMagick, i.e. try

       %convert -list font

     The output should contain

       Font: MS-ゴシック-標準
         family: MS ゴシック
         style: Normal
         stretch: Normal
         weight: 400
         glyphs: /path/to/msgothic.ttc

     in ja_JP.UTF-8, or

       Font: MS-Gothic-Regular
         family: MS Gothic

     in en_US.UTF-8 locale.

  3) Then try

       %convert orig.jpg -font MS-ゴシック-標準 -verbose -fill white \
         -pointsize 125 -stroke blue -strokewidth 1 \
         -draw "text 20,130 'がくせい'" straight.jpg

     if you use ja_JP.* locale (-font MS-Gothic-Regular if you use
     en_US.UTF-8 -- note that the command is locale-sensitive) and see
     if this makes any difference.

Best regards.
- -- 
Nikola Lečić = Никола Лечић
fingerprint : FEF3 66AF C90E EDC3 D878  7CDC 956D F4AB A377 1C9B
Version: GnuPG v2.0.9 (FreeBSD)


More information about the freebsd-questions mailing list