[Fontconfig] Difficulty finding a font file through the libraries

Michael Brennen michael at fishnet.us
Fri Oct 29 06:56:45 UTC 2021

On Oct 29, 2021, at 00:49, Lawrence D'Oliveiro <ldo at geek-central.gen.nz> wrote:
> On Fri, 29 Oct 2021 00:06:32 -0500, Michael Brennen wrote:
>> For what it is worth, adding this line to the end of
>> /usr/share/ghostscript/Resource/Init/Fontmap.GS, gs does not go
>> through the fc libraries and finds the font in the .ttf file.
>> /MoongladeDEMO-Regular  (/var/www/ext/resources/fonts/2- Moonglade Regular DEMO.ttf)  ;
> OK, I figured out on my Debian system the equivalent file is
> /usr/share/ghostscript/9.54.0/Resource/Init/Fontmap.GS. I think that’s
> just for the builtin fonts, and shouldn’t be edited; this is because
> your changes could easily be lost the next time the package is upgraded
> or reinstalled.
> So where is the equivalent to /var/lib/ghostscript/fonts/Fontmap? And
> is it automatically generated in turn from config files in /etc
> somewhere?

I know better than to touch the /usr/share stuff for the long run; this is quick get to the point testing. :)

Running the process as follows gives the same results. It finds the font in the .ttf.orig file.

# sudo -u apache /usr/bin/gs ….

The Fontmap file is /usr/share/ghostscript/Resource/Init/Fontmap; it has four lines in it that refer back to the Fontmap.GS file. I have not spent much time looking for an alternate gs configuration file under /etc, but so far I have not found one; besides, that is ancillary to the real problem.

% See Fontmap.GS for the syntax of real Fontmap files.
%% Replace 1 (Fontmap.GS)
(Fontmap.GS) .runlibfile

So if I comment the font directory path in /etc/fonts/local.conf and then run this script file as "sudo -u apache ./run_gs” (which I think should closely approximate php running the script as the apache user)

export GS_FONTPATH=/var/www/ext/resources/fonts
time /usr/bin/gs ...

Processing pages 1 through 2.
Page 1
Scanning /var/www/ext/resources/fonts for fonts...**** Warning: glyf overlaps cmap, truncating.
**** Warning: glyf overlaps cmap, truncating.
 8859 files, 8358 scanned, 7393 new fonts.
Can't find (or can't open) font file /usr/share/ghostscript/Resource/Font/MoongladeDEMO-Regular.
Can't find (or can't open) font file MoongladeDEMO-Regular.
Loading MoongladeDEMO-Regular font from /var/www/ext/resources/fonts/2- Moonglade Regular DEMO.ttf... 30637720 23902546 2708316 1039805 3 done.

it finds the font in the .ttf file, NOT the .ttf.orig file. The difference is that in this configuration gs does not go through FC to find the fonts.

Regarding the XML documentation, I have read that, but the XML syntax is not the difficulty sorting out the linked config files in /etc/fonts/conf.d. The difficulty is that there is a *lot* going on in those files, and trying to gain some idea of what they do is not trivial.

Besides, I doubt that they have anything to do with gs not being able to find the font in the .ttf file when it searches through FC. Or do you think the preset config files have anything to do with this? I genuinely do not know.

So as I see the question is still open why gs searching through FC does not find the font in the proper file, but when gs searches the fonts directly it successfully finds it. Does the name have anything to do with this? That is why I wondered about the configuration presets in /etc/fonts/conf.d, not knowing if they might have anything to do with the name format.

Again, thanks for your patience.

   -- Michael

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/fontconfig/attachments/20211029/76daee99/attachment-0001.htm>

More information about the Fontconfig mailing list