convert & pango - "couldn't load font"

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?".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert & pango - "couldn't load font"

Post by fmw42 »

What types of fonts do not work. ImageMagick cannot use every type of font. Limitations come from either freetype or fontconfig delegate libraries. I am not sure of the limitations of PANGO. It may be restricted on the types of fonts it can use. But I am not an expert of PANGO and what fonts it can use. You should check with those tools to see what limitations they have on font types.
HiRezGuy
Posts: 19
Joined: 2018-06-24T08:26:07-07:00
Authentication code: 1152

Re: convert & pango - "couldn't load font"

Post by HiRezGuy »

Thanks a lot for your response. I am running under win10.

Should I use this "type" file?
http://www.imagemagick.org/source/type-windows.xml

type-windows.xml seems to have most of the fonts on my system.

But type-windows.xml was not included with the portable installation.

Should I set $MAGICK_HOME manually for a portable install under win10?

The unix perl script imagick_type_gen seems like a good one; I was kind of thinking I may need to write one, but someone already has. It shouldn't be too difficult to get working under win10.
HiRezGuy
Posts: 19
Joined: 2018-06-24T08:26:07-07:00
Authentication code: 1152

Re: convert & pango - "couldn't load font"

Post by HiRezGuy »

fmw42 wrote: 2018-07-20T13:19:20-07:00 What types of fonts do not work. ImageMagick cannot use every type of font. Limitations come from either freetype or fontconfig delegate libraries. I am not sure of the limitations of PANGO. It may be restricted on the types of fonts it can use. But I am not an expert of PANGO and what fonts it can use. You should check with those tools to see what limitations they have on font types.
In the last response before my first response today, I posted a list of the fonts that work.

I have a feeling you mean "types of fonts" in a way that's more than just listing dir's and stuff. (In other words, I know almost nothing about fonts other than I use the ones I like. I have about the same knowledge of images and the various formats. Sorry about that gents.)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert & pango - "couldn't load font"

Post by fmw42 »

I was asking about .ttf vs other types (suffixes). Which suffix type fails or is it font by font irrespective of the type of font?
HiRezGuy
Posts: 19
Joined: 2018-06-24T08:26:07-07:00
Authentication code: 1152

Re: convert & pango - "couldn't load font"

Post by HiRezGuy »

A bit of background.

Basically, I am trying to figure out how I will package IM_portable_Win10 with my project (MS VS 2017). In this respect, I am trying to figure out what will need to be configured up-front (like available fonts, ENV variables, etc.) so that selections can be limited (if necessary), configuration files updated (if necessary), and to make the process easy to use.

Thanks again.
HiRezGuy
Posts: 19
Joined: 2018-06-24T08:26:07-07:00
Authentication code: 1152

Re: convert & pango - "couldn't load font"

Post by HiRezGuy »

fmw42 wrote: 2018-07-20T14:35:28-07:00 I was asking about .ttf vs other types (suffixes). Which suffix type fails or is it font by font irrespective of the type of font?
I think that last post before my posts today has those fonts listed. I will review those lists and confirm back so you aren't wasting your time on this.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert & pango - "couldn't load font"

Post by fmw42 »

I am just asking you to tell me what the suffix is on the fonts that fail. Do all the the fonts with a same suffix fail?
HiRezGuy
Posts: 19
Joined: 2018-06-24T08:26:07-07:00
Authentication code: 1152

Re: convert & pango - "couldn't load font"

Post by HiRezGuy »

fmw42 wrote: 2018-07-20T15:08:37-07:00 I am just asking you to tell me what the suffix is on the fonts that fail. Do all the the fonts with a same suffix fail?
Thanks for your patience fmw.

IM sees ttf and ttc fonts - literally hundreds. Of the 22 that process correctly with pango, they are all ttf files.

There are also fon files; IM doesn't see these.

There is a file "type-ghostscript.xml" that contains many entries; I don't believe these fonts are on my system.

Notes:
- Win10 + ImageMagick-7.0.8-2-portable-Q16-x64
- under the IM install dir, "type.xml" has no entries; not sure if this is "OK"
- I do not have any environment variables set (e.g., IM install dir)
- there is no "type-windows.xml" file in the ImageMagick-7.0.8-2-portable-Q16-x64 version; not sure if this is "OK"
HiRezGuy
Posts: 19
Joined: 2018-06-24T08:26:07-07:00
Authentication code: 1152

Re: convert & pango - "couldn't load font"

Post by HiRezGuy »

