fontTypeMetrics() returns as single line though given multil

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
persanker1
Posts: 2
Joined: 2011-06-26T05:47:03-07:00
Authentication code: 8675308

fontTypeMetrics() returns as single line though given multil

Post by persanker1 »

fontTypeMetrics() returns metrics as single line for text "A\r\nB", for example 300*150 . But the text drawn on the image seems to be 150*300(2 lines).
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: fontTypeMetrics() returns as single line though given mu

Post by anthony »

Not surprising the newline and return characters are nor real characters but formatting controls, that applications would pull out to reposition the cursor appropriately.

Applications do not request font metrics for such characters as that does not make any sense!

font metrics are meant to find how much space individual characters and words, perhaps even the words with a default word spacing. Applications are then supposed to use that information to figure out if it needs to squeeze or expand spacing, or word-wrap words to the next line and so on. Newlines and Returns are not part of that calculation.

IM is also not a word processor, it only has minimal text to image handling. enough to allow annotation and labeling, nto for generating text pages. If this is what you need you are better off looking at some other text to raster image tool, like, Pango, TeX, LaTeX, and so on.

One method is convert your text to postscript (which means all layout decisions have already been made) and then have IM run the ghostscript program to convert that to a raster image. Or use TeX and LaTeX to generate DVI, that is just one step from either postscript, or raster images.

see IM examples, A Complete Text Processing System (alternatives)
http://www.imagemagick.org/Usage/text/#tex
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply