Text shift at different densities

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.
Post Reply
semiadam
Posts: 6
Joined: 2011-06-23T18:39:19-07:00
Authentication code: 8675308

Text shift at different densities

Post by semiadam »

Hello all,

We are encountering unexpected behavior when changing the density for text generation:

Code: Select all

convert -pointsize 24  -density 100 -size 500x200 caption:"IIIIIIIIIIIIIIIIIIIIIIIII\r\nOOOOOOOOO" test1.png

Code: Select all

convert -pointsize 24  -density 200 -size 500x200 caption:"IIIIIIIIIIIIIIIIIIIIIIIII\r\nOOOOOOOOO" test2.png
In the first example above the row of "I"s is shorter than the row of "O"''s, while in the second example "O"s are shorter. (If you can't see this issue please play with different density values).

As far as I understand changing density from 100 to 200 should make everything exactly 2 times bigger, but it's not the case for text. My workaround so far has been to generate everything at a certain density (like 300) and then resample to desired density, but that makes things extremely slow when working with large font sizes. So I thought maybe ImageMagick developers can solve the root issue described above.

I would appreciate your help in advance.

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

Re: Text shift at different densities

Post by fmw42 »

I don't know too much about this, but perhaps you should specify a fixed width font. The default font may not be fixed width and perhaps is subject to the density. But note density is only useful for printing and should have no bearing on the displayed image (as I understand it). However, I will defer to others more expert on this topic.
semiadam
Posts: 6
Joined: 2011-06-23T18:39:19-07:00
Authentication code: 8675308

Re: Text shift at different densities

Post by semiadam »

Thanks. We need to use variety of fonts so fixed width fonts cannot be an option for us, plus that this issue still appears for fixed-width fonts in a different way.

We actually use density for printing. Our output for print file should be generated at 300dpi while it should be generated at a much lower dpi to be scaled for user screen. This text inconsistency between print output and screen output is our problem, which I believe is due to a bug in ImageMagick. I hope IM text experts can find a solution for this.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Text shift at different densities

Post by anthony »

Note that IM itself does not do text rendering.

It passes the job to either the FreeType library or Pango library on Linux and Macs. I am not certain what it uses for Windows.

You can get more specific info by requesting font metrics..
http://www.imagemagick.org/Usage/text/#font_info

Over the years these libraries have changed how they render fonts, even for the same font, and IM version number. One aspect is specifically how they handle sub-pixel rendering and positioning. I myself am having problems on a new Fedora 16 system as the OS specifically turned of some of the sub-pixel anti-aliasing handling the library provides, making the font out rather horrible, until I can apply the OS fix to correct the issue.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply