Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Dec 2008 19:56:15 +0100
From:      Nikola =?UTF-8?B?TGXEjWnEhw==?= <nikola.lecic@anthesphoria.net>
To:        cuongvt <freebsd@vuhanhnhu.com>
Cc:        FreeBSD-questions@FreeBSD.org
Subject:   Re: imagemagick convert: japanese text broken in freebsd
Message-ID:  <20081214195615.383462e3@anthesphoria.net>
In-Reply-To: <20997257.post@talk.nabble.com>
References:  <20997257.post@talk.nabble.com>

next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

On Sat, 13 Dec 2008 20:20:23 -0800 (PST)
cuongvt <freebsd@vuhanhnhu.com> 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:
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> convert origin.jpg -fill white -font
> /usr/X11R6/lib/X11/fonts/TrueType/msgothic.ttc -pointsize 125 -stroke
> blue -strokewidth 1 -draw "text 20,130 '=E3=81=8C=E3=81=8F=E3=81=9B=E3=81=
=84'" straight.jpg
> =3D=3D=3D=3D=3D=3D=3D=3D
> IM did not informed any error, but the result is japanese text broken
> (question marks).

Hello,

It works for me with ImageMagick-6.4.5.5 and ImageMagick-6.4.7.5.
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
     IMAGEMAGICK_FONTCONFIG.

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:

  http://www.tug.org/pipermail/xetex/2007-May/006539.html

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

  /usr/local/lib/ImageMagick-6.4.7/config/type-ghostscript.xml

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: =EF=BC=AD=EF=BC=B3-=E3=82=B4=E3=82=B7=E3=83=83=E3=82=AF-=E6=A8=
=99=E6=BA=96
         family: =EF=BC=AD=EF=BC=B3 =E3=82=B4=E3=82=B7=E3=83=83=E3=82=AF
         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 =EF=BC=AD=EF=BC=B3-=E3=82=B4=E3=82=B7=E3=83=
=83=E3=82=AF-=E6=A8=99=E6=BA=96 -verbose -fill white \
         -pointsize 125 -stroke blue -strokewidth 1 \
         -draw "text 20,130 '=E3=81=8C=E3=81=8F=E3=81=9B=E3=81=84'" straigh=
t.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.
- --=20
Nikola Le=C4=8Di=C4=87 =3D =D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0 =D0=9B=D0=
=B5=D1=87=D0=B8=D1=9B
fingerprint : FEF3 66AF C90E EDC3 D878  7CDC 956D F4AB A377 1C9B
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (FreeBSD)

iJwEAQEDAAYFAklFVtMACgkQ/MM/0rYIoZin4wP/Zhlf++1GS8jWitrcT0wq0Rkr
cROjjb0DOusXnZnq9LdWac3kjOv5mAUENu7jVy+9rGqvmGhDFkgBi4/mBrcSePGv
cTzSMqsWAeeF+JTizyqJCyRjaz2iOuEjQ1y6zvkOj5D9EE+udXmR6BE7u3HdgZKL
mknYg8Y4ARyu1N+tiOw=3D
=3DW84X
-----END PGP SIGNATURE-----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081214195615.383462e3>