#1054147 libgraphics-magick-perl: Cannot find fonts after gsfonts transition

Package:
libgraphics-magick-perl
Source:
libgraphics-magick-perl
Description:
format-independent image processing - perl interface
Submitter:
Date:
2023-10-23 15:48:03 UTC
Severity:
normal
#1054147#5
Date:
2023-10-18 03:38:10 UTC
From:
To:
Dear Maintainer,

With the transition from gsfonts -> fonts-urw-base35, fonts have moved and libgraphics-magick-perl (or maybe underlying libimage-magick? I can't tell), can't find fonts. When you generate images with text you get:

```
Exception 405: Unable to read font (/usr/share/fonts/type1/gsfonts/n022004l.pfb)
```

The directory `/usr/share/fonts/type1/gsfonts` no longer belongs to any package, though it existed and was almost-empty (except for a `.uuid` file) on my machine due to the transition.

#1054147#10
Date:
2023-10-23 15:44:25 UTC
From:
To:
Dear Maintainer,

*** Reporter, please consider answering these questions, where appropriate ***

To fix this problem one has to fix the paths in
/usr/lib/GraphicsMagick-1.3.42/config/type-ghostscript.mgk file

To workaround  this issue, install the fonts that comes with ghostscript-fonts-
std-8.11.tar.gz  in the paths that you see in above `.mgk` file.


I have installed

ii  graphicsmagick-imagemagick-compat                   1.4+really1.3.42-1
all          image processing tools providing ImageMagick interface

Run the following command


convert  -size 1366x720  -background cornsilk -fill blue -pointsize 12 -font
FreeMono -gravity center label:'Some Random Screenshot'   screenshot.png

You will see the following error

convert: Unable to get type metrics (Some Random Screenshot).

Run the following command

~$ gm convert -list font
Path: /usr/lib/GraphicsMagick-1.3.42/config/type-ghostscript.mgk

Name                             Family                  Style   Stretch
Weight
--------------------------------------------------------------------------------
AvantGarde-Book                  AvantGarde              normal  normal    400
AvantGarde-BookOblique           AvantGarde              oblique normal    400
AvantGarde-Demi                  AvantGarde              normal  normal    600
AvantGarde-DemiOblique           AvantGarde              oblique normal    600

Run the following command

~$ cat /usr/lib/GraphicsMagick-1.3.42/config/type-ghostscript.mgk | grep fonts
| head
Mapping for URW Standard postscript fonts (cyrillicized)
Download from https://src.fedoraproject.org/repo/pkgs/urw-fonts/
(https://src.fedoraproject.org/repo/pkgs/urw-fonts/urw-
fonts-2.0.tar.bz2/c5cc8237e4289fc6ebeaa296174fa504/urw-fonts-2.0.tar.bz2)
NetBSD's pkgsrc (http://pkgsrc.se/fonts/urw-fonts) calls these "urw-
fonts-2.0nb1".
    metrics="/usr/share/fonts/type1/gsfonts/a010013l.afm"
    glyphs="/usr/share/fonts/type1/gsfonts/a010013l.pfb"
    metrics="/usr/share/fonts/type1/gsfonts/a010033l.afm"
    glyphs="/usr/share/fonts/type1/gsfonts/a010033l.pfb"
    metrics="/usr/share/fonts/type1/gsfonts/a010015l.afm"
    glyphs="/usr/share/fonts/type1/gsfonts/a010015l.pfb"

Note that the fonts is coming from /usr/share/fonts/type1/gsfonts/

List the contents gsfonts package

~$ dpkg -L gsfonts
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/gsfonts
/usr/share/doc/gsfonts/NEWS.Debian.gz
/usr/share/doc/gsfonts/changelog.Debian.gz
/usr/share/doc/gsfonts/copyright


transitional dummy package (gsfonts -> fonts-urw-base35)

Now check the contents of the package fonts-urw-base35

~$ dpkg -L fonts-urw-base35 | grep 'afm\|pfb' | head
/usr/share/fonts/X11/Type1/C059-BdIta.pfb
/usr/share/fonts/X11/Type1/C059-Bold.pfb
/usr/share/fonts/X11/Type1/C059-Italic.pfb
/usr/share/fonts/X11/Type1/C059-Roman.pfb
/usr/share/fonts/X11/Type1/D050000L.pfb

There are afm and pfb files here.

In order to fix this, the paths to font metrics etc has to be fixed in file
/usr/lib/GraphicsMagick-1.3.42/config/type-ghostscript.mgk

~$ dpkg -S /usr/lib/GraphicsMagick-1.3.42/config/type-ghostscript.mgk
libgraphicsmagick-q16-3: /usr/lib/GraphicsMagick-1.3.42/config/type-
ghostscript.mgk


To workaround this bug, I installed the fonts manually in
/usr/share/fonts/type1/gsfonts/

~$ ls /usr/share/fonts/type1/gsfonts/
a010013l.afm  a010035l.pfb  b018032l.pfm  c059036l.afm  n019003l.pfb
n019024l.pfm  n021003l.afm  n021024l.pfb  p052003l.afm   s050000l.afm
a010013l.pfb  a010035l.pfm  b018035l.afm  c059036l.pfb  n019003l.pfm
n019043l.afm  n021003l.pfb  n021024l.pfm  p052003l.pfb   s050000l.pfb
a010013l.pfm  b018012l.afm  b018035l.pfb  ChangeLog     n019004l.afm
n019043l.pfb  n021003l.pfm  n022003l.afm  p052004l.afm   TODO
a010015l.afm  b018012l.pfb  b018035l.pfm  COPYING       n019004l.pfb
n019044l.afm  n021004l.afm  n022003l.pfb  p052004l.pfb   z003034l.afm
a010015l.pfb  b018012l.pfm  c059013l.afm  d050000l.afm  n019004l.pfm
n019044l.pfb  n021004l.pfb  n022004l.afm  p052023l.afm   z003034l.pfb
a010015l.pfm  b018015l.afm  c059013l.pfb  d050000l.pfb  n019023l.afm
n019063l.afm  n021004l.pfm  n022004l.pfb  p052023l.pfb   z003034l.pfm
a010033l.afm  b018015l.pfb  c059016l.afm  fonts         n019023l.pfb
n019063l.pfb  n021023l.afm  n022023l.afm  p052024l.afm
a010033l.pfb  b018015l.pfm  c059016l.pfb  fonts.dir     n019023l.pfm
n019064l.afm  n021023l.pfb  n022023l.pfb  p052024l.pfb
a010033l.pfm  b018032l.afm  c059033l.afm  fonts.scale   n019024l.afm
n019064l.pfb  n021023l.pfm  n022024l.afm  README
a010035l.afm  b018032l.pfb  c059033l.pfb  n019003l.afm  n019024l.pfb
n019064l.pfm  n021024l.afm  n022024l.pfb  README.tweaks

I used the following instructions


[[https://www.linuxfromscratch.org/blfs/view/svn/pst/gs.html][ghostscript-10.02.0]]

If you have downloaded the fonts, unpack them to =/usr/share/ghostscript= and
ensure the ownership of the files are =root=: =root=.

#+begin_example
tar -xvf ../ghostscript-fonts-std-8.11.tar.gz -C /usr/share/ghostscript --no-
same-owner &&
tar -xvf ../gnu-gs-fonts-other-6.0.tar.gz     -C /usr/share/ghostscript --no-
same-owner &&
fc-cache -v /usr/share/ghostscript/fonts/
#+end_example

taking care to replace ghostscript path with gsfonts path.

The `convert` command works now, after my workaround