Open latortuga opened 10 years ago
Can you describe the issue you had, if possible a small ruby example. Thanks
Moncef
From: Drew Ulmer [mailto:notifications@github.com] Sent: Friday, November 01, 2013 2:38 PM To: rmagick/rmagick Subject: [rmagick] Draw#get_type_metrics incorrectly raises an exception on %% (#92)
This line causes '%%' to be included in the list of "image attributes" special escape sequences but '%%' is the escape sequence for a percentage sign, not for any image attributes (per the RMagick documentation, directly above the table here http://studio.imagemagick.org/RMagick/doc/draw.html#spec_chars_table ), and thus should not raise an exception.
— Reply to this email directly or view it on GitHub https://github.com/rmagick/rmagick/issues/92 . https://github.com/notifications/beacon/HKC725hRsTASxMa1bpFbvNfn5dgtt2W5-m0JKdY0VendmerpNISnNn2MfH8lWFXb.gif
label = Magick::Draw.new
word = "100%%"
label.get_type_metrics(word) # => Throws an exception
We ran into this because we were escaping all % signs with "%%" per the documentation I linked above. It turned out that if you don't escape the % in this situation it also works fine but IMHO it is erroneous to include the '%%' flag in the check on the line I linked because '%%' is not an escape sequence for image attributes. I made a fork and fixed it as close to the exception as I could and it is in production for us right now, working fine.
‘%%’ is used for annotate to output the character ‘%’. Anywhere else to output ‘%’ just use ‘%’. This was change by ImageMagick starting version 6.3.3.
When you ask for a metric ‘%%’ we should raise an exception as there is no such metric. The code as is is right.
Regards,
Moncef
I have the same problem. I would like to measure any kind of text, also those including %a, %b, etc. and escape variable placeholders before doing actual measurement. I followed documentation on this page: http://www.imagemagick.org/RMagick/doc/draw.html#spec_chars_table and escaped % by prepending it with another %. That should do the trick but it didn't work.
BTW. the documentation differs from the code. There are more special characters in the code than in the documentation: https://github.com/rmagick/rmagick/blob/master/ext/RMagick/rmdraw.c
static char attrs[] = "OPbcdefghiklmnopqrstuwxyz[@#%";
https://github.com/rmagick/rmagick/blob/962d56cba3a132d590be1dd062f2a3a2efa48545/ext/RMagick/rmdraw.c#L1917
This line causes '%%' to be included in the list of "image attributes" special escape sequences but '%%' is the escape sequence for a percentage sign, not for any image attributes (per the RMagick documentation, directly above the table here), and thus should not raise an exception.