GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
ptast

GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-

Post by ptast »

Hi all,

I just updated to the latest revision of IM and noted that my text is not drawn as before.
I have a special character in my (char *) string (0xB0, degree sign, °)

When I want to know how wide (in pixels) the string will be I use GetTypeMetrics(...). The latest version seems to chop/stops at the special character and wont draw the text after the special character onto the image.

My previous version that drew the text, special character, was 6.4.8-3-Q8

I'm using windows....

Regards,
Patrik

Using DrawInfo params:

draw_info->font = ConstantString("@C:\\WINDOWS\\Fonts\\ARIAL.TTF");
draw_info->pointsize = 12;
draw_info->density = ConstantString("96x96");
draw_info->text_antialias = MagickTrue;
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-

Post by magick »

To debug we'll need a complete source listing that we can build / execute and that only includes code to illustrate the problem. We need to reproduce the problem before we can offer a solution.
ptast

Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-

Post by ptast »

Hi Magick,

Try:
C:\Programming\ImageMagick\ImageMagick-6.5.8-Q8>convert -size 320x85 xc:transpar
ent -pointsize 72 -draw "text 25,60 'Magick'" -channel RGBA -blur 0x6 -fill dark
red -stroke magenta -draw "text 20,55 'Mag°ick'" fuzzy-magick.png



It will look sumthing like this

Image

Or using a font name will produce the same::

C:\Programming\ImageMagick\ImageMagick-6.5.8-Q8>convert -size 320x85 xc:transpar
ent -pointsize 72 -font @C:\\WINDOWS\\Fonts\\verdana.TTF -draw "text 25,60 'Magi
ck'" -channel RGBA -blur 0x6 -fill darkred -stroke magenta -draw "text 20,55 'Ma
g°ick'" fuzzy-magick.png


Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-

Post by fmw42 »

ptast wrote: Try:
C:\Programming\ImageMagick\ImageMagick-6.5.8-Q8>convert -size 320x85 xc:transpar
ent -pointsize 72 -draw "text 25,60 'Magick'" -channel RGBA -blur 0x6 -fill dark
red -stroke magenta -draw "text 20,55 'Mag°ick'" fuzzy-magick.png
You have not specified a font so get some default font which may not support the special degree character.

See Unicode or UTF8 Format Text under http://www.imagemagick.org/Usage/text/#attributes. You may need to provide your text from a file that is UTF-8 compliant rather than typing in the character, which may not support utf-8.
ptast

Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-

Post by ptast »

IM 6.4.8-Q8 will produce the degree sign, 0xB0H

C:\Programming\ImageMagick\ImageMagick-6.4.8-Q8>convert -size 320x85 xc:transpar
ent -pointsize 72 -font @C:\\WINDOWS\\Fonts\\verdana.TTF -draw "text 25,60 'Magi
ck'" -channel RGBA -blur 0x6 -fill darkred -stroke magenta -draw "text 20,55 'Ma
g°ick'" fuzzy-magick.png


Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-

Post by fmw42 »

I get a similar result to your last example showing the degree sign and all text with IM 6.5.8-6 Q16 Mac OSX Tiger using:

convert -size 320x85 xc:transparent -pointsize 72 -font Verdana \
-draw "text 25,60 'Magick'" -channel RGBA -blur 0x6 -fill darkred \
-stroke magenta -draw "text 20,55 'Mag°ick'" tmp.png

or

convert -size 320x85 xc:transparent -pointsize 72 -font Verdana \
-draw "text 25,60 'Magick'" -channel RGBA -alpha on -blur 0x6 -fill darkred \
-stroke magenta -draw "text 20,55 'Mag°ick'" tmp.png
ptast

Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-

Post by ptast »

Oh,

So you see the degree sign in 6.5.8-6 on Tiger? I do not, it chops the text at the deg sign . Rest is flushed. Could this be a Mr Gates issue then? Well it worked in version 6.4.8-Q8...

I'm not a newbie in IM, been using it (magick C) since 2003
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-

Post by fmw42 »

yes, i see the whole text and the degree symbol.

what happens if you remove the @ symbol from your font file path? sorry I am not a windows user, so don't know what special things you need to do. see http://www.imagemagick.org/Usage/windows/

try adding -alpha on after -channel rgba

has your font changes or been corrupted? try Helvetica or Arial and see what happens.

don't know what else to have you try
ptast

Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-

Post by ptast »

I reverted to version 6.5.5-Q8 and tried a different font, arial and the "problem" persists

C:\Programming\ImageMagick\ImageMagick-6.5.5-Q8>convert -size 320x85 xc:transpar
ent -pointsize 72 -font @C:\\WINDOWS\\Fonts\\arial.TTF -draw "text 25,60 'Magick
'" -channel RGBA -blur 0x6 -fill darkred -stroke magenta -draw "text 20,55 'Mag°
ick'" fuzzy-magick.png


Image

I will try to find and diff source code of IM 6.4.8 if I can find the "issue". I just tried the same on fedora 9 6.4.7-7 and it worked as expected

Fedora 9
Image

I will upgrade the fedora machine also and see if it persists. The degree sign is quite important in remote sensing....
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-

Post by magick »

Convert your text to UTF-8. We suspect that will fix the problem.
ptast

Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-

Post by ptast »

How do I convert to UTF-8 when I tell in magick C using DrawImage(....) drawinfo->primitive = ConstantString("Mag°ick");

I just wonder why it works on 6.4.8 and below and not above? There sure is sumthing wicked?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-

Post by fmw42 »

