Page 1 of 2
GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-
Posted: 2009-12-18T02:58:36-07:00
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;
Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-
Posted: 2009-12-18T06:41:47-07:00
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.
Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-
Posted: 2009-12-18T10:54:26-07:00
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
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
Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-
Posted: 2009-12-18T11:08:19-07:00
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.
Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-
Posted: 2009-12-18T11:18:36-07:00
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
Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-
Posted: 2009-12-18T11:31:14-07:00
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
Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-
Posted: 2009-12-18T11:42:08-07:00
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
Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-
Posted: 2009-12-18T12:06:32-07:00
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
Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-
Posted: 2009-12-18T12:34:08-07:00
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
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
I will upgrade the fedora machine also and see if it persists. The degree sign is quite important in remote sensing....
Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-
Posted: 2009-12-18T12:43:50-07:00
by magick
Convert your text to UTF-8. We suspect that will fix the problem.
Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-
Posted: 2009-12-18T13:10:22-07:00
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?
Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-
Posted: 2009-12-18T17:41:42-07:00
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/
Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-
Posted: 2009-12-19T01:49:13-07:00
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....
Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-
Posted: 2009-12-19T11:56:29-07:00
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
Re: GetTypeMetrics(...) issue in ImageMagick-6.5.8-6-
Posted: 2009-12-19T16:13:35-07:00
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