Top row of caption is cropped, resulting in missing diacritics

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
picdek
Posts: 3
Joined: 2018-08-24T07:05:45-07:00
Authentication code: 1152

Top row of caption is cropped, resulting in missing diacritics

Post by picdek »

I have a problem which arises when I render a text with certain fonts. For some reason, the diacritics are cut off from the letters at the top row when I render a text using caption. Here's an example using the Helvetica font:

Code: Select all

magick -background black -fill white -pointsize 90 -density 90 -size 460x -interline-spacing 20 -font Helvetica caption:'Å Ö Å Ö Å Ö Å Ö Å Ö Å Ö Å Ö Å' ~/font_test.png
Image
I'm on Ubuntu 18.04, and I'm using ImageMagick version 7.0.8-11 Q16 x86_64.

How do I stop the top row diacritics from getting cut off?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Top row of caption is cropped, resulting in missing diacritics

Post by snibgo »

What version of IM?

It works fine for me, with the default font Arial, IM v7.0.7-28. I don't have the Helvetica font.

If your string starts with \n you will get blank space at the top, which you can then "-trim" off.
snibgo's IM pages: im.snibgo.com
picdek
Posts: 3
Joined: 2018-08-24T07:05:45-07:00
Authentication code: 1152

Re: Top row of caption is cropped, resulting in missing diacritics

Post by picdek »

snibgo wrote: 2018-08-27T00:13:09-07:00 What version of IM?
7.0.8-11, as stated in my post.
snibgo wrote: 2018-08-27T00:13:09-07:00It works fine for me, with the default font Arial, IM v7.0.7-28. I don't have the Helvetica font.
As I said, this is not limited to just Helvetica (which by the way is available in the gsfonts package if you're using Ubuntu). Not all fonts are affected, but it's certainly a widespread problem. This short little snippet creates an image using every font on your system, and many of the resulting texts do get cut off:

Code: Select all

for font in $(magick -list font | grep "Font:" | awk '{print $2;}'); do magick -background black -fill white -pointsize 90 -density 90 -size 460x -interline-spacing 20 -font $font caption:'Å Ö Å Ö Å Ö Å Ö Å Ö Å Ö Å Ö Å' ~/${font}.png; done
snibgo wrote: 2018-08-27T00:13:09-07:00If your string starts with \n you will get blank space at the top, which you can then "-trim" off.
That's a great workaround, actually. Thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Top row of caption is cropped, resulting in missing diacritics

Post by snibgo »

picdek wrote:7.0.8-11, as stated in my post.
Yeah, sorry, I haven't had my first coffee yet.

That's a neat test. I see what you mean about the fonts. On my computer (Windows 8.1), about a third show the problem.

I don't know if the problem is in the fonts writing the diacriticals outside the glyph boundary, or the freetype library, or IM.
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: Top row of caption is cropped, resulting in missing diacritics

Post by fmw42 »

FYI, IM 7.0.8.11 is still in beta.
picdek
Posts: 3
Joined: 2018-08-24T07:05:45-07:00
Authentication code: 1152

Re: Top row of caption is cropped, resulting in missing diacritics

Post by picdek »

snibgo wrote: 2018-08-27T01:10:05-07:00 That's a neat test. I see what you mean about the fonts. On my computer (Windows 8.1), about a third show the problem.

I don't know if the problem is in the fonts writing the diacriticals outside the glyph boundary, or the freetype library, or IM.
Alright, so it's not just Linux that's affected then. Good to know.

Your workaround works fine, so I'm not too keen on going on a hunt for the root cause, but should I do it, I'll share my findings.
fmw42 wrote: 2018-08-27T08:22:14-07:00 FYI, IM 7.0.8.11 is still in beta.
Just built and installed 7.0.8-10, and it suffers from the same problem.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Top row of caption is cropped, resulting in missing diacritics

Post by magick »

Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ http://www.imagemagick.org/download/beta/ by sometime tomorrow.
Post Reply