Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 06 Jul 1999 13:27:31 -0700
From:      Ken Marx <kmarx@bigshed.com>
To:        freebsd-doc@FreeBSD.ORG
Cc:        Ken Marx <kmarx@bigshed.com>
Subject:   groff & truetype fonts
Message-ID:  <378266B3.D1A128F0@bigshed.com>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------3C1CF1EA0CF97A37329BB8C2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,
 
I recently had to convert truetype fonts for use with groff.
I thought this might be a useful addition to Dave Bodenstab's
*excellent* primer (http://www.pt.freebsd.org/tutorials/fonts/fonts.html). 

It currently states:
 
    "Using TrueType with groff is difficult because groff would need a
    font description file, and I know of no tools to construct the
    metrics from a TrueType font. In addition, the font would have to
    be downloaded to postscript printers in the appropriate format,
    and again, groff cannot handle TrueType fonts in this fashion."
 
I figured out how to address the first part of this pretty well.
Here's a synopsis of what I've got:  
    
    - Works fine with groff
    - Printing must use ghostscript with the proper printer device name
      (such as ljet4 for HP-PCL)
    - Still doesn't work for pure postscript printer. Must use gs and  
      some native printer language supported by the printer (e.g., PCL)
      OR the printer must somehow get copies of the postscript font loaded
      onto it.
    - I ended up finding a different afmtodit utility than what
      he talks about. Seems like either works.
    - Some points are just my best guess at an explanation, but the
      results do work...

Suggestions:

- I'm wondering if the ttf2ps util I found might also be considered
for inclusion with the FreeBSD distribution?
 
- He refers to ghostscript 4.01 in the current writeup. You might want to
update this to mention that ghostscript 5.10 does a much better
job of handling some of the truetype stuff.
 
...

So, below is the relevant part of some doc I did for my project.
I also attached a lame html version.
 
Thanks for your time.
 
k.

-- 
Ken Marx, kmarx@bigshed.com
It's wrong headed not to capitalize on the strengths and synergies of our 
business and maintain a horizontal view of the backbone.
		- http://cgi.bigshed.com/~kmarx/cgi-bin/speak.cgi

-------------------------- snip ---------------------------------------

...

    2. Converting the font to a groff/postscript format for groff

    This requires potentially a bit more work, simply becuase it
    depends on some utilities that often aren't installed or
    downloaded. They are:

    ttf2pf - TrueType to postscript convertsion utilities. This
    allows conversion of a TrueType font to an ascii font metric
    (.afm) file.

    Currently available at:
     http://sunsite.icm.edu.pl/pub/GUST/contrib/BachoTeX98/ttf2pf/.
    Note: These files are postscript programs and must be downloaded
    to disk by holding down the shift key when clicking on the
    link. Otherwise, your browser may try to launch ghostview to
    view them.

    The files of interest are:

                      GS_TTF.PS
                      PF2AFM.PS
                      ttf2pf.ps

    The funny upper/lower case is due to their being intended also
    for DOS shells.  ttf2pf.ps makes use of the others as upper
    case, so any renaming must be consistent with this. (Actually,
    GS_TTF.PS and PFS2AFM.PS are supposedly part of the ghostscript
    distribution, but it's just as easy to use these as an isolated
    utility.  FreeBSD doesn't seem to include the latter.) You also
    may want to have these installed to /usr/local/bin, or ...(?)

    afmtodit  - Create font files for use with groff, using a .afm
    file. This usually resides in the directory,
    /usr/src/contrib/groff/afmtodit, and requires some work to get
    going.

    If you're paranoid about working in the /usr/src tree, simply
    copy the contents of the above directory to a work location.
    In the work area, you'll need to make the utility.

    Type:

        make -f Makefile.sub afmtodit

    You may also need to copy /usr/contrib/groff/devps/generate/textmap to
    /usr/share/groff_font/devps/generate if it doesn't already exist.

    Once all these utilities are in place, you're ready to commence:

        Create the .afm file by typing:

        gs [-dNODISPLAY] [-q] -- ttf2pf.ps TTF_name [PS_font_name
        [AFM_name]]

    Where, TTF_name is your TrueType font file, PS_font_name is
    the name by which you wish the font to be known (default is
    whatever is used in the TTF_name file), and AFM_name is the
    name you wish for the .afm file.

    This also produces a .pfa file, the ascii postscript font
    metrics file (.pfb is for the binrary form). This won't be
    needed, but could (I think) be useful for a fontserver.

    Change directories to /usr/share/groff_font/devps so as to make
    the following command easier to execute. You'll probably need
    root priviledges for this. (Or, if you're paranoid about working
    there, make sure you reference the files DESC, text.enc and
    generate/textmap as being in this directory.)

        Create the groff postscript file:

           % afmtodit -d DESC -e text.enc file.afm \
                    generate/textmap PS_font_name

    Where,  file.afm is the AFM_name created by the ttf2pf.ps
    program above, and PS_font_name is the font name used from that
    command, as well as the name that groff (1) will use for
    references to this font. For example, the 3of9 Barcode font
    was created using the command:

        % /tmp/afmtodit/afmtodit -d DESC -e text.enc 3of9.afm \
                 generate/textmap 3of9

    Ensure that the resulting PS_font_name file (e.g., 3of9 in the
    above example) is finally located in the directory,
    /usr/share/groff_font/devps.

    Note that if ttf2pf.ps assigns a font name using the one it
    finds in the ttf file and you want to use a different name,
    you must edit the .afm file prior to running afmtodit.  This
    name must also match the one used in the Fontmap file for
    seemless use of groff, piping to gs.
--------------3C1CF1EA0CF97A37329BB8C2
Content-Type: text/html; charset=us-ascii;
 name="ttf2groff.html"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="ttf2groff.html"

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="GENERATOR" content="Mozilla/4.5 [en] (X11; I; FreeBSD 2.2.8-RELEASE i386) [Netscape]">
</head>
<body>
2. Converting the font to a groff/postscript format for groff
<p>&nbsp;&nbsp;&nbsp; This requires potentially a bit more work, simply
becuase it depends on some utilities
<br>&nbsp;&nbsp;&nbsp; that often aren't installed or downloaded. They
are:
<p>&nbsp;&nbsp;&nbsp; ttf2pf - TrueType to postscript convertsion utilities.
This allows conversion of a
<br>&nbsp;&nbsp;&nbsp; TrueType font to an ascii font metric (.afm) file.
<p>&nbsp;&nbsp;&nbsp; Currently available at:
<br>&nbsp;&nbsp;&nbsp;&nbsp; http://sunsite.icm.edu.pl/pub/GUST/contrib/BachoTeX98/ttf2pf/
. Note: These files
<br>&nbsp;&nbsp;&nbsp; are postscript programs and must be downloaded to
disk by holding down the shift
<br>&nbsp;&nbsp;&nbsp; key when clicking on the link. Otherwise, your browser
may try to launch ghostview
<br>&nbsp;&nbsp;&nbsp; to view them.
<p>&nbsp;&nbsp;&nbsp; The files of interest are:
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
GS_TTF.PS
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
PF2AFM.PS
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ttf2pf.ps
<p>&nbsp;&nbsp;&nbsp; The funny upper/lower case is due to their being
intended also for DOS shells.
<br>&nbsp;&nbsp;&nbsp; ttf2pf.ps makes use of the others as upper case,
so any renaming must be consistent
<br>&nbsp;&nbsp;&nbsp; with this. (Actually, GS_TTF.PS and PFS2AFM.PS are
supposedly part of the
<br>&nbsp;&nbsp;&nbsp; ghostscript distribution, but it's just as easy
to use these as an isolated utility.
<br>&nbsp;&nbsp;&nbsp; FreeBSD doesn't seem to include the latter.) You
also may want to have these
<br>&nbsp;&nbsp;&nbsp; installed to /usr/local/bin, or ...(?)
<p>&nbsp;&nbsp;&nbsp; afmtodit&nbsp; - Create font files for use with groff,
using a .afm file. This usually resides
<br>&nbsp;&nbsp;&nbsp; in the directory, /usr/src/contrib/groff/afmtodit,
and requires some work to get going.
<p>&nbsp;&nbsp;&nbsp; If you're paranoid about working in the /usr/src
tree, simply copy the contents of the
<br>&nbsp;&nbsp;&nbsp; above directory to a work location. In the work
area, you'll need to make the utility.
<br>&nbsp;&nbsp;&nbsp; Type:
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; make -f Makefile.sub afmtodit
<p>&nbsp;&nbsp;&nbsp; You may also need to copy /usr/contrib/groff/devps/generate/textmap
to
<br>&nbsp;&nbsp;&nbsp; /usr/share/groff_font/devps/generate if it doesn't
already exist.
<p>&nbsp;&nbsp;&nbsp; Once all these utilities are in place, you're ready
to commence:
<br>&nbsp;
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Create the .afm file by typing:
<br>&nbsp;
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gs [-dNODISPLAY] [-q] --
ttf2pf.ps TTF_name [PS_font_name
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [AFM_name]]
<p>&nbsp;&nbsp;&nbsp; Where, TTF_name is your TrueType font file, PS_font_name
is the name by which
<br>&nbsp;&nbsp;&nbsp; you wish the font to be known (default is whatever
is used in the TTF_name file), and
<br>&nbsp;&nbsp;&nbsp; AFM_name is the name you wish for the .afm file.
<p>&nbsp;&nbsp;&nbsp; This also produces a .pfa file, the ascii postscript
font metrics file (.pfb is for the
<br>&nbsp;&nbsp;&nbsp; binrary form). This won't be needed, but could (I
think) be useful for a fontserver.
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Change directories to /usr/share/groff_font/devps
so as to make the following
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; command easier to execute.
You'll probably need root priviledges for this. (Or, if
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; you're paranoid about working
there, make sure you reference the files DESC,
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; text.enc and generate/textmap
as being in this directory.)
<br>&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Create the groff postscript
file:
<br>&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; % afmtodit
-d DESC -e text.enc file.afm \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
generate/textmap PS_font_name
<p>&nbsp;&nbsp;&nbsp; Where,&nbsp; file.afm is the AFM_name created by
the ttf2pf.ps program above, and
<br>&nbsp;&nbsp;&nbsp; PS_font_name is the font name used from that command,
as well as the name that
<br>&nbsp;&nbsp;&nbsp; groff (1) will use for references to this font.
For example, the 3of9 Barcode font was
<br>&nbsp;&nbsp;&nbsp; created using the command:
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; % /tmp/afmtodit/afmtodit
-d DESC -e text.enc 3of9.afm \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
generate/textmap 3of9
<br>&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ensure that the resulting
PS_font_name file (e.g., 3of9 in the above example)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; is finally located in the
directory, /usr/share/groff_font/devps.
<p>&nbsp;&nbsp;&nbsp; Note that if ttf2pf.ps assigns a font name using
the one it finds in the ttf file and you
<br>&nbsp;&nbsp;&nbsp; want to use a different name, you must edit the
.afm file prior to running afmtodit.
<br>&nbsp;&nbsp;&nbsp; This name must also match the one used in the Fontmap
file for seemless use of
<br>&nbsp;&nbsp;&nbsp; groff, piping to gs.
</body>
</html>

--------------3C1CF1EA0CF97A37329BB8C2--



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-doc" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?378266B3.D1A128F0>