Issue with rendering text with exclamation point at the end

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?".
GarbageSauce
Posts: 23
Joined: 2016-12-08T19:43:17-07:00
Authentication code: 1151

Issue with rendering text with exclamation point at the end

Post by GarbageSauce »

Hi guys. So this line here

Code: Select all

magick -background none -fill #000000 -font H:/python27/fonts/BW-penn.ttf -size x90 -gravity center label:"GO TIGERS!" asdf.png
Renders with the G clipped off. Removing the -gravity center argument does fix the problem although the text gets moved a tad. Is there a way to fix this?

Since the font I am forced to use doesn't exist anywhere else, you can download it here. This problem doesn't exist with the default ImageMagick font.
http://www.filedropper.com/bw-penn
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Issue with rendering text with exclamation point at the end

Post by fmw42 »

You have to escape the !. On unix \! and on windows ^!

If that does not work, then it is the font glyph set that is bad.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Issue with rendering text with exclamation point at the end

Post by GeeMack »

GarbageSauce wrote:Renders with the G clipped off. Removing the -gravity center argument does fix the problem although the text gets moved a tad. Is there a way to fix this?
Using IM 7.0.3-9 on Windows 10, I get the same result, the clipped off "G", using any monospace font. I tried some very common Windows fonts like Consolas and Courier-New, and a couple less common monospace fonts I use for numbering tickets, etc. I'd call this a bug, and it should probably be added to the Bugs section of the forum.

Some fonts I use have particular glyphs that spill outside the bounding box, especially when using less common characters like "Å" or some symbols. As a workaround I often add a space and a newline before and after the text, then clean it down with "-trim", then re-add a specified border. It's clunky, but it does what I need. The command would look something like this...

Code: Select all

magick -background none -bordercolor none -fill black ^
    -font Courier-New -size x90 label:"\n YOUR TEXT HERE! \n" -trim -border 5x5 output.png
But yes, your issue looks like a bug that should be repaired by the developers.

EDITED TO ADD: With some additional testing it looks like some of my proportional fonts also exhibit this issue. If you use fmw42's suggestion and escape the exclamation points with a backslash "\!" it doesn't seem to cause that problem.
GarbageSauce
Posts: 23
Joined: 2016-12-08T19:43:17-07:00
Authentication code: 1151

Re: Issue with rendering text with exclamation point at the end

Post by GarbageSauce »

Thanks man. Your method seems to work. It does seem a bit scary since the only way to get the text to return to its original size is by increasing x90 to x410. Yikes. But thanks again. I'll report the bug.

EDIT: I didn't see the other posts. The thing with adding \n works great. I tried both "GO TIGERS^!" and "GO TIGERS"^! and both didn't work. The first one adds a star before the exclamation point (lol?) and the second just straight up doesn't work.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Issue with rendering text with exclamation point at the end

Post by fmw42 »

^! is for Windows. You cannot use that on Unix. On Unix, you need to use \!

Using \! on my Mac with your font worked fine. No cut off or loss of characters.

Code: Select all

im7 magick -background none -fill "#000000" -font /library/fonts/BW-penn.ttf -size x90 -gravity center label:"GO TIGERS\!" asdf.png
Also on unix, hex colors need quoting
GarbageSauce
Posts: 23
Joined: 2016-12-08T19:43:17-07:00
Authentication code: 1151

Re: Issue with rendering text with exclamation point at the end

Post by GarbageSauce »

I am using Windows. :P
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Issue with rendering text with exclamation point at the end

Post by fmw42 »

Windows needs \ for directories, does it not? Unless you are using cygwin. If you are then you need unix escapes \!

H:/python27/fonts/BW-penn.ttt should be? H:\python27\fonts/BW-penn.ttf
GarbageSauce
Posts: 23
Joined: 2016-12-08T19:43:17-07:00
Authentication code: 1151

Re: Issue with rendering text with exclamation point at the end

Post by GarbageSauce »

I tried all 4 combinations of forward slash, backward slash, inside quotes, and outside quotes. Still nothing.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Issue with rendering text with exclamation point at the end

Post by fmw42 »

I am not a Windows user, so do not know Windows syntax well. But what is your IM version and Windows version and are you using cygwin or not?
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Issue with rendering text with exclamation point at the end

Post by GeeMack »

fmw42 wrote:^! is for Windows. You cannot use that on Unix. On Unix, you need to use \!
*** Edited to delete an incorrect comment.
Last edited by GeeMack on 2016-12-08T21:26:50-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Issue with rendering text with exclamation point at the end

Post by fmw42 »

What misalignment issue?
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Issue with rendering text with exclamation point at the end

Post by GeeMack »

fmw42 wrote:What misalignment issue?
The OP's issue with the first character in a label getting clipped if the gravity is set to center. Even more experiments show me that the gravity setting is the issue. If I get a few minutes I'll try to post some samples of the results.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Issue with rendering text with exclamation point at the end

Post by fmw42 »

If so, then report it on the bugs forum. Be sure it is not bad font glyphs for that particular font glyph set. Not all fonts with the same name have equally defined glyphs.
GarbageSauce
Posts: 23
Joined: 2016-12-08T19:43:17-07:00
Authentication code: 1151

Re: Issue with rendering text with exclamation point at the end

Post by GarbageSauce »

I am using ImageMagick-7.0.3-9-Q16-x64-static.exe and no cygwin.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Issue with rendering text with exclamation point at the end

Post by fmw42 »

If this does not work, then you will need a Windows user to correct my syntax.

Code: Select all

magick -background none -fill #000000 -font H:\python27\fonts\BW-penn.ttf -size x90 -gravity center label:"GO TIGERS^!" asdf.png
Post Reply