Lacking Natural Simplicity (Posts about install-font.sh)https://tkurtbond.github.io/categories/install-fontsh.atom2024-01-23T18:49:39ZT. Kurt BondNikolainstall-font.sh - The simple approachhttps://tkurtbond.github.io/posts/2021/07/17/install-fontsh-the-simple-approach/2021-07-17T15:36:43-04:002021-07-17T15:36:43-04:00T. Kurt Bond<p>The simple approach to using <a class="reference external" href="https://www.schaffter.ca/mom/mom-05.html#install-font">install-font.sh</a> to install fonts for
<span class="app">groff</span> probably works for almost everybody.</p>
<p>First, make sure that <a class="reference external" href="https://fontforge.org/">FontForge</a> is installed; it is free and open
source and available for installation in most distributions. Second,
call the <span class="command">install-font.sh</span> command with one argument, the
font file, and answer the prompts.</p>
<p>This will install the fonts for <span class="app">groff</span>'s use in the appropriate
directories under <span class="file">/usr/local/share/groff</span>, creating the
directories if necessary. If you need to install into
<span class="file">/usr/share/groff</span> you should specify the <code class="docutils literal"><span class="pre">-s</span></code> option to the
script. For instance:</p>
<div class="code"><pre class="code text"><a id="rest_code_ff24099a9e554b159661c2026ad00c97-1" name="rest_code_ff24099a9e554b159661c2026ad00c97-1" href="https://tkurtbond.github.io/posts/2021/07/17/install-fontsh-the-simple-approach/#rest_code_ff24099a9e554b159661c2026ad00c97-1"></a>$ install-font.sh Lora-Regular.ttf
</pre></div>
<p>will install the Regular variant of the font, leading you through four
prompts, for three of which you just need to take the default.</p>
<p>The only prompt where you need to do something other than accept the
default is the prompt for the style. For <span class="file">Lora-Regular</span> you'd
specify <code class="docutils literal">+R</code>. For italic, bold, and bold italic, the other
traditional <span class="app">troff</span> font styles, you'd specify <code class="docutils literal">+I</code>, <code class="docutils literal">+B</code>,
and <code class="docutils literal">+BI</code>. The prompt lists them all for you to choose from.</p>
<p>Here's a walk-through of installing the <a class="reference external" href="https://fonts.google.com/specimen/Lora">Lora</a> font, assuming that
<span class="command">install-font.sh</span> is in your path. (If your
<span class="file">/usr/local/share/groff</span> directory isn't writable for your
normal user, you should prefix the command with <code class="docutils literal">sudo</code>.)</p>
<p><span class="command">install-font.sh</span> does produce a lot of output, but the
colorizing helps pick out the important things. I've put the
responses the user types in bold and red, and added “<RETURN>”
where the user presses the RETURN key to accept defaults.</p>
<pre>
$ <span style="color:red;"><b>install-font.sh Lora-Regular.ttf</b></span>
/usr/local/share/groff/site-font not found; creating.
/usr/local/share/groff/site-font/devps not found; creating.
/usr/local/share/groff/site-font/devpdf not found; creating.
Processing <span style="color:teal;">Lora-Regular.ttf</span>...
Running fontforge...
Copyright (c) 2000-2020. See AUTHORS for Contributors.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
Version: 20201107
Based on sources from 2020-11-16 19:11 UTC-D.
The following table(s) in the font have been ignored by FontForge
Ignoring 'STAT' style attributes table
Done.
Family name (default = Lora): <span style="color:red;"><b><RETURN></b></span>
=><span style="color:teal;">Lora-Regular</span> (Lora-Regular.ttf) assigned to family '<span style="color:olive;">Lora</span>'.
Enter +STYLE (eg +R, +I, +B, +BI), or a unique groff name for <span style="color:teal;">Lora-Regular</span>.
Leave blank to set name to '<span style="color:teal;">Lora-Regular</span>': <span style="color:red;"><b>+R</b></span>
=><span style="color:teal;">Lora-Regular</span> assigned groff fontname '<span style="color:olive;">LoraR</span>'.
Creating <span style="color:olive;">LoraR</span>...
afmtodit: both uni00B5 and uni03BC map to mc at /Users/tkb/sw/versions/groff/git/bin/afmtodit line 6441.
Done.
Installing <span style="color:olive;">LoraR</span> in /usr/local/share/groff/site-font/devps/... Done.
Make <span style="color:olive;">LoraR</span> available to gropdf? (y/n; default = y) <span style="color:red;"><b><RETURN></b></span>
Checking for gropdf executable and devpdf directory... gropdf found.
Installing <span style="color:olive;">LoraR</span> in /usr/local/share/groff/site-font/devpdf/... Done.
Copy <span style="color:teal;">Lora-Regular.ttf</span> to /usr/local/share/fonts/truetype/Lora/
(y/n; default = n) <span style="color:red;"><b><RETURN></b></span>
Install <span style="color:teal;">Lora-Regular.ttf</span> manually to make it available system-wide.
$ <span style="color:red;"><b>install-font.sh Lora-Italic.ttf</b></span>
Processing <span style="color:teal;">Lora-Italic.ttf</span>...
Running fontforge...
Copyright (c) 2000-2020. See AUTHORS for Contributors.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
Version: 20201107
Based on sources from 2020-11-16 19:11 UTC-D.
The following table(s) in the font have been ignored by FontForge
Ignoring 'STAT' style attributes table
Done.
Family name (default = Lora): <span style="color:red;"><b><RETURN></b></span>
=><span style="color:teal;">Lora-Italic</span> (Lora-Italic.ttf) assigned to family '<span style="color:olive;">Lora</span>'.
Enter +STYLE (eg +R, +I, +B, +BI), or a unique groff name for <span style="color:teal;">Lora-Italic</span>.
Leave blank to set name to '<span style="color:teal;">Lora-Italic</span>': <span style="color:red;"><b>+I</b></span>
=><span style="color:teal;">Lora-Italic</span> assigned groff fontname '<span style="color:olive;">LoraI</span>'.
Creating <span style="color:olive;">LoraI</span>...
afmtodit: both uni00B5 and uni03BC map to mc at /Users/tkb/sw/versions/groff/git/bin/afmtodit line 6441.
Done.
Installing <span style="color:olive;">LoraI</span> in /usr/local/share/groff/site-font/devps/... Done.
Make <span style="color:olive;">LoraI</span> available to gropdf? (y/n; default = y) <span style="color:red;"><b><RETURN></b></span>
Checking for gropdf executable and devpdf directory... gropdf found.
Installing <span style="color:olive;">LoraI</span> in /usr/local/share/groff/site-font/devpdf/... Done.
Copy <span style="color:teal;">Lora-Italic.ttf</span> to /usr/local/share/fonts/truetype/Lora/
(y/n; default = n) <span style="color:red;"><b><RETURN></b></span>
Install <span style="color:teal;">Lora-Italic.ttf</span> manually to make it available system-wide.
$ <span style="color:red;"><b>install-font.sh Lora-Bold.ttf</b></span>
Processing <span style="color:teal;">Lora-Bold.ttf</span>...
Running fontforge...
Copyright (c) 2000-2020. See AUTHORS for Contributors.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
Version: 20201107
Based on sources from 2020-11-16 19:11 UTC-D.
The following table(s) in the font have been ignored by FontForge
Ignoring 'STAT' style attributes table
Glyph bounding box data exceeds font bounding box data for GID 4
Subsequent errors will not be reported.
In GID 769 the advance width (1316) is greater than the stated maximum (1291)
Subsequent errors will not be reported.
Done.
Family name (default = Lora): <span style="color:red;"><b><RETURN></b></span>
=><span style="color:teal;">Lora-Bold</span> (Lora-Bold.ttf) assigned to family '<span style="color:olive;">Lora</span>'.
Enter +STYLE (eg +R, +I, +B, +BI), or a unique groff name for <span style="color:teal;">Lora-Bold</span>.
Leave blank to set name to '<span style="color:teal;">Lora-Bold</span>': <span style="color:red;"><b>+B</b></span>
=><span style="color:teal;">Lora-Bold</span> assigned groff fontname '<span style="color:olive;">LoraB</span>'.
Creating <span style="color:olive;">LoraB</span>...
afmtodit: both uni00B5 and uni03BC map to mc at /Users/tkb/sw/versions/groff/git/bin/afmtodit line 6441.
Done.
Installing <span style="color:olive;">LoraB</span> in /usr/local/share/groff/site-font/devps/... Done.
Make <span style="color:olive;">LoraB</span> available to gropdf? (y/n; default = y) <span style="color:red;"><b><RETURN></b></span>
Checking for gropdf executable and devpdf directory... gropdf found.
Installing <span style="color:olive;">LoraB</span> in /usr/local/share/groff/site-font/devpdf/... Done.
Copy <span style="color:teal;">Lora-Bold.ttf</span> to /usr/local/share/fonts/truetype/Lora/
(y/n; default = n) <span style="color:red;"><b><RETURN></b></span>
Install <span style="color:teal;">Lora-Bold.ttf</span> manually to make it available system-wide.
$ install-font.sh Lora-BoldItalic.ttf
Processing <span style="color:teal;">Lora-BoldItalic.ttf</span>...
Running fontforge...
Copyright (c) 2000-2020. See AUTHORS for Contributors.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
Version: 20201107
Based on sources from 2020-11-16 19:11 UTC-D.
The following table(s) in the font have been ignored by FontForge
Ignoring 'STAT' style attributes table
Glyph bounding box data exceeds font bounding box data for GID 4
Subsequent errors will not be reported.
In GID 776 the advance width (1297) is greater than the stated maximum (1273)
Subsequent errors will not be reported.
Done.
Family name (default = Lora): <span style="color:red;"><b><RETURN></b></span>
=><span style="color:teal;">Lora-BoldItalic</span> (Lora-BoldItalic.ttf) assigned to family '<span style="color:olive;">Lora</span>'.
Enter +STYLE (eg +R, +I, +B, +BI), or a unique groff name for <span style="color:teal;">Lora-BoldItalic</span>.
Leave blank to set name to '<span style="color:teal;">Lora-BoldItalic</span>': <span style="color:red;"><b>+BI</b></span>
=><span style="color:teal;">Lora-BoldItalic</span> assigned groff fontname '<span style="color:olive;">LoraBI</span>'.
Creating <span style="color:olive;">LoraBI</span>...
afmtodit: both uni00B5 and uni03BC map to mc at /Users/tkb/sw/versions/groff/git/bin/afmtodit line 6441.
Done.
Installing <span style="color:olive;">LoraBI</span> in /usr/local/share/groff/site-font/devps/... Done.
Make <span style="color:olive;">LoraBI</span> available to gropdf? (y/n; default = y) <span style="color:red;"><b><RETURN></b></span>
Checking for gropdf executable and devpdf directory... gropdf found.
Installing <span style="color:olive;">LoraBI</span> in /usr/local/share/groff/site-font/devpdf/... Done.
Copy <span style="color:teal;">Lora-BoldItalic.ttf</span> to /usr/local/share/fonts/truetype/Lora/
(y/n; default = n) <span style="color:red;"><b><RETURN></b></span>
Install <span style="color:teal;">Lora-BoldItalic.ttf</span> manually to make it available system-wide.
</pre><p><em>Last edited: 2021-07-20 12:40:30 EDT</em></p>
<!-- Local Variables:
time-stamp-format: "%Y-%02m-%02d %02H:%02M:%02S %Z"
time-stamp-start: "\\*Last edited:[ \t]+\\\\?"
time-stamp-end: "\\*\\\\?\n"
time-stamp-line-limit: -20
End: -->groff and install-font.sh and installing fonts for use in groffhttps://tkurtbond.github.io/posts/2021/07/17/groff-and-install-fontsh-and-installing-fonts-for-use-in-groff/2021-07-17T00:16:49-04:002021-07-17T00:16:49-04:00T. Kurt Bond<aside class="admonition note">
<p class="admonition-title">Note</p>
<p>This was originally a <a class="reference external" href="https://lists.gnu.org/archive/html/groff/2021-07/msg00089.html">post</a> to the <a class="reference external" href="https://www.gnu.org/software/groff/">groff</a> <a class="reference external" href="https://lists.gnu.org/mailman/listinfo/groff/">mailing list</a>. It has
been slightly modified.</p>
</aside>
<p>Currently <span class="command">install-font.sh</span> is not part of <span class="app">groff</span>.
We've had some discussion on the list <a class="reference external" href="https://lists.gnu.org/archive/html/groff/2021-07/msg00061.html">recently</a> and in the past about
integrating it into the <span class="app">groff</span> distribution, and in response to
recent <a class="reference external" href="https://lists.gnu.org/archive/html/groff/2021-07/msg00054.html">discussion</a> there is a new bug, <a class="reference external" href="https://savannah.gnu.org/bugs/index.php?60930">#60930</a>, requesting
integrating it, including documentation, etc.</p>
<p>In the meantime, if you want to install fonts in OpenType or TrueType
formats for use with <code class="docutils literal">devps</code> and <code class="docutils literal">devpdf</code>,
<span class="command">install-font.sh</span> greatly simplifies the process.</p>
<p>The <span class="command">install-font.sh</span> script was written by Peter Schaffter, the author
of the <a class="reference external" href="https://www.schaffter.ca/mom/mom-01.html">mom macros</a> for
<span class="app">groff</span>, and is distributed on mom's <a class="reference external" href="https://www.schaffter.ca/mom/mom-05.html#install-font">download page</a> and can be
downloaded <a class="reference external" href="https://www.schaffter.ca/mom/bin/install-font.sh">directly</a>. It has a <code class="docutils literal"><span class="pre">-H</span></code>
option that prints the documentation for it.</p>
<p><a class="reference external" href="https://fontforge.org/">Fontforge</a> is a free and open source font
editor. It can run scripts to manipulate fonts and convert between
font formats. (I only use <span class="app">fontforge</span> to install fonts with
<span class="command">install-font.sh</span>, so I use a version that is command line
only, but the normal build has a GUI for interactively building
fonts.) The <span class="command">install-font.sh</span> script uses <span class="app">Fontforge</span> to convert
OpenType and TrueType fonts to PostScript Type42 (<span class="file">.t42</span>) and Type1
(<span class="file">.pfa</span>), from which a <span class="app">groff</span> font is generated by the
<span class="app">groff</span> utility <span class="command">afmtodit</span>. Then the necessary files are moved to
<span class="file">site-font/devps</span> and registered in its download file for use by <span class="command">grops</span>.
Optionally the same can be done for <span class="file">site-font/devpdf</span> for the use of
<span class="file">gropdf</span>. Then the fonts are available for use by <code class="docutils literal">groff
<span class="pre">-Tps</span></code> and <code class="docutils literal">groff <span class="pre">-Tpdf</span></code>.</p>
<p>So, suppose you wanted to use <a class="reference external" href="https://fonts.google.com/specimen/Cormorant+Garamond">Cormorant Garamond</a>, a free
font. You could download the Regular, Italic, Bold, and Bold Italic
variants of the font, since <span class="app">groff</span> tends to expect there to be
R, I, B, and BI variants of the fonts it uses, though that is not
mandatory. This would give you the files
<span class="file">CormorantGaramond-Regular.ttf</span>,
<span class="file">CormorantGaramond-Italic.ttf</span>,
<span class="file">CormorantGaramond-Bold.ttf</span>, and
<span class="file">CormorantGaramond-BoldItalic.ttf</span>. You would then use
<span class="command">install-font.sh</span> to convert them and install the resulting
files into proper places under <span class="app">groff</span>'s site-font directory.</p>
<p>So, for instance, you'd cd to the directory that holds the <span class="file">.ttf</span> files
you downloaded. Then, to install the Regular variant of Cormorant
Garamond you'd run the command</p>
<div class="code"><pre class="code bash"><a id="rest_code_001b896fc1de43a48f898330b4a228e9-1" name="rest_code_001b896fc1de43a48f898330b4a228e9-1" href="https://tkurtbond.github.io/posts/2021/07/17/groff-and-install-fontsh-and-installing-fonts-for-use-in-groff/#rest_code_001b896fc1de43a48f898330b4a228e9-1"></a><span class="k">$(</span>IFDIR<span class="k">)</span>/install-font.sh<span class="w"> </span>-n<span class="w"> </span>-P<span class="w"> </span><span class="s2">"</span><span class="nv">$DEST</span><span class="s2">"</span><span class="w"> </span>-d<span class="w"> </span>-F<span class="w"> </span>CormorantGaramond<span class="w"> </span>-f<span class="w"> </span>+R<span class="w"> </span>CormorantGaramond-Regular.ttf
</pre></div>
<p>where <code class="docutils literal">IFDIR</code> is an environment variable indicating the directory
where <span class="command">install-font.sh</span> is located and <code class="docutils literal">DEST</code> is an
environment variable indicating the directory that contains
<span class="app">groff</span>'s <span class="file">site-font</span> directory (not the actual
<span class="file">site-font</span> directory itself). The <code class="docutils literal"><span class="pre">-n</span></code> option means don't
try to copy the TrueType file to where the system font files are
located. The <code class="docutils literal"><span class="pre">-P</span></code> option takes as its argument the directory that
contains the <span class="app">groff</span>'s site-font directory. Usually this is some
place like <span class="file">/usr/share/groff</span> or <span class="file">/usr/local/share/groff</span>,
but not all distributions create the <span class="file">site-font</span> directory. If
you don't specify <code class="docutils literal"><span class="pre">-P</span></code> <span class="command">install-font.sh</span> will guess the
location. (If the <span class="file">site-font</span> directory doesn't exist, or you
don't have write access to it I think you can use the environment
variable <code class="docutils literal">GROFF_FONT_PATH</code> to tell <span class="app">groff</span> where to find it,
but I've never used that and don't know the specifics. I often build
<span class="app">groff</span> from git and install it someplace my normal user has
write access to, so I haven't had to worry about it.) The <code class="docutils literal"><span class="pre">-d</span></code>
option says to make the font available to <span class="command">gropdf</span>. The
<code class="docutils literal"><span class="pre">-F</span></code> option takes an argument that specifies the font family name to
use. This is the name that you would use with the <code class="docutils literal">.fam</code> request or
the <code class="docutils literal"><span class="pre">-f</span></code> option to <span class="command">groff</span> to let it know you want to use
this font family. The <code class="docutils literal"><span class="pre">-f</span></code> option takes an argument that specifies
the font style to use, <code class="docutils literal">+R</code>, <code class="docutils literal">+I</code>, <code class="docutils literal">+B</code>, or <code class="docutils literal">+BI</code>. (The
<code class="docutils literal"><span class="pre">-f</span></code> option can instead take a name, but I don't use that form and
can't explain the distinctions.) The style (<code class="docutils literal">R</code>, <code class="docutils literal">I</code>, <code class="docutils literal">B</code>, or
<code class="docutils literal">BI</code>) is appended to the font family name specified with <code class="docutils literal"><span class="pre">-F</span></code> to
produce the name of the <span class="app">groff</span> font, and consequently the name
of the <span class="app">groff</span> font file that is written to the <code class="docutils literal">devps</code> and
<code class="docutils literal">devpdf</code> directories under <code class="docutils literal"><span class="pre">site-font</span></code>. So, in this example, the
name of the <span class="app">groff</span> font and the <span class="app">groff</span> font file would be
<span class="file">CormorantGaramondR</span>. The last argument to the script is the
name of the Truetype or OpenType file you are converting.</p>
<p>To complete the example, here are the commands to install the Italic,
Bold, and Bold Italic variants of Cormorant Garamond:</p>
<div class="code"><pre class="code bash"><a id="rest_code_6ea474dc405b4e1ba7a27d8bc563556c-1" name="rest_code_6ea474dc405b4e1ba7a27d8bc563556c-1" href="https://tkurtbond.github.io/posts/2021/07/17/groff-and-install-fontsh-and-installing-fonts-for-use-in-groff/#rest_code_6ea474dc405b4e1ba7a27d8bc563556c-1"></a><span class="k">$(</span>IFDIR<span class="k">)</span>/install-font.sh<span class="w"> </span>-n<span class="w"> </span>-P<span class="w"> </span><span class="s2">"</span><span class="nv">$DEST</span><span class="s2">"</span><span class="w"> </span>-d<span class="w"> </span>-F<span class="w"> </span>CormorantGaramond<span class="w"> </span>-f<span class="w"> </span>+I<span class="w"> </span>CormorantGaramond-Italic.ttf
<a id="rest_code_6ea474dc405b4e1ba7a27d8bc563556c-2" name="rest_code_6ea474dc405b4e1ba7a27d8bc563556c-2" href="https://tkurtbond.github.io/posts/2021/07/17/groff-and-install-fontsh-and-installing-fonts-for-use-in-groff/#rest_code_6ea474dc405b4e1ba7a27d8bc563556c-2"></a><span class="k">$(</span>IFDIR<span class="k">)</span>/install-font.sh<span class="w"> </span>-n<span class="w"> </span>-P<span class="w"> </span><span class="s2">"</span><span class="nv">$DEST</span><span class="s2">"</span><span class="w"> </span>-d<span class="w"> </span>-F<span class="w"> </span>CormorantGaramond<span class="w"> </span>-f<span class="w"> </span>+B<span class="w"> </span>CormorantGaramond-Bold.ttf
<a id="rest_code_6ea474dc405b4e1ba7a27d8bc563556c-3" name="rest_code_6ea474dc405b4e1ba7a27d8bc563556c-3" href="https://tkurtbond.github.io/posts/2021/07/17/groff-and-install-fontsh-and-installing-fonts-for-use-in-groff/#rest_code_6ea474dc405b4e1ba7a27d8bc563556c-3"></a><span class="k">$(</span>IFDIR<span class="k">)</span>/install-font.sh<span class="w"> </span>-n<span class="w"> </span>-P<span class="w"> </span><span class="s2">"</span><span class="nv">$DEST</span><span class="s2">"</span><span class="w"> </span>-d<span class="w"> </span>-F<span class="w"> </span>CormorantGaramond<span class="w"> </span>-f<span class="w"> </span>+BI<span class="w"> </span>CormorantGaramond-BoldItalic.
</pre></div>
<p>As I said in an earlier email to the list, I tend to put all four
commands into a script so I can run them again if something goes wrong
or when I need to install them on a new machine or in a new
installation of <span class="app">groff</span>. In the case of Cormorant Garamond I named the
file <span class="file">install-cormorant-garamond.sh</span>.</p>
<p><strong>Later:</strong> Peter Schaffter <a class="reference external" href="https://lists.gnu.org/archive/html/groff/2021-07/msg00090.html">pointed out</a> that the <em>simple</em> use of
<span class="command">install-font.sh</span> is:</p>
<div class="code"><pre class="code bash"><a id="rest_code_727f56a490074ad09e17843357bf4161-1" name="rest_code_727f56a490074ad09e17843357bf4161-1" href="https://tkurtbond.github.io/posts/2021/07/17/groff-and-install-fontsh-and-installing-fonts-for-use-in-groff/#rest_code_727f56a490074ad09e17843357bf4161-1"></a>sudo<span class="w"> </span>install-font.sh<span class="w"> </span>fontfile
</pre></div>
<p>and then answer the questions the script asks. He also pointed out
that it creates the <span class="file">site-font</span> directory and necessary
subdirectories if needed in, and here I quote: “the only two locations
it's ever likely to be”. Looking at <span class="command">install-font.sh</span> reveal
those locations are <span class="file">/usr/local/share/groff</span> and
<span class="file">/usr/share/groff</span>, defaulting to
<span class="file">/usr/local/share/groff</span>; to get it to use
<span class="file">/usr/share/groff</span> you specify the <code class="docutils literal"><span class="pre">-s</span></code> option.</p>
<p>For a walk-through of the simple use see the <a class="reference external" href="https://tkurtbond.github.io/posts/2021/07/17/install-fontsh-the-simple-approach/">follow-up</a>.</p>
<p><em>Last edited: 2021-07-15 17:46:40 EDT</em></p>
<!-- Local Variables:
time-stamp-format: "%Y-%02m-%02d %02H:%02M:%02S %Z"
time-stamp-start: "\\*Last edited:[ \t]+\\\\?"
time-stamp-end: "\\*\\\\?\n"
time-stamp-line-limit: -20
End: -->