groff
[Top][All Lists]
Advanced

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

Re: Using arbitrary fonts


From: G. Branden Robinson
Subject: Re: Using arbitrary fonts
Date: Mon, 30 Jan 2023 10:19:56 -0600

Hi Blake,

At 2023-01-30T09:28:50-0600, Blake McBride wrote:
> I have been using the default groff fonts for many happy years.
> However, I need to produce a document with a machine-generated
> signature.  There are plenty of adequate signature fonts out there.
> However, I do not know how to make groff use them.
> 
> I downloaded a font.  It came with files with the .otf, .ttf, .woff,
> and .woff2 extensions.  What are the exact steps I need to use to use
> them in a groff/mm document?  (I only want one line to use the special
> font.  The rest of the document can use the regular groff fonts.)

The first thing to do is to make the font visible to the output driver,
which will probably be "ps" or "pdf".

Here are some instructions from the grops(1) page in groff Git.

  TrueType and other font formats
    TrueType fonts can be used with grops if converted first to Type 42
    format, a PostScript wrapper equivalent to the PFA format described
    in pfbtops(1).  Several methods exist to generate a Type 42 wrapper;
    some of them involve the use of a PostScript interpreter such as
    Ghostscript—see gs(1).

    One approach is to use FontForge, a font editor that can convert
    most outline font formats.  Here’s an example of using the Roboto
    Slab Serif font with groff.  Several variables are used so that you
    can more easily adapt it into your own script.

        MAP=/usr/local/share/groff/1.23.0/font/devps/generate/text.map
        TTF=/usr/share/fonts/truetype/roboto/slab/RobotoSlab-Regular.ttf
        BASE=$(basename "$TTF")
        INT=${BASE%.ttf}
        PFA=$INT.pfa
        AFM=$INT.afm
        GFN=RSR
        DIR=$HOME/.local/groff/font
        mkdir -p "$DIR"/devps
        fontforge -lang=ff -c "Open(\"$TTF\");\
        Generate(\"$DIR/devps/$PFA\");"
        afmtodit "$DIR/devps/$AFM" "$MAP" "$DIR/devps/$GFN"
        printf "$BASE\t$PFA\n" >> "$DIR/devps/download"

    fontforge and afmtodit may generate warnings depending on the
    attributes of the font.  The test procedure is simple.

        printf ".ft RSR\nHello, world!\n" | groff -F "$DIR" > hello.ps

    Once you’re satisfied that the font works, you may want to generate
    any available related styles (for instance, Roboto Slab also has
    “Bold”, “Light”, and “Thin” styles) and set up GROFF_FONT_PATH in
    your environment to include the directory you keep the generated
    fonts in so that you don’t have to use the -F option.

Ensure that you do the test procedure shown, before worrying about macro
package integration.

Once this works (please reply to the list if it doesn't), the mm usage
issue can be tackled.

> I need to produce a document with a machine-generated signature.

In mm this requires some context.  Are you using one of the memorandum
types ("MT") or one of the letter formats ("LT")?  If so I'll have do
some digging, because the signature line is automatically printed and
I'll need to work up a recommendation for how to override that cleanly
(or someone who's more of an mm expert than I am may have ideas).

If not, and you're outputting the signature line like any other
formatted text, it should be straightforward.

Put in a line like this.

\f[YOURNEWFONT]Blake McBride\f[]

...where YOURNEWFONT is the groff name you have given to the font you
installed using the procedure above.

Let us know if this helps, or doesn't.

Regards,
Branden

Attachment: signature.asc
Description: PGP signature


reply via email to

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