| 1 |
.. _PfaEdit-TeX.TeX: |
| 2 |
|
| 3 |
FontForge and TeX |
| 4 |
================= |
| 5 |
|
| 6 |
FontForge has a number of features built in to it to deal with TeX. |
| 7 |
|
| 8 |
It can read "pk" and "gf" bitmap files and |
| 9 |
:ref:`autotrace <elementmenu.AutoTrace>` them to generate outline fonts. It can |
| 10 |
even invoke metafont directly on a ".mf" file, generate a "gf" bitmap from that, |
| 11 |
autotrace it and generate an outline font. |
| 12 |
|
| 13 |
It can read ligature, kerning information from a ".tfm" file. It can create a |
| 14 |
tfm file. |
| 15 |
|
| 16 |
The `encodings <https://fontforge.org/downloads/Encodings.ps.gz>`__ file has a number of standard TeX |
| 17 |
encodings built in to it. |
| 18 |
|
| 19 |
For large CJK truetype fonts it can read a sub-font definition file as defined |
| 20 |
in the ttf2tfm man page and :doc:`generate </ui/dialogs/generate>` a series of postscript |
| 21 |
type-1 fonts based on those two. |
| 22 |
|
| 23 |
In consultation with the lilypond group we have designed a new |
| 24 |
:doc:`SFNT table 'TeX <non-standard>` ' for storing TeX specific information in |
| 25 |
True/OpenType files. |
| 26 |
|
| 27 |
|
| 28 |
Generating a tfm file (and an enc file). |
| 29 |
---------------------------------------- |
| 30 |
|
| 31 |
Before you generate a tfm file you should perform some of the following |
| 32 |
|
| 33 |
.. object:: Set the font parameters |
| 34 |
|
| 35 |
Do this with :menuselection:`Element --> Font Info --> TeX`. |
| 36 |
|
| 37 |
.. _PfaEdit-TeX.Italic: |
| 38 |
|
| 39 |
.. object:: Optionally set Italic Correction values for glyphs |
| 40 |
|
| 41 |
(FontForge will generate default values for italic fonts, so you only need do |
| 42 |
this if FontForge gets it wrong). |
| 43 |
|
| 44 |
* Select a glyph which should have an Italic Correction |
| 45 |
* :menuselection:`Element --> Glyph Info --> Alt Pos` |
| 46 |
* Press [New] |
| 47 |
* Set the tag to ``Italic Correction`` from the pulldown list |
| 48 |
* Set the XAdvance to the italic correction |
| 49 |
|
| 50 |
.. _PfaEdit-TeX.charlist: |
| 51 |
|
| 52 |
.. object:: Optionally set any glyphlists |
| 53 |
|
| 54 |
* Select the first glyph in the glyphlist (the smallest one) |
| 55 |
* :menuselection:`Element --> Glyph Info --> Alt Subs` |
| 56 |
* Press [New] |
| 57 |
* Set the tag to ``TeX Glyphlist`` from the pulldown list |
| 58 |
* Type the names of all the other glyphs in the glyphlist into the Components |
| 59 |
field |
| 60 |
|
| 61 |
So if the charlist is for left parenthesis |
| 62 |
|
| 63 |
You would select the lparen glyph and might type in "lparen.big lparen.bigger |
| 64 |
lparen.biggest" |
| 65 |
|
| 66 |
.. _PfaEdit-TeX.extension: |
| 67 |
|
| 68 |
.. object:: Optionally set any extension glyphs. |
| 69 |
|
| 70 |
* If the glyph is in a charlist then Select the last glyph in the glyphlist |
| 71 |
(the largest one) |
| 72 |
* :menuselection:`Element --> Glyph Info --> Mult Subs` |
| 73 |
* Press [New] |
| 74 |
* Set the tag to ``TeX Extension list`` from the pulldown list |
| 75 |
* Type the names of the glyphs that this glyph decomposes into in the order: |
| 76 |
top middle bottom extension |
| 77 |
|
| 78 |
If a field is not present use .notdef |
| 79 |
|
| 80 |
So if the extension list is for left parenthesis |
| 81 |
|
| 82 |
You would select the lparen.biggest glyph and might type in "lparen.top |
| 83 |
lparen.mid lparen.bottom lparen.ext" |
| 84 |
|
| 85 |
Note: When FontForge does a :menuselection:`File --> Merge Feature Info` on a |
| 86 |
tfm file, it will set these values appropriately. |
| 87 |
|
| 88 |
Having done this to your satisfaction you are ready to generate a tfm file. Go |
| 89 |
to :menuselection:`File --> Generate Fonts`, select one of the postscript |
| 90 |
encodings from the pulldown list, press the [Options] button and turn on the [*] |
| 91 |
Tfm & Enc check box. |
| 92 |
|
| 93 |
I'm not sure what you *do* with these files yet, but this should create them. |
| 94 |
|
| 95 |
|
| 96 |
.. _PfaEdit-TeX.TeX-Install: |
| 97 |
|
| 98 |
Installing a type1 (pfb) postscript font for TeX |
| 99 |
------------------------------------------------ |
| 100 |
|
| 101 |
I am a novice TeX/LaTeX user so my comments should be taken with a grain of |
| 102 |
salt. I did manage to get this process to work on my own system. |
| 103 |
|
| 104 |
Installing a PostScript font for TeX is more complicated than one would hope |
| 105 |
(and so far I've only figured out how to install a Latin font). Instead of just |
| 106 |
moving the font file to some standard directory you must: |
| 107 |
|
| 108 |
* <configure TeX so that it is prepared for local additions> |
| 109 |
* Rename the font file so that the filename is in a format TeX understands |
| 110 |
|
| 111 |
(I'm told this isn't required, but I couldn't get things to work without doing |
| 112 |
this. Perhaps I have an old system. Perhaps I didn't try hard enough) |
| 113 |
* Create several helper files that TeX will use for its own purposes |
| 114 |
* Move each file type into its own special directory |
| 115 |
* Optionally: Create a package file to make it easy for LaTeX to find the font |
| 116 |
* Optionally: Move the package file into its own directory |
| 117 |
* Use the updmap script or manually: |
| 118 |
|
| 119 |
* Update dvips's configuration files so that it knows where to look for the |
| 120 |
postscript fonts |
| 121 |
* Optionally: Update pdftex's configuration files so that it knows where to look |
| 122 |
too. |
| 123 |
|
| 124 |
I suggest that before you read further you look at the following resources on |
| 125 |
the web: |
| 126 |
|
| 127 |
* It is possible to add your fonts to the standard TeX directory structure, but |
| 128 |
the TeX guru's frown on this as it makes updating TeX difficult. They suggest |
| 129 |
instead that you make all your changes in some parallel directory and provide |
| 130 |
they instructions on how to go about doing this at: |
| 131 |
`Installation advice for TeX fonts and directories <http://www.ctan.org/installationadvice/>`_. |
| 132 |
They also provide an example of a font installation but that is better explained |
| 133 |
in |
| 134 |
`the LaTeX font-faq <http://www.ctan.org/tex-archive/info/Type1fonts/fontinstallationguide.pdf>`_. |
| 135 |
* Old versions of TeX (ie. mine) are still worried about the old 8 character |
| 136 |
limitation on DOS filenames. This means that the tools I was using don't accept |
| 137 |
understandable filenames instead they require a format described in |
| 138 |
`TeX font file naming conventions <http://www.tug.org/fontname/html/index.html>`_. |
| 139 |
If you are creating your own fonts this boils down to: |
| 140 |
|
| 141 |
* the first letter of the font should be "f" (which means the font wasn't made by |
| 142 |
one of the big-name font vendors) |
| 143 |
* the next two letters are some abbreviation of the family-name for your font |
| 144 |
* the next letter (or two) should be "r" for a roman font, "i" for italic, "o" for |
| 145 |
oblique, "b" for bold, and "bi" for bold italic |
| 146 |
* the last two letters should be "8a" (which means your font is in Adobe Standard |
| 147 |
Encoding. And your font *must be* in that encoding or things don't work). |
| 148 |
|
| 149 |
(Again I am told that you can use any encoding as long as you register it with |
| 150 |
TeX. I was unable to get this to work. But my system is out of date) |
| 151 |
* Finally |
| 152 |
`the LaTeX font-faq <http://www.ctan.org/tex-archive/info/Type1fonts/fontinstallationguide.pdf>`_ |
| 153 |
describes the gory details of how to go about installing the font. Its only |
| 154 |
(minor) drawback is that it assumes you are installing a font from Adobe. That |
| 155 |
is easily glossed over it means that: |
| 156 |
|
| 157 |
* fonts from Adobe should have font names beginning with "p" rather than "f". |
| 158 |
* the translation from adobe's font-families to 2 character abbreviations has |
| 159 |
already been done, when using an adobe font you look the family up in a table to |
| 160 |
get the 2 character abbreviation, when creating your own font you make up your |
| 161 |
own. |
| 162 |
* the vendor directory for adobe is "adobe", but the vendor directory for fonts |
| 163 |
you make should be "public" |
| 164 |
* (I hope these comments will make sense after you've read the above links) |
| 165 |
* I've not tried to work with truetype fonts, but here's a document that talks |
| 166 |
about it to some extent. |
| 167 |
`LaTeX and TTF <http://www.radamir.com/tex/ttf-tex.htm>`_ |
| 168 |
* If you are interested in the basics, here's the documentation on |
| 169 |
`fontinst <http://www.ctan.org/tex-archive/fonts/utilities/fontinst/doc/fontinst.ps>`_ |
| 170 |
itself. |
| 171 |
* I don't know how to deal with cyrillic (except that cyrillic T2 encodings are |
| 172 |
called 6a), greek or CJK fonts yet. |
| 173 |
* Here's some info on how to use fonts once they are installed: |
| 174 |
`LaTeX and fonts <http://www-h.eng.cam.ac.uk/help/tpl/textprocessing/fonts.html>`_ |
| 175 |
|
| 176 |
I did the following: |
| 177 |
|
| 178 |
* I created a directory structure as described in |
| 179 |
`Installation advice <http://www.ctan.org/installationadvice/>`_ (and also in |
| 180 |
`the LaTeX font-faq <http://www.ctan.org/tex-archive/info/Type1fonts/fontinstallationguide.pdf>`_). |
| 181 |
* I made a font (which I will call Cupola), initially I encoded it with the TeX |
| 182 |
Base Encoding (this was to make sure I had all the characters I needed) |
| 183 |
* Then just before generating it I reencoded it into Adobe Standard Encoding |
| 184 |
(because TeX's fontinst routine expects that) |
| 185 |
* I generated the font naming it "fcur8a.pfb" which means: |
| 186 |
|
| 187 |
* f -- made by a small font vendor, public domain, etc. |
| 188 |
* cu -- abbreviation for the family name "Cupola" |
| 189 |
* r -- roman face |
| 190 |
* 8a -- Adobe Standard Encoding |
| 191 |
* I applied the following script: |
| 192 |
|
| 193 |
.. code-block:: bash |
| 194 |
|
| 195 |
#!/bin/bash |
| 196 |
# You will need to change the next two lines to suit your font. |
| 197 |
# You may need to change the two after that as well. |
| 198 |
BASE=fcu |
| 199 |
PACKAGE=cupola |
| 200 |
VENDOR=public |
| 201 |
LOCALTEXMF=/usr/local/share/texmf |
| 202 |
|
| 203 |
# remove any old files that might be lying around and might confuse us later on |
| 204 |
csh -c "rm fi.tex *.mtx *.pl *.vpl" |
| 205 |
|
| 206 |
# create a little script to get TeX to create various useful files it needs |
| 207 |
echo "\\input fontinst.sty" >fi.tex |
| 208 |
echo "\\latinfamily{$BASE}{}" >>fi.tex |
| 209 |
echo "\\bye" >>fi.tex |
| 210 |
|
| 211 |
#execute that script |
| 212 |
tex fi |
| 213 |
|
| 214 |
# But we need to do a bit more processing on some of those files |
| 215 |
for file in *.pl ; do |
| 216 |
pltotf $file |
| 217 |
done |
| 218 |
for file in *.vpl ; do |
| 219 |
vptovf $file |
| 220 |
done |
| 221 |
|
| 222 |
# Get rid of stuff we don't need any more |
| 223 |
rm fi.tex *.mtx *.pl *.vpl |
| 224 |
|
| 225 |
# create the directories we need for the various components |
| 226 |
mkdir -p $LOCALTEXMF/fonts/type1/$VENDOR/$PACKAGE \ |
| 227 |
$LOCALTEXMF/fonts/afm/$VENDOR/$PACKAGE \ |
| 228 |
$LOCALTEXMF/fonts/tfm/$VENDOR/$PACKAGE \ |
| 229 |
$LOCALTEXMF/fonts/vf/$VENDOR/$PACKAGE \ |
| 230 |
$LOCALTEXMF/tex/latex/$VENDOR/$PACKAGE |
| 231 |
|
| 232 |
# move everything into its expected directory |
| 233 |
cp $BASE*.pfb $LOCALTEXMF/fonts/type1/$VENDOR/$PACKAGE |
| 234 |
cp $BASE*.afm $LOCALTEXMF/fonts/afm/$VENDOR/$PACKAGE |
| 235 |
mv $BASE*.tfm $LOCALTEXMF/fonts/tfm/$VENDOR/$PACKAGE |
| 236 |
mv $BASE*.vf $LOCALTEXMF/fonts/vf/$VENDOR/$PACKAGE |
| 237 |
mv *$BASE*.fd $LOCALTEXMF/tex/latex/$VENDOR/$PACKAGE |
| 238 |
|
| 239 |
# finally create the LaTeX package for this font (and put it in the right place) |
| 240 |
echo "\\ProvidesPackage{$PACKAGE}" > $LOCALTEXMF/tex/latex/$VENDOR/$PACKAGE/$PACKAGE.sty |
| 241 |
echo "\\renewcommand{\\rmdefault}{$BASE}" >> $LOCALTEXMF/tex/latex/$VENDOR/$PACKAGE/$PACKAGE.sty |
| 242 |
echo "\\endinput" >> $LOCALTEXMF/tex/latex/$VENDOR/$PACKAGE/$PACKAGE.sty |
| 243 |
|
| 244 |
# but updating the map files required a bit more knowledge than this script has |
| 245 |
# so I left that to be done by hand |
| 246 |
echo "*********************************************************************" |
| 247 |
echo You need to create your own map files |
| 248 |
echo One should be called $LOCALTEXMF/dvips/config/$BASE.map and should |
| 249 |
echo " contain a line for each file in the family. One might look like this:" |
| 250 |
echo "${BASE}r8a $PACKAGE-Regular \"TexBase1Encoding ReEncodeFont\" <8r.enc <${BASE}r8a.pfb" |
| 251 |
echo Then change the config.ps file by looking for the location defining the |
| 252 |
echo " standard map file and adding:" |
| 253 |
echo "p +$BASE.map" |
| 254 |
echo " after it." |
| 255 |
echo Then go to $LOCALTEXMF/pdftex/config/ |
| 256 |
echo Make a copy "(or a link)" of $LOCALTEXMF/dvips/config/$BASE.map |
| 257 |
echo and edit pdftex.cfg and insert |
| 258 |
echo "p +$BASE.map" |
| 259 |
echo at the appropriate place in it too. |