Font rendering problem

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Douwe
Posts: 3
Joined: 2012-11-21T09:28:10-07:00
Authentication code: 6789

Font rendering problem

Post by Douwe »

Hi all,

Using Imagemagick's convert (6.7.3-4) on the command line I noticed a difference between the way flash/photoshop renders a font as compared to imagemagick:

Flash/Photoshop:

Image

ImageMagick:

Image

Notice the difference in the way the tekst is spread out like a wave in flash and photoshop, this effect seems ommited by ImageMagick.

I'm using a command generated by a script that boils down to something like this:

Code: Select all

convert -size 222x144 -font myfont text 'bla bla bla'

My question is ofcourse:

Is it possible to achieve the same effect in ImageMagick?
And maybe some insight into what property(s) of a font cause this effect, my knowledge of fonts is basic to say the least, but I'm willing to learn.

Regards,

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

Re: Font rendering problem

Post by fmw42 »

convert -size 222x144 -font myfont text 'bla bla bla'
This is an incomplete command. You need to add something like either caption:"bla bla bla" or PANGO:"bla bla bla". Then you have to tile the result to what final size you want or provide the right number of "bla" in your text line.

If you command is different than above, please post the full command. If possible provide the font or fontname as well. It is hard to tell you what is going on without more details

see
http://www.imagemagick.org/Usage/text/#caption
http://www.imagemagick.org/Usage/text/#pango (note pango delegate must be installed and IM recompiled to use it)
Douwe
Posts: 3
Joined: 2012-11-21T09:28:10-07:00
Authentication code: 6789

Re: Font rendering problem

Post by Douwe »

Hi, thanks for your reply.

The complete command would be:

Code: Select all

convert -size 568x376 xc:none -font fontcache/36.ttf -density 72 -pointsize 400.71428571658 -interline-spacing 0 -gravity center -stroke none -fill "black" -draw @tmp/gentext50adea61.mvg tmp/gentext50adea61.png
Where the .mvg that holds the text would contain

Code: Select all

scale 0.1816732673268,0.1816732673268 text +0,+0 'bla bla bla bla
bla bla bla bla
bla bla bla bla
bla bla bla bla'
Using caption or annotate was abandoned because of (if i'm not mistaken, its been a while) very subtle scaling/positioning issues, pango we haven't tried yet. The reason we use the .mvg file for the actual text was because of some obscure weirdness happening with some german and french characters when passed directly to the (ubuntu server) shell.

I'm pretty sure it's something more or less specific to this (type of) font though, as the application this is part of has been running for quite a while now with a limited set of other fonts.

I think this is the font that was used (I had to check with a coworker first):

http://www.dafont.com/earwig-factory.font

On this page it says 'In OpenType savvy applications, letters and numerals are pseudorandomized for a more natural effect.'

This sounds like a clue to me, could it be that ImageMagick the way we use it is not 'OpenType savvy'?

Regards,

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

Re: Font rendering problem

Post by fmw42 »

I get your same results (though the image is the right size). Perhaps -draw is not sophisticated enough to deal with the randomization of the font orientation.
Douwe
Posts: 3
Joined: 2012-11-21T09:28:10-07:00
Authentication code: 6789

Re: Font rendering problem

Post by Douwe »

Nor is caption, at least not using this command:

Code: Select all

convert -background lightblue  -fill blue  -font fontcache/36.ttf -pointsize 36 -size 320x   caption:'bla bla bla bla bla bla' tmp/caption.png
Anyone any ideas?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Font rendering problem

Post by anthony »

Looks more like the density is different. IM uses a default density of 72 dpi, as it has not 'output device'.

Photoshop as a GUI program has a monitor as the output device, and from this it probably picked up a density of something like 90 or 100 dpi.

Thus the different sized font (in pixels, rather than points).

See Text Handling, Pointsize and Density
http://www.imagemagick.org/Usage/text/#pointsize
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Font rendering problem

Post by fmw42 »

Anthony,

I think the issue is that the font orientation is not getting randomized, which I suspect IM cannot handle, though am not sure.

Fred
Post Reply