groff
[Top][All Lists]
Advanced

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

adjusting font picks for code snippets and math


From: Norwid Behrnd
Subject: adjusting font picks for code snippets and math
Date: Fri, 6 Sep 2024 11:38:43 +0200

Hello,

I would like a different font for the display of snippets of source code in pdf
the default installation of groff in Linux Debian (version 1.23.0) renders with
Courier, and improve the one of mathematics.  Unsure if this a question of
proper font installation, or perhaps using groff in general, I want to address
the question here.

part 1) The conversion of a markdown file into .ms with Pandoc writes a
preamble including the two lines

```
.\" font family: A, BM, H, HN, N, P, T, ZCM
.fam P
```

Following the demonstration of Gavin Freeborn,[1] I fetched font files about
Libertine from CTAN,[2] and successfully installed the data for regular,
italic, and bold characters with Peter Schaffter's script[3] by

```
$ sudo ./install-font.sh -s -d -F Libertine -f +R LinLibertineO.pfb 
$ sudo ./install-font.sh -s -d -F Libertine -f +I LinLibertineOI.pfb
$ sudo ./install-font.sh -s -d -F Libertine -f +B LinLibertineOB.pfb
```

This now allows me to use

```
.fam Libertine
```

for the running text. While the documentation[4] states groff's set of R, I,
B, BI fonts can be extended, the large table does not explicitly hint how one
can add a non-proportional font (e.g., Bera Mono[5]) to the effect this one to
be used only for snippets of code.  Is there a particular "key" -- like `R`
for regular/Roman -- to restrain the eventual use of this font one can provide
during the installation?  

1b) Presuming there were two non-proportional fonts at disposition, what can I
add to the document's preamble to let groff know to then use Bera Mono instead
of Courier for snippets of code?

1c) (pdf)LateX allows to activate fonts with an optional scaling of their
glyphs' height, e.g. `\usepackage[scaled]{beramono}`[6].  Does groff provide a
similar functionality?

---

part 2) Compiling the snippet shared below with

```
$ groff -e -ms -Tpdf 2test.ms > 2test.pdf
```

the variation of the font family from the default set of A, BM, H, HN, N, or P,
does not affect the glyph about rho during var.  Using for instance font family
BM depicts the plus signs differently in text and math mode.  With the amended
Libertine font, a

```
.fam Libertine
```

in the document's preamble now picks a different glyph about rho however
breaks the square root into pieces.

Based on these observations, what could be the/a recommended "groff key" during
the installation (as in 1a) and subsequent use (as in 1b) to substitute this
default font?  In the present context, `LibertinusT1Math.pfb` of
LibertinusT1Math[7] appears as suitable pick for that its glyphs are closely
related to the ones of Libertine.  On the other hand, this set simultaneously
contains glyphs which are regular [Roman, Greek, Cyrillic], italic, bold, math
doublestroke -- a blend beyond the scope of Peter Schaffter's present guide.

Regards,

Norwid


```
.\" name: 2test.ms
.\" compilation: groff -e -ms -Tpdf 2test.ms > 2test.pdf
.\" font family: A, BM, H, HN, N, P, T, ZCM
.fam BM
.EQ
delim @@
.EN
.LP
This is normal text, \f[I]italic\f[R], and \f[B]bold\f[R].
An in\-line equation @E = m c sup 2@ followed by one in display-style
.EQ
x sub {1 , 2} = p over 2 +- sqrt {{p sup 2} over 4 - q}
.EN
.LP
Code snippet: \f[CR]write(fileunit,"(I3,1x,F5.2)") counter, area\f[R].
.PP
.EQ
rho = m over V
.EN
Glyphs about the plus sign appear of different origin, see + vs @+@.
```

[1] https://www.youtube.com/watch?v=CzUHjtGBdZs
[2] https://ctan.org/pkg/libertine
[3] https://www.schaffter.ca/mom/bin/install-font.sh
[4] https://www.schaffter.ca/mom/momdoc/appendices.html#fonts
[5] https://www.ctan.org/pkg/bera
[6] https://tug.org/FontCatalogue/beramono/
[7] https://ctan.org/pkg/libertinust1math

Attachment: LibertinusT1Math.pfb
Description: application/font-type1


reply via email to

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