Text: first line, accent issue

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
Kree
Posts: 7
Joined: 2015-04-17T12:04:41-07:00
Authentication code: 6789

Text: first line, accent issue

Post by Kree »

Hello guys! I try to create a picture from a text, my command similar like this:

Code: Select all

convert -font Turnpike -pointsize 72 label:"ÖÜÓÚÉÁ\nÖÜÓÚÉÁ" text.png
As you can see, I try to use the Turnpike font, what have accent characters, and they are only visible in the second line, but not in the first:
Image
Which parameter can modify the first line's white space? The -interline-spacing works only between the lines.

Thanks in advance!
Last edited by Kree on 2017-05-13T11:59:04-07:00, edited 1 time in total.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Text: first line, accent issue

Post by dlemstra »

What is your os and version of IM?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Text: first line, accent issue

Post by fmw42 »

I suspect that your font glyphs for that font are not accurately representing the accented symbols. I tried on IM 6.9.8.4 Q16 and they do not work. Whereas arial font works fine.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Text: first line, accent issue

Post by snibgo »

Of course, you can put a \n at the start. At the end, -trim and add a border, if you want.

Code: Select all

convert -font Turnpike -pointsize 72 label:"\nÖÜÓÚÉÁ\nÖÜÓÚÉÁ" -trim -bordercolor White -border 10 text.png
EDIT: In the example, I forgot to put \n at the start.
snibgo's IM pages: im.snibgo.com
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Text: first line, accent issue

Post by GeeMack »

Kree wrote: 2017-05-09T14:07:42-07:00As you can see, I try to use the Turnpike font, what have accent characters, and they are only visible in the second line, but not in the first: [...] Which parameter can modify the first line's white space? The -interline-spacing works only between the lines.
This is going to be an issue with maybe 20% or more of fonts. I ran a quick loop in a directory of monospace fonts I use for labeling scientific images like weather maps and satellite images. Using IM v7.0.5-5 on Windows 10 and a command like this to generate the labels...

Code: Select all

magick -pointsize 48 -font "%FONT%" label:"Å" -gravity center -background #808080 -extent 48x72 test.png
... then assembling them into a montage to create this sampler...

Image

... you can see that a random sampling of fonts will display this problem with a substantial percentage of them. The proportion seems to be similar even with fonts that aren't monospace when I run the loop in a directory with hundreds of fairly common Windows fonts.

I just accept that IM won't print the entire character, so I've developed work-arounds like adding a newline "\n" at the beginning of the label, then trimming and bordering as necessary to get my required size, something like snibgo mentioned above. Another method I use in some scripts is to create the label with white characters on white, then use "-annotate" and "-gravity southwest" to apply black characters to that white label. I've also created the white on white label with one pointsize, then reduced the pointsize before using "-annotate" to print black characters on the label.

None of these "fixes" is ideal, but the issue has come up in the "Bugs" forum, and apparently it isn't something that can be easily fixed in the source code.
Kree
Posts: 7
Joined: 2015-04-17T12:04:41-07:00
Authentication code: 6789

Re: Text: first line, accent issue

Post by Kree »

Thank you guys! This \n beginning and -trim works like a charm! Because of the problem is with the font itself, this hacking is a good solution for me! Thanks again!
Post Reply