groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A primer on font installation for groff (was: gropdf(1)'s 'Font inst


From: Alejandro Colomar
Subject: Re: A primer on font installation for groff (was: gropdf(1)'s 'Font installation' section is opaque to me)
Date: Fri, 19 Apr 2024 12:42:58 +0200

Hi Branden,

On Thu, Apr 18, 2024 at 08:33:39PM -0500, G. Branden Robinson wrote:
> Hi Alex,
> 
> At 2024-04-19T00:29:37+0200, Alejandro Colomar wrote:
> > While the above is interesting, I've already read similar explanations
> > from you in related threads.  However, I still have no clue of how to
> > drop TINOR from the Linux man-pages repo and generate it from
> > something coming from a package.  :(
> 
> Well, it's tedious, which is why Peter Schaffter and others have written
> shell scripts to help with the process.
> 
> Here's a file- and program-centric overview of what's required.
> 
> 1.  You grab a modern font file from some place.  This will be a TTF or
>     OTF file.

Hmmm, good!  I finally have a starting point.

I got this:

$ apt-file show texlive-fonts-extra-links | grep Tinos
texlive-fonts-extra-links: 
/usr/share/texlive/texmf-dist/fonts/truetype/google/tinos/Tinos-Bold.ttf
texlive-fonts-extra-links: 
/usr/share/texlive/texmf-dist/fonts/truetype/google/tinos/Tinos-BoldItalic.ttf
texlive-fonts-extra-links: 
/usr/share/texlive/texmf-dist/fonts/truetype/google/tinos/Tinos-Italic.ttf
texlive-fonts-extra-links: 
/usr/share/texlive/texmf-dist/fonts/truetype/google/tinos/Tinos-Regular.ttf

> 2.  You use FontForge or a similar tool to generate TWO files from a
>     TTF/OTF file.

Okay, fontforge available here:

$ apt-file find bin/fontforge
fontforge: /usr/bin/fontforge             
fontforge-nox: /usr/bin/fontforge

I'll check Peter Schaffter's script to see how he uses fontforge.

>     2a.  A PostScript Type 1 font in PFA and/or PFB format.  If you want
>     to embed this font in a groff-generated PostScript file, you have to
>     use PFA, because that is all grops(1) understands.  If you want to
>     embed this font in a groff-generated PDF, you can use either,
>     because gropdf(1) understands both formats.

I may skip this part, since I already have the PFB:

$ apt-file show texlive-fonts-extra | grep Tinos | grep pfb
texlive-fonts-extra: 
/usr/share/texlive/texmf-dist/fonts/type1/google/tinos/Tinos-Bold.pfb
texlive-fonts-extra: 
/usr/share/texlive/texmf-dist/fonts/type1/google/tinos/Tinos-BoldItalic.pfb
texlive-fonts-extra: 
/usr/share/texlive/texmf-dist/fonts/type1/google/tinos/Tinos-Italic.pfb
texlive-fonts-extra: 
/usr/share/texlive/texmf-dist/fonts/type1/google/tinos/Tinos.pfb

>     2b.  If you have a PFB file and need PFA, you can use groff's
>     utility pfbtops(1) to produce the latter.

I already do this:

$(_TINOS_PFA): $(TINOS_PFB) $(MK) | $$(@D)/
        $(info  $(INFO_)PFBTOPS         $@)
        $(PFBTOPS) <$< >$@

>     2c.  You will also have to produce an AFM file.  This stands for
>     "Adobe Font Metrics".  This describes the dimensions of the glyphs
>     in the proper font file.  The font metrics are not the font itself;
>     they merely describe it in some respects.

I'll need this thing.  Hopefully, it'll be simple after reading Peter's
script.

> 3.  The formatter, troff(1), must have font metrics so that it can
>     correctly position glyphs on the page.  But GNU troff, like AT&T
>     troff before it, does not use AFM files directly for this purpose;
>     AT&T troff is older than Adobe PostScript.  Instead it uses a "font
>     description file", which includes the metrics and other information
>     important to the formatter.  The font description file is what
>     corresponds to the short, shouty *roff font names we're used to,
>     like "TR" or "S" or "CBI".
> 
> 4.  The *roff font description files must be placed where the formatter
>     can find them when it runs.  They must appear in the
>     GROFF_FONT_PATH, or the formatter must be told where to look with an
>     `-f` command-line option.
> 
> 5.  When embedding fonts in PostScript or PDF, the _output driver_
>     (grops or gropdf) must be told where to look to find them.  Each
>     driver consults a "download" file for this information.
> 
> A package manager has a few things to keep track of to ensure that the
> state of all these remains coherent.
> 
> A.  If a new "modern" (TTF/OTF) font is installed, a program to generate
>     PFA/PFB and AFM files must be run to make it available to groff.
> 
> B.  afmtodit(1) must be run to produce a groff font description file
>     from the AFM file.

Once I get the AFM, I'll get back to this.

> C.  The font description files must be placed in groff's "font search
>     path".  In practice this means two places, one for PostScript and
>     one for PDF.

I already do this:

$ find .tmp/fonts/
.tmp/fonts/
.tmp/fonts/devpdf
.tmp/fonts/devpdf/download
.tmp/fonts/devpdf/Tinos.pfa
.tmp/fonts/devpdf/TINOR

> D.  The "download" files for the grops and gropdf programs must be
>     updated to list the PFA/PFB file in the correct locations.

$ cat .tmp/fonts/devpdf/download 
        Tinos   Tinos.pfa

> When a font is removed, the foregoing artifacts must be updated or
> deleted as appropriate.
> 
> When a font is updated, some or all of the foregoing artifacts must be
> regenerated, depending on whether the font files changed their names
> (this happens regularly to the URW "base" fonts).  The AFM files and
> therefore the corresponding groff font description files must be updated
> if any glyphs were added, removed, or changed their dimensions.
> 
> The foregoing procedure offers several points of failure.  That is, I
> suspect, why no distribution has ever yet bothered.
> 
> Does this help?

A lot!  Thanks!

> Regards,
> Branden

Have a lovely day!
Alex



-- 
<https://www.alejandro-colomar.es/>

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]