The only way I have been able to use utf-8 characters is by creating a file with the text in a utf-8 compliant text editor and then referencing the file rather than the text.

see http://www.imagemagick.org/Usage/text/#unicode

However, this does not explain why I can get it to work on my Mac, your Fedora system works, but your Windows system does not.

The other thing is to be sure you quote and escape properly for Windows. The IM syntax is slightly different for Window and Unix. See http://www.imagemagick.org/Usage/windows/
ptast

Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-

Post by ptast »

Yeah, no luck there either using an IM ver > 6.4.8. I also tried Anthony's example and not a single character was rendered

convert -background lightblue -fill blue -pointsize 32 \
label:' é è à ù ç Ö ÿ ‘ ’ “ ” ° ² ³ € x ÷ ' label_i8n.gif


I bet there is a trivial solution but for now I will have to revert to IM 6.4.8, it works like Magick.

I didn't find 6.4.8 in SVN, branches/ImageMagick-6.4.8, so I could not diff on the latest.

Many thanks for your help, it will be solved someday....
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-

Post by fmw42 »

When I copy and paste Anthony's example from your post, I get the following which seems to work fine on my Mac OSX Tiger, IM 6.5.8-7 Q16

convert -background lightblue -fill blue -pointsize 32 \
> label:' \303\251 \303\250 \303\240 \303\271 \303\247 \303\226 \303\277 \342\200\230 \342\200\231 \342\200\234 \342\200\235 \302\260 \302\262 \302\263 \342\202\254 x \303\267 ' label_i8n.gif
ptast

Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-

Post by ptast »

No luck on Mr Gates XP, just numbers were rendered using your example.

It does find height of the "special" character but not width. I wonder if "my" TTF are incomatible though they are standard windows.
C:\Programming\ImageMagick\ImageMagick-6.5.8-Q8>convert -version -background lightblue -fill blue -pointsize 3
2 label:"°" -debug "Annotate" test.png
Version: ImageMagick 6.5.8-7 2009-12-13 Q8 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

2009-12-20T01:06:11+02:00 0:00.031 0.031u 6.5.8 Annotate convert[2880]: annotate.c/RenderFreetype/1139/Annotat
e
Font c:\windows\fonts\arial.ttf; font-encoding none; text-encoding none; pointsize 32
2009-12-20T01:06:11+02:00 0:00.031 0.031u 6.5.8 Annotate convert[2880]: annotate.c/GetTypeMetrics/733/Annotate

Metrics: text: °; width: 0; height: 37; ascent: 29; descent: -7; max advance: 64; bounds: 0,-0.109375 0.343
75,0.34375; origin: 0,0; pixels per em: 32,32; underline position: -3.39063; underline thickness: 2.34375
2009-12-20T01:06:11+02:00 0:00.062 0.047u 6.5.8 Annotate convert[2880]: annotate.c/RenderFreetype/1139/Annotat
e
Font c:\windows\fonts\arial.ttf; font-encoding none; text-encoding none; pointsize 32
2009-12-20T01:06:11+02:00 0:00.062 0.047u 6.5.8 Annotate convert[2880]: annotate.c/GetTypeMetrics/733/Annotate

Metrics: text: °; width: 0; height: 37; ascent: 29; descent: -7; max advance: 64; bounds: 0,-0.109375 0.343
75,0.34375; origin: 0,0; pixels per em: 32,32; underline position: -3.39063; underline thickness: 2.34375
2009-12-20T01:06:11+02:00 0:00.078 0.063u 6.5.8 Annotate convert[2880]: annotate.c/RenderFreetype/1139/Annotat
e
Font c:\windows\fonts\arial.ttf; font-encoding none; text-encoding none; pointsize 32
And "working" version:
C:\Programming\ImageMagick\ImageMagick-6.4.8-Q8>convert -version -background lightblue -fill blue -pointsize 3
2 label:"°" -debug "Annotate" test.png
Version: ImageMagick 6.4.8 2008-12-27 Q8 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC

2009-12-19T23:12:24+00:00 0:01 0.203u 6.4.8 Annotate convert[524]: annotate.c/RenderFreetype/1451/Annotate
Font c:\windows\fonts\arial.ttf; font-encoding none; text-encoding none; pointsize 32
2009-12-19T23:12:24+00:00 0:01 0.203u 6.4.8 Annotate convert[524]: annotate.c/GetTypeMetrics/1001/Annotate
Metrics: text: ░; width: 10; height: 37; ascent: 29; descent: -7; max advance: 64; bounds: 2,14 11,23; orig
in: 13,0; pixels per em: 32,32; underline position: -3.39063; underline thickness: 2.34375
2009-12-19T23:12:24+00:00 0:01 0.203u 6.4.8 Annotate convert[524]: annotate.c/RenderFreetype/1451/Annotate
Font c:\windows\fonts\arial.ttf; font-encoding none; text-encoding none; pointsize 32
2009-12-19T23:12:24+00:00 0:01 0.203u 6.4.8 Annotate convert[524]: annotate.c/GetTypeMetrics/1001/Annotate
Metrics: text: ░; width: 10; height: 37; ascent: 29; descent: -7; max advance: 64; bounds: 2,14 11,23; orig
in: 13,0; pixels per em: 32,32; underline position: -3.39063; underline thickness: 2.34375
2009-12-19T23:12:24+00:00 0:01 0.203u 6.4.8 Annotate convert[524]: annotate.c/RenderFreetype/1451/Annotate
Font c:\windows\fonts\arial.ttf; font-encoding none; text-encoding none; pointsize 32
Post Reply