word wrapping detection

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
jpotter
Posts: 7
Joined: 2011-04-18T07:12:43-07:00
Authentication code: 8675308

word wrapping detection

Post by jpotter »

Is there a way to determine where the word wrap will take place (specifically what is the text that is starting on the second line?)


Thanks
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: word wrapping detection

Post by anthony »

Nope not without doing all the calculations yourself!

It gets worse if you specify a full -size for caption but not pointsize. Then the font pointsize will become variable for best fit! That will make it even harder to determine!


Look at Determining Font Metrics
http://www.imagemagick.org/Usage/text/#font_info
this will give you a way to see how long a particular string will be rendered in a specific situation.
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: word wrapping detection

Post by fmw42 »

jpotter wrote:Is there a way to determine where the word wrap will take place (specifically what is the text that is starting on the second line?)


Thanks

Why not just put a \n where you want the break to be!

convert -background lightblue -size 200x -fill blue -font candice label:"This is test 1\nand This is test2\nand test3" test.png

The longest line determines the pointsize for the given width. Thus you know exactly what letter will be at the beginning of each line
Post Reply