groff
[Top][All Lists]
Advanced

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

[groff] [UTROFF] About fonts


From: Pierre-Jean
Subject: [groff] [UTROFF] About fonts
Date: Fri, 01 Dec 2017 08:39:49 +0100
User-agent: mail v14.8.16

Hello alls,

As said yesterday, my little tour of Utmac will focus today on
fonts.  And I hope to prove you wrong if you think there’s not
much to discuss on that topic!

# An user interface for fonts
-----------------------------

Heirloom Troff can mount OpenType fonts like any other font. It
can also define all kind of ligatures, adapt the kerning, and
enables the OpenType features, as follow.

    .fp 1 R LinLibertine_R otf
    .flig R ct \[c_t] st \[s_t]
    .feature R +lnum
    .kernafter R ’ 100


That’s very handy. But the problem with such an easiness and the
variety of available features, is that I quickly had too many
mounted fonts, and it was becoming difficult to name each of
them. Another problem was coming for the difficulty to know which
font to use in a particular context. For example, the (private)
font Apolline, has a lightly embolden font made for small text:
If the user want to use italic inside a note, he should not use
\fI, but \f(DI.

To solve these problems, I began to use strings to define fonts,
and I eventually opted for the easy, hierarchical, xml inspired,
user interface for fonts:

    Roman \*IItalic\*I \*BBold \*IBold Italic \*UBold Italic
    Superscript\*U\*I\*B


I think there is yet a post on this list about those font
toggles.  Here is how it is implemented in Utmac (in the file
u-fonts.tmac).  First, fonts are internally mounted and named in
the form f-[Bold][Italic][Feature], where Bold, Italic, and
Feature are numbers:

    f-000 roman
    f-100 bold
    f-010 italic
    f-001 small capitals
    f-002 acronyms, all capitals
    f-003 superscripts
    f-004 subscript
    f-005 final glyphs
    f-113 bold italic superscirpt
    f-302 Extra bold acronyms

Secondly strings are defined to expand to the internal font name:

    .ds I \f[010]


Thirdly, a substraction is inserted in the string definition, to
toggle the font on or off each time it is used.

    .nr f-i 0
    .ds I \\R’f-i 1-\\n[f-i]’\\f[0\\n[f-i]0]
    \*Iblah\*I => \f[010]blah\f[000]
    .
    .ds B \\R’f-b 1-\\n[f-b]’\\f[\\n[f-b]\\n[f-i]0]
    .ds I \\R’f-i 1-\\n[f-i]’\\f[\\n[f-b]\\n[f-i]0]
    \*Iblah \*Bblah\*B\*I => \f[010]blah \f[110]blah\f[010]\f[000]


Fourthly, a system allows the possibility to set all kind of
defaults, ie, to say that the default font is f-310, and its
italic f-300.  In the end, the strings are defined as follow:

    .\" The mounted font (roman)
    .ft f-000
    .\" The font toggles: unset if == 0, set if > 0.
    .nr f-b 0
    .nr f-i 0
    .nr f-f 0
    .\" The subfont strings: we may want the default
    .\" to be italicized (for example in a heading),
    .\" and the \*I to toggle the Roman form...
    .\" So, these strings offer that possibility.
    .\" (I did not need subfont strings for the features)
    .nr font-bold0 0
    .nr font-bold1 1
    .nr font-ital0 0
    .nr font-ital1 1
    .\" The whole internal font string, of the form f-XXX
    .ds f-l f-\\n[font-bold\\n[f-b]]\\n[font-ital\\n[f-i]]\\n[f-f]
    .\" The font strings displayed to the user
    .\" The first part of the string toggles the format.
    .\" The second part of the string sets (print) the font.
    .\" Bold
    .ds B \\ER’f-b 1-\\En[f-b]’\\f[\\E*[f-l]]
    .\" Italic
    .ds I \\ER’f-i 1-\\En[f-i]’\\f[\\E*[f-l]]
    .\" Small capitals
    .ds C \\ER’f-f 1-\\En[f-f]’\\f[\\E*[f-l]]
    .\" Acronyms (all capitals)
    .ds A \\ER’f-f 2-\\En[f-f]’\\f[\\E*[f-l]]
    .\" Superscript
    .ds U \\ER’f-f 3-\\En[f-f]’\\f[\\E*[f-l]]
    .\" Subscript
    .ds L \\ER’f-f 4-\\En[f-f]’\\f[\\E*[f-l]]
    .\" Final glyphs
    .ds F \\ER’f-f 5-\\En[f-f]’\\f[\\E*[f-l]]


While the system may seem complex, it works perfectly, and has a
very simple user interface. It also comes with another advantage:
it is now easy to create xml documents from troff sources. But
that will be for my next topic!

Cheers,
Pierre-Jean.




reply via email to

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