Page 1 of 1

Top row of caption is cropped, resulting in missing diacritics

Posted: 2018-08-26T23:53:13-07:00
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?

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

Posted: 2018-08-27T00:13:09-07:00
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.

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

Posted: 2018-08-27T00:29:08-07:00
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!

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

Posted: 2018-08-27T01:10:05-07:00
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.

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

Posted: 2018-08-27T08:22:14-07:00
by fmw42
FYI, IM 7.0.8.11 is still in beta.

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

Posted: 2018-08-28T00:25:30-07:00
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.

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

Posted: 2018-08-28T05:33:37-07:00
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.