From owner-freebsd-doc Tue Jul 6 13:24:39 1999 Delivered-To: freebsd-doc@freebsd.org Received: from mail.vicor-nb.com (bigwoop.vicor-nb.com [208.206.78.2]) by hub.freebsd.org (Postfix) with ESMTP id A9A8314BD7 for ; Tue, 6 Jul 1999 13:24:33 -0700 (PDT) (envelope-from kmarx@bigshed.com) Received: from bigshed.com (pri-180-dev.vicor-nb.com [208.206.78.180]) by mail.vicor-nb.com (Postfix) with ESMTP id 44D4F97E01; Tue, 6 Jul 1999 13:24:32 -0700 (PDT) Message-ID: <378266B3.D1A128F0@bigshed.com> Date: Tue, 06 Jul 1999 13:27:31 -0700 From: Ken Marx X-Mailer: Mozilla 4.5 [en] (X11; I; FreeBSD 2.2.8-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: freebsd-doc@FreeBSD.ORG Cc: Ken Marx Subject: groff & truetype fonts Content-Type: multipart/mixed; boundary="------------3C1CF1EA0CF97A37329BB8C2" Sender: owner-freebsd-doc@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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" 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-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-doc" in the body of the message