Text does not wrap correctly

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
arthur
Posts: 7
Joined: 2015-04-03T01:50:18-07:00
Authentication code: 6789

Text does not wrap correctly

Post by arthur »

Hello,

I'm reposting this here since I think it's a bug and not an error on my side.
Can a mod close this duplicate topic viewtopic.php?f=1&t=30375 ?

I am having some issue trying to wrap text in a given width and pointsize.
Here is what I run:

Code: Select all

convert -size 400x -pointsize 50 caption:'This does not wrap' out.png
And this is what I get:
Image

I would expect "wrap" to be on a new line.

I get this result with imagemagick 6.9.5 on OSX and imagemagick 6.7.7 on Ubuntu
Probably same issue http://stackoverflow.com/questions/1158 ... -font-size

Thank you for your help
Arthur
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Text does not wrap correctly

Post by snibgo »

I agree it seems to be a bug.

I won't remove the other topic as it contains information that might be useful. I would merge the topics but when I try clever things like that I end up deleting the universe.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Text does not wrap correctly

Post by fmw42 »

I can repeat it on IM 6.9.5.7 Q16 Mac OSX Snow Leopard. It would seem to be a bug.

But note that if you really do not want the text to wrap, you should use label:. That works fine for the same command.
arthur
Posts: 7
Joined: 2015-04-03T01:50:18-07:00
Authentication code: 6789

Re: Text does not wrap correctly

Post by arthur »

Thank you for your responses. I will try to look around in the code to see I understand anything…

For the label: option, I really do want the text to wrap :P I have a fixed pointsize and width and a variable height.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Text does not wrap correctly

Post by fmw42 »

arthur wrote:For the label: option, I really do want the text to wrap :P I have a fixed pointsize and width and a variable height.
Understood. I was just checking to be sure.

I note that you did not specify a font and took the system default font which on Mac is Arial, I believe. Does it fail for other fonts?

I think the IM developers will need to look into this.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Text does not wrap correctly

Post by GeeMack »

fmw42 wrote:I note that you did not specify a font and took the system default font which on Mac is Arial, I believe. Does it fail for other fonts?
I tested this with a few different fonts running IM7 on Windows 10 64. For example, using this command...

Code: Select all

magick ^
   -fill black ^
   -background white ^
   -font myriad-web-pro ^
   ( -pointsize 15 -size 100x caption:"This does not wrap" ) ^
   ( -pointsize 30 -size 200x caption:"This does not wrap" ) ^
   ( -pointsize 40 -size 300x caption:"This does not wrap" ) ^
   ( -pointsize 45 -size 300x caption:"This does not wrap" ) ^
   ( -pointsize 46 -size 300x caption:"This does not wrap" ) ^
   ( -pointsize 48 -size 300x caption:"This does not wrap" ) ^
   ( -pointsize 48 -size 320x caption:"This does not wrap" ) ^
   ( -pointsize 49 -size 350x caption:"This does not wrap" ) ^
   ( -pointsize 50 -size 350x caption:"This does not wrap" ) ^
   ( -pointsize 50 -size 400x caption:"This does not wrap" ) ^
   ( -pointsize 55 -size 450x caption:"This does not wrap" ) ^
   ( -pointsize 60 -size 450x caption:"This does not wrap" ) ^
   -bordercolor black ^
   -border 2x2 ^
   -bordercolor white ^
   -border 10x10 ^
   -append ^
   -shave 10x10 ^
   -border 20x20 ^
      caption_myriad-web-pro.png
... I get this as the output image...

Image

The error seems to be hit and miss and occurs either with the default font or any specified font. It happens with no "-gravity" setting or with a setting like "-gravity center". It appears to be making the wrapping decision using a fairly narrow combination of pointsize and width, so sometimes it doesn't look like a problem, but changing one factor by just a bit can make it happen.
arthur
Posts: 7
Joined: 2015-04-03T01:50:18-07:00
Authentication code: 6789

Re: Text does not wrap correctly

Post by arthur »

I think I found the issue, I have submitted a pull request to the Github clone https://github.com/ImageMagick/ImageMagick/pull/260
Can a dev let me know if this should be submitted elsewhere?
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Text does not wrap correctly

Post by dlemstra »

Thanks for the patch and that is the correct place. Will take a look at it tonight.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Post Reply