Convert and Pango Issues

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
Jeremy
Posts: 16
Joined: 2016-04-12T15:28:20-07:00
Authentication code: 1151

Convert and Pango Issues

Post by Jeremy »

I'm attempting to run a convert command from the command line. The font I'm using has ligatures so I need to use pango. However pango doesn't seem to want to work or recognize the font where label or caption does. My command is:

convert -font test-Regular.ttf -pointsize 124 PANGO:"ac" pango.png - doesn't work

convert -font test-Regular.ttf -pointsize 124 label:"ac" label.png - works

When I run convert -version I get:

Version: ImageMagick 6.9.10-24 Q16 x86_64 2019-01-12 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype jng jp2 jpeg lcms ltdl lzma openexr pangocairo png rsvg tiff webp wmf x xml zlib


Any ideas?

Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert and Pango Issues

Post by fmw42 »

Where can we get test-Regular.ttf to test? If that is a custom font, the please post a link to a copy of it.

Try specifying the font inside the PANGO markup language. See https://imagemagick.org/Usage/text/#pango
Jeremy
Posts: 16
Joined: 2016-04-12T15:28:20-07:00
Authentication code: 1151

Re: Convert and Pango Issues

Post by Jeremy »

Check your pms
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert and Pango Issues

Post by fmw42 »

Sorry, I am not having any success either with your font and Pango.

I tried:

Code: Select all

convert -font jeremy-Regular.ttf -pointsize 124 PANGO:"ac" pango.png

and

convert PANGO:'<span font="jeremy-Regular.ttf" size="126976">ac</span>' pango.png

and

convert -font jeremy-Regular.ttf -pointsize 124 PANGO:"@test.txt" pango.png

where test.txt was a UTF-8 compatible text file contains and showing your actual characters.

Using IM 6.9.10.24 Q16 Mac OSX.

However, this works:

Code: Select all

convert -font /Library/fonts/jeremy-Regular.ttf -pointsize 124 CAPTION:"@test.txt" pango.png
Jeremy
Posts: 16
Joined: 2016-04-12T15:28:20-07:00
Authentication code: 1151

Re: Convert and Pango Issues

Post by Jeremy »

Yeah maybe I made the font wrong. I'm going to take a closer look at it. I'll report back once I find out anything out. Thanks for your help!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert and Pango Issues

Post by snibgo »

As far as I know, pango needs the font to be installed at the system level, rather than simply using a font file.
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: Convert and Pango Issues

Post by fmw42 »

Your font is fine. See my additional comment above and here. Put the text showing your characters in a UTF-compatible text editor file and then specify the file in the CAPTION with the @ symbol as below. The following works for me.

Code: Select all

convert -font /Library/fonts/jeremy-Regular.ttf -pointsize 124 CAPTION:"@test.txt" pango.png
See https://imagemagick.org/Usage/text/#unicode
Jeremy
Posts: 16
Joined: 2016-04-12T15:28:20-07:00
Authentication code: 1151

Re: Convert and Pango Issues

Post by Jeremy »

Alright, I'm narrowing it down, I think Pango isn't installed right as it doesn't seem to work with any fonts at all for me.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert and Pango Issues

Post by fmw42 »

Did you follow my command using CAPTION? Did that work? You should not need PANGO as CAPTION does work if you specify a UTF-8 compatible text file with your text in your actual font.

Note snigbo's last comment about installing fonts into the System.
Jeremy
Posts: 16
Joined: 2016-04-12T15:28:20-07:00
Authentication code: 1151

Re: Convert and Pango Issues

Post by Jeremy »

Caption didn't really work for me and PANGO doesn't seem to work with Imagick. I need to spend sometime digging into convert and exec.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert and Pango Issues

Post by fmw42 »

To use CAPTION properly, you need to put your text into UTF-8 compatible text file that shows your characters properly. Then use @textfile.txt to load that text into CAPTION. See the link I provided.
Jeremy
Posts: 16
Joined: 2016-04-12T15:28:20-07:00
Authentication code: 1151

Re: Convert and Pango Issues

Post by Jeremy »

Thanks!

Anyway this works:
convert PANGO:"<span font_family="jeremy" size="126976">ac</span>" pango.png.

It doesn't however seem to work from a PHP exec. I'm sure I'm just missing something small.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert and Pango Issues

Post by fmw42 »

PHP uses different environment variables than your OS. So you might try putting the full path to convert in your exec() command
Post Reply