groff
[Top][All Lists]
Advanced

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

Re: [Groff] Access alternative figures from OpenType fonts


From: Werner LEMBERG
Subject: Re: [Groff] Access alternative figures from OpenType fonts
Date: Fri, 13 Nov 2015 05:30:06 +0100 (CET)

> I choose Cormorant (see below) which came in otf format.

Hmm, the current github version no longer comes in OTF but only in TTF
format.

  https://github.com/CatharsisFonts/Cormorant

The last OpenType version was v0.6, apparently.

> I envision two macros: .onum and .lnum which set the old style or
> the lining one; both may be written (I guess) with some magic code
> together the .char command.

Yes :-)

> My CormorantR file seems to have not reference for lnum figures,
> even when it has references to the dnom and numr character sets.

Lnum figures have `.lf' as a suffix in its glyph names (at least in
the last release, v0.8).

Maybe you haven't used the right program to generate the AFM?  I
opened Cormoran0008-Regular.ttf with FontForge, selecting

  File -> Generate Fonts
    -> PS Type 1 (Ascii)
    -> Options -> Output AFM

and after pressing the `Generate' button I get a PFA (which you can
delete) and a 2.8MB(!) AFM file; the latter contains proper entries
for the `*.lf' glyphs.

You should use a Type 42 font that is directly derived from the TTF
without an intermediate step; for this reason I recommend the
`ttftotype42' program the LCDF Typetools package instead of FontForge
(which converts everything to its own font format before generating a
new font).

  https://github.com/kohler/lcdf-typetools

Running the standard invocation

  afmtodit Cormorant0008-Regular.t42 textmap CormorantR

on the generated AFM works fine; for example, `seven.lf' is mapped to
glyph index 820 and is thus accessible as

  \N'820'

within groff.

Unfortunately, the groff font file format doesn't support kerning for
unnamed glyphs.  To fix that, you have to use a custom-made `textmap'
file.  For example, copy
`/usr/share/groff/current/font/devps/generate/textmap' to
`Cormorant.textmap' and append the lines

  zero.lf zero.lf
  one.lf one.lf
  two.lf two.lf
  three.lf three.lf
  four.lf four.lf
  five.lf five.lf
  six.lf six.lf
  seven.lf seven.lf
  eight.lf eight.lf
  nine.lf nine.lf

to it, then call

  afmtodit Cormorant0008-Regular.t42 Cormorant.textmap CormorantR

and you find the following, additional lines in `CormorantR'.

  seven.lf bq -35
  seven.lf Bq -35
  seven.lf _ -35
  seven.lf . -35
  seven.lf u2026 -35
  seven.lf , -35
  nine.lf bq -23
  nine.lf Bq -23
  nine.lf _ -23
  nine.lf . -23
  nine.lf u2026 -23
  nine.lf , -23

This approach also has the benefit that the ten lnum digits are no
longer unnamed but have groff glyph names like `\[seven.lf]'.

Oh, by the way, two macros to switch between normal and lnum figures
should be now (untested)

  .de lnum
  .  char 0 \[zero.lf]
  .  char 1 \[one.lf]
  .  char 2 \[two.lf]
  .  char 3 \[three.lf]
  .  char 4 \[four.lf]
  .  char 5 \[five.lf]
  .  char 6 \[six.lf]
  .  char 7 \[seven.lf]
  .  char 8 \[eight.lf]
  .  char 9 \[nine.lf]
  ..

  .de onum
  .  rchar 0
  .  rchar 1
  .  rchar 2
  .  rchar 3
  .  rchar 4
  .  rchar 5
  .  rchar 6
  .  rchar 7
  .  rchar 8 
  .  rchar 9
  ..


    Werner

reply via email to

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