Some things I tried this AM.
1. downloaded imagick_type_gen (chrome sees it as a python file; add a pl extension instead)
2. tried running imagick_type_gen.pl with no options - can't do; script uses "locate", and there is no analog for a "whence"-type program under Win
3. created a listing of ttf font files under c:\windows\fonts using "dir"; ttc files don't work with the script
4. make sure there are no special perl metacharacters, like parenthesis, in the path names (e.g., "C:\Program Files (x86)") - re's in script will choke
5. ran "perl imagick_type_gen.pl -f font_paths_ttf.txt >type.xml"; generated an xml file that looks clean and parses correctly; used listing of ttf font files from step 3 for input
6. set PREFIX=C:\Program Files\ImageMagick
7. installed type.xml from step 5 under %PREFIX%
8. tested all 328 ttf fonts with a perl script that calls "IM_convert"; the test script reads font names from an input file, and generates a pango input file with that font name

Summary:
The results are the same as my last post before yesterday - 22 fonts run cleanly; everything else generates warnings. (NOTE: The list of font names that run cleanly are included in my last post before yesterday - previous page of this thread.)

Code: Select all

Microsoft Windows [Version 10.0.17134.165]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\user>set PREFIX=C:\Program Files\ImageMagick

C:\Users\user>echo %PREFIX%
C:\Program Files\ImageMagick

C:\Users\user>cd \0\mm\test

C:\0\mm\test>perl .\t_fonts.pl

t_fonts.pl : 328 fonts processed

C:\0\mm\test>
A font like Algerian generates one warning - log entry from test script includes font name, generated pango markup, the IM_convert command used with "system()", and the output from IM_convert:

Code: Select all

003 : "Algerian"

<span foreground="#FFFFFF" font="Algerian" font_size="98304" font_weight="heavy">The <b>Warm-Group</b>
<i>is</i>
<s>the</s> <u>BEST Gathering</u></span>

"C:\Program Files\ImageMagick\convert" -size 1024x768 -background "#10253F" -gravity Center pango:"@C:\0\mm\test\t_text_pango.txt" t_image_003_Algerian.jpg 2>>C:\0\mm\test\t_fonts_log.txt

** (convert.exe:2948): WARNING **: couldn't load font "Algerian Heavy Italic Not-Rotated 96", falling back to "Sans Heavy Italic Not-Rotated 96", expect ugly output.
A font like Agency-FB-Bold generates multiple warnings:

Code: Select all

002 : "Agency-FB-Bold"

<span foreground="#FFFFFF" font="Agency-FB-Bold" font_size="98304" font_weight="heavy">The <b>Warm-Group</b>
<i>is</i>
<s>the</s> <u>BEST Gathering</u></span>

"C:\Program Files\ImageMagick\convert" -size 1024x768 -background "#10253F" -gravity Center pango:"@C:\0\mm\test\t_text_pango.txt" t_image_002_Agency-FB-Bold.jpg 2>>C:\0\mm\test\t_fonts_log.txt

** (convert.exe:9828): WARNING **: couldn't load font "Agency-FB-Bold Heavy Not-Rotated 96", falling back to "Sans Heavy Not-Rotated 96", expect ugly output.

** (convert.exe:9828): WARNING **: couldn't load font "Agency-FB-Bold Bold Not-Rotated 96", falling back to "Sans Bold Not-Rotated 96", expect ugly output.

** (convert.exe:9828): WARNING **: couldn't load font "Agency-FB-Bold Heavy Italic Not-Rotated 96", falling back to "Sans Heavy Italic Not-Rotated 96", expect ugly output.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert & pango - "couldn't load font"

Post by fmw42 »

I am not sure that ImageMagick (freetype and fontconfig) can handle .fon fonts. They are windows specific. I suggest you check with the freetype people about that. see https://www.freetype.org.

Ghostscript fonts would only be needed by Ghostscript when reading PDF, PS, EPS, etc.

I do not think I can help any further as that is my limit of understanding. Perhaps a Windows user could comment further about the usage of .fon fonts.
HiRezGuy
Posts: 19
Joined: 2018-06-24T08:26:07-07:00
Authentication code: 1152

Re: convert & pango - "couldn't load font"

Post by HiRezGuy »

Other notes:
- As an fyi: I believe there is a bug report for pango+Windows that Anthony maybe assigned to himself a year ago - I saw that somewhere.
- I don't see any open issues at github that are similar.

A Similar Problem @ ImageMagick Forum
viewtopic.php?t=33136

I'm basically back to where I was a few weeks ago: I figured it was a limitation, and I'd need to work around it if I wanted to use pango with my project.

I'll create a small perl script in the same spirit as "imagick_type_gen" and the test script I wrote. No worries. I was basically talking and reminding myself of where I left off. Thanks for being a good sport.
Post Reply