interline-spacing: width or height exceeds limit

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
roallen
Posts: 5
Joined: 2020-01-14T05:37:20-07:00
Authentication code: 1152

interline-spacing: width or height exceeds limit

Post by roallen »

When doing multi-line text of unknown length for a set width image (need the text to scale automatically instead of using -pointsize) with a custom web font, the new line leaves a significant gap between the two lines and -interline-spacing only reduces it by a little. Is it possible to do two lines of scaled text but position them closer together? I've tried doing two separate -font sequences and using North and South gravity but it still leaves a big gap.

> magick -interline-spacing -35 -size 680x400 -background none -gravity center -font Poppins-Regular.ttf label:"Interline\nSpacing" label.png

If I keep increasing interline-spacing, it eventually comes back with the following error even though there is still a big gap:

> magick -interline-spacing -40 -size 680x400 -background none -gravity center -font Poppins-Regular.ttf label:"Interline\nSpacing" label.png

magick: width or height exceeds limit `Interline\nSpacing' @ error/annotate.c/GetMultilineTypeMetrics/767.


* This issue has applied to any font I've tried. Here is Poppins: https://github.com/google/fonts/blob/ma ... egular.ttf

snibgo
Posts: 12922
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: interline-spacing: width or height exceeds limit

Post by snibgo »

Sorry, I don't know how to solve the "-interline-spacing" problem.

A workaround is to make two label images and append them.

Code: Select all

magick -size 680x400 -background none -gravity center  label:"Interline" label:"Spacing" -trim -append insterspace.png
Image
If you want a space between the labels, create a blank image. But then we can't trim all the images, so the command is more complex. Windows CMD syntax:

Code: Select all

magick ^
  -background none -gravity center ^
  ( -size 680x400  label:"Interline" -trim ) ^
  -size 1x15 xc:None ^
  ( -size 680x400 label:"Spacing" -trim ) ^
  -append ^
  insterspace2.png
Image
snibgo's IM pages: im.snibgo.com

User avatar
magick
Site Admin
Posts: 11220
Joined: 2003-05-31T11:32:55-07:00

Re: interline-spacing: width or height exceeds limit

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.

roallen
Posts: 5
Joined: 2020-01-14T05:37:20-07:00
Authentication code: 1152

Re: interline-spacing: width or height exceeds limit

Post by roallen »

Awesome. Thank you for both the workaround (works perfectly for me) and the upcoming fix!

Post Reply