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