| 1 |
|
| 2 |
ttf2tfm -- TrueType to TFM converter |
| 3 |
ttf2pk -- TrueType to PK converter |
| 4 |
==================================== |
| 5 |
|
| 6 |
These two auxiliary programs make TrueType fonts usable with TeX. |
| 7 |
ttf2tfm extracts the metric and kerning information of a TrueType font |
| 8 |
and converts it into metric files usable by TeX (quite similar to |
| 9 |
afm2tfm which is part of the dvips package). ttf2pk rasterizes the |
| 10 |
glyph outlines of a TrueType font into a bitmap font in PK format. |
| 11 |
|
| 12 |
Since a TrueType font often contains more than 256 glyphs, some means |
| 13 |
are necessary to map a subset of the TrueType glyphs into a TeX font. |
| 14 |
To do this, two mapping tables are needed: the first maps from the |
| 15 |
TrueType font to a raw TeX font (this mapping table is used both by |
| 16 |
ttf2tfm and ttf2pk), and the second maps from the raw TeX font to |
| 17 |
another (virtual) TeX font providing all kerning and ligature |
| 18 |
information needed by TeX. |
| 19 |
|
| 20 |
We sometimes refer to this first map as the `input' or `raw' map, and |
| 21 |
to the second as the `output' or `virtual' map. |
| 22 |
|
| 23 |
This two stage mapping has the advantage that one raw font can be |
| 24 |
accessed with various TeX encodings (e.g. T1 and OT1) via the virtual |
| 25 |
font mechanism, and just one PK file is necessary. |
| 26 |
|
| 27 |
For CJKV fonts, a different mechanism is provided (see section |
| 28 |
`Subfont definition files' below). Additionally, rotated glyphs for |
| 29 |
pseudo-vertical writing are supported -- if possible, vertical glyph |
| 30 |
presentation forms are used from the font's GSUB table. |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
ttf2tfm |
| 35 |
======= |
| 36 |
|
| 37 |
Usage: |
| 38 |
|
| 39 |
ttf2tfm FILE[.ttf|.ttc] [OPTION]... [FILE[.tfm]] |
| 40 |
|
| 41 |
Options (default values are given in brackets): |
| 42 |
|
| 43 |
-c REAL use REAL for height of small caps made with -V [0.8] |
| 44 |
-e REAL widen (extend) characters by a factor of REAL [1.0] |
| 45 |
-E INT select INT as the TTF encoding ID [1] |
| 46 |
-f INT select INT as the font index in a TTC [0] |
| 47 |
-l create 1st/2nd byte ligatures in subfonts |
| 48 |
-L LIGFILE[.sfd] create 1st/2nd byte ligatures in subfonts using LIGFILE |
| 49 |
-n use PS names of TrueType font |
| 50 |
-N use only PS names and no cmap |
| 51 |
-O use octal for all character codes in the vpl file |
| 52 |
-p ENCFILE[.enc] read ENCFILE for the TTF->raw TeX mapping |
| 53 |
-P INT select INT as the TTF platform ID [3] |
| 54 |
-q suppress informational output |
| 55 |
-r OLDNAME NEWNAME replace glyph name OLDNAME with NEWNAME |
| 56 |
-R RPLFILE[.rpl] read RPLFILE containing glyph replacement names |
| 57 |
-s REAL oblique (slant) characters by REAL, usually <<1 [0.0] |
| 58 |
-t ENCFILE[.enc] read ENCFILE for the encoding of the vpl file |
| 59 |
-T ENCFILE[.enc] equivalent to -p ENCFILE -t ENCFILE |
| 60 |
-u output only characters from encodings, nothing extra |
| 61 |
-v FILE[.vpl] make a VPL file for conversion to VF |
| 62 |
-V SCFILE[.vpl] like -v, but synthesize smallcaps as lowercase |
| 63 |
-w generate subfont enc. vectors containing glyph indices |
| 64 |
-x rotate subfont glyphs by 90 degrees |
| 65 |
-y REAL move rotated glyphs down by a factor of REAL [0.25] |
| 66 |
--help print this message and exit |
| 67 |
--version print version number and exit |
| 68 |
|
| 69 |
|
| 70 |
The usage is very similar to afm2tfm. Please consult the dvips info |
| 71 |
file for more details on the various parameters. Here we will |
| 72 |
concentrate on the differences between afm2tfm and ttf2tfm. |
| 73 |
|
| 74 |
|
| 75 |
cmaps |
| 76 |
----- |
| 77 |
|
| 78 |
Contrary to Type 1 PostScript fonts (but similar to the new CID-keyed |
| 79 |
PostScript fonts), most TrueType fonts have more than one native |
| 80 |
mapping table, also called `cmap', which maps the (internal) TTF glyph |
| 81 |
indices to the (external) TTF character codes. Common examples are a |
| 82 |
mapping table to Unicode encoded character positions and the standard |
| 83 |
Macintosh mapping. To specify this TrueType mapping table, use the |
| 84 |
options `-P' and `-E'. With `-P' you specify the platform ID; defined |
| 85 |
values are: |
| 86 |
|
| 87 |
platform platform ID (pid) |
| 88 |
---------------------------------- |
| 89 |
Apple Unicode 0 |
| 90 |
Macintosh 1 |
| 91 |
ISO 2 |
| 92 |
Microsoft 3 |
| 93 |
|
| 94 |
The encoding ID depends on the platform. For pid=0, we ignore the |
| 95 |
`-E' parameter (setting it to zero) since the mapping table is always |
| 96 |
Unicode version 2.0. For pid=1, the following table lists the defined |
| 97 |
values: |
| 98 |
|
| 99 |
platform ID = 1 |
| 100 |
script encoding ID (eid) |
| 101 |
--------------------------------- |
| 102 |
Roman 0 |
| 103 |
Japanese 1 |
| 104 |
Chinese 2 |
| 105 |
Korean 3 |
| 106 |
Arabic 4 |
| 107 |
Hebrew 5 |
| 108 |
Greek 6 |
| 109 |
Russian 7 |
| 110 |
Roman Symbol 8 |
| 111 |
Devanagari 9 |
| 112 |
Gurmukhi 10 |
| 113 |
Gujarati 11 |
| 114 |
Oriya 12 |
| 115 |
Bengali 13 |
| 116 |
Tamil 14 |
| 117 |
Telugu 15 |
| 118 |
Kannada 16 |
| 119 |
Malayalam 17 |
| 120 |
Sinhalese 18 |
| 121 |
Burmese 19 |
| 122 |
Khmer 20 |
| 123 |
Thai 21 |
| 124 |
Laotian 22 |
| 125 |
Georgian 23 |
| 126 |
Armenian 24 |
| 127 |
Maldivian 25 |
| 128 |
Tibetan 26 |
| 129 |
Mongolian 27 |
| 130 |
Geez 28 |
| 131 |
Slavic 29 |
| 132 |
Vietnamese 30 |
| 133 |
Sindhi 31 |
| 134 |
Uninterpreted 32 |
| 135 |
|
| 136 |
Here are the ISO encoding IDs: |
| 137 |
|
| 138 |
platform ID = 2 |
| 139 |
encoding encoding ID |
| 140 |
---------------------------- |
| 141 |
ASCII 0 |
| 142 |
ISO 10646 1 |
| 143 |
ISO 8859-1 2 |
| 144 |
|
| 145 |
And finally, the Microsoft encoding IDs: |
| 146 |
|
| 147 |
platform ID = 3 |
| 148 |
encoding encoding ID |
| 149 |
--------------------------- |
| 150 |
Symbol 0 |
| 151 |
Unicode 2.0 1 |
| 152 |
Shift JIS 2 |
| 153 |
GB 2312 (1980) 3 |
| 154 |
Big 5 4 |
| 155 |
KSC 5601 (Wansung) 5 |
| 156 |
KSC 5601 (Johab) 6 |
| 157 |
UCS-4 10 |
| 158 |
|
| 159 |
The program will abort if you specify an invalid platform/encoding ID |
| 160 |
pair. It will then show the possible pid/eid pairs. Please note that |
| 161 |
most fonts have at most two or three cmaps, usually corresponding to |
| 162 |
the pid/eid pairs (1,0), (3,0), or (3,1) in case of Latin based fonts. |
| 163 |
Valid Microsoft fonts should have a (3,1) mapping table, but some |
| 164 |
fonts exist (mostly Asian fonts) which have a (3,1) cmap not encoded |
| 165 |
in Unicode. The reason for this strange behavior is the fact that |
| 166 |
some old MS Windows versions will reject fonts having a non-Unicode |
| 167 |
cmap (since all non-Unicode Microsoft encoding IDs are for Asian |
| 168 |
specific MS Windows versions). |
| 169 |
|
| 170 |
The `-P' and `-E' options to ttf2tfm must be equally specified for |
| 171 |
ttf2pk; the corresponding parameters in a map file are `Pid' and |
| 172 |
`Eid', respectively. |
| 173 |
|
| 174 |
The default pid/eid pair is (3,1). |
| 175 |
|
| 176 |
If you use the `-N' switch, all cmaps are ignored, using only the |
| 177 |
PostScript names in the TrueType font. The corresponding option in a |
| 178 |
map file is `PS=Only'. |
| 179 |
|
| 180 |
If you use the `-n' switch, the default glyph names built into ttf2tfm |
| 181 |
are replaced with the PS glyph names found in the font. In many cases |
| 182 |
this is not what you want because the glyph names in the font are |
| 183 |
often incorrect or non-standard. The corresponding option in a map |
| 184 |
file is `PS=Yes'. |
| 185 |
|
| 186 |
|
| 187 |
input and output encodings |
| 188 |
-------------------------- |
| 189 |
|
| 190 |
You must specify the encoding vectors from the TrueType font to the |
| 191 |
raw TeX font and from the raw TeX font to the virtual TeX font exactly |
| 192 |
as with afm2tfm, but you have more possibilities to address the |
| 193 |
character codes. [With `encoding vector' a mapping table with 256 |
| 194 |
entries in form of a PostScript vector is meant; see the file |
| 195 |
`T1-WGL4.enc' of this package for an example.] With afm2tfm, you must |
| 196 |
access each glyph with its Adobe glyph name, e.g. `/quotedsingle' or |
| 197 |
`/Acircumflex'. This has been extended with ttf2tfm; now you can (and |
| 198 |
sometimes must) access the code points and/or glyphs directly using |
| 199 |
the following syntax for specifying the character position in decimal, |
| 200 |
octal, or hexadecimal notation: `/.c<decimal-number>', |
| 201 |
`/.c0<octal-number>', or `/.c0x<hexadecimal-number>'. Examples: |
| 202 |
`/.c72', `/.c0646', `/.c0x48'. To access a glyph index directly, use |
| 203 |
the character `g' instead of `c' in the just introduced notation. |
| 204 |
Example: `/.g0x32'. |
| 205 |
|
| 206 |
[Note: The `.cXXX' notation makes no sense if `-N' is used.] |
| 207 |
|
| 208 |
Another possibility is to use the `-r old-glyphname new-glyphname' |
| 209 |
switch to rename a glyph. Example: |
| 210 |
|
| 211 |
ttf2tfm ... -r .g0xc7 dotlessi -r hungarumlaut dblacute ... |
| 212 |
|
| 213 |
Nevertheless, it is not allowed to use the `.gXXX' or `.cXXX' glyph |
| 214 |
name construct for `new-glyphname'. |
| 215 |
|
| 216 |
Alternatively, you can collect such replacement pairs in a file which |
| 217 |
should have `.rpl' as extension, using the `-R' option. The syntax is |
| 218 |
simple: Each line contains a pair `old-glyphname new-glyphname' |
| 219 |
separated by whitespace (without the quotation marks). The percent |
| 220 |
sign starts a line comment; you can continue a line with a backslash |
| 221 |
as the last character. An example for a replacement file is `VPS.rpl' |
| 222 |
(to be used in conjunction with `t5.enc' for Vietnamese) which is |
| 223 |
part of this package. |
| 224 |
|
| 225 |
The `-r' and `-R' switches are ignored for subfonts or if no encoding |
| 226 |
tables are specified. For ttf2pk, the corresponding option to `-R' is |
| 227 |
`Replacement'. Single replacements are directly given as |
| 228 |
old_glyphname=newglyphname in a map file. |
| 229 |
|
| 230 |
For pid/eid pairs (1,0) and (3,1), both ttf2tfm and ttf2pk recognize |
| 231 |
built-in default Adobe glyph names; the former pair follows the names |
| 232 |
given in Appendix E of the book `Inside Macintosh', volume 6, the |
| 233 |
latter uses the names given in the TrueType Specification (WGL4, a |
| 234 |
Unicode subset). Note that Adobe glyph names are not unique and do |
| 235 |
sometimes differ: E.g., many PS fonts have the glyph `mu', whereas |
| 236 |
this glyph is called `mu1' in the WGL4 character set to distinguish it |
| 237 |
from the real Greek letter mu. You can find those mapping tables in |
| 238 |
the source code file `ttfenc.c'. Be also aware that OpenType |
| 239 |
(i.e. TrueType 2.0) fonts use an updated WGL4 table; we use the data |
| 240 |
from the latest published TrueType specification (1.66). |
| 241 |
|
| 242 |
On the other hand, the switches `-n' and `-N' make ttf2tfm read in and |
| 243 |
use the PostScript names in the TrueType font itself (stored in the |
| 244 |
font's `post' table) instead of the default Adobe glyph names. |
| 245 |
|
| 246 |
If you don't select an input encoding, the first 256 glyphs of the |
| 247 |
TrueType font with a valid entry in the selected cmap will be mapped |
| 248 |
to the TeX raw font (without the `-q' option ttf2tfm prints this |
| 249 |
mapping table to standard output), followed by all glyphs not yet |
| 250 |
addressed in the selected cmap. However, some code points for the |
| 251 |
(1,0) pid/eid pair are omitted since they do not represent glyphs |
| 252 |
useful for TeX: 0x00 (null), 0x08 (backspace), 0x09 (horizontal |
| 253 |
tabulation), 0x0d (carriage return), and 0x1d (group separator). The |
| 254 |
`invalid character' with glyph index 0 will be omitted too. |
| 255 |
|
| 256 |
If you select the `-N' switch, the first 256 glyphs of the TrueType |
| 257 |
font with a valid PostScript name will be used in case no input |
| 258 |
encoding is specified. Again, some glyphs are omitted: `.notdef', |
| 259 |
`.null', and `nonmarkingreturn'. |
| 260 |
|
| 261 |
If you don't select an output encoding, ttf2tfm uses the same mapping |
| 262 |
table as afm2tfm would use (you can find it in the source code file |
| 263 |
texenc.c); it corresponds to TeX typewriter text. Unused positions |
| 264 |
(either caused by empty code points in the mapping table or missing |
| 265 |
glyphs in the TrueType font) will be filled (rather arbitrarily) with |
| 266 |
characters present in the input encoding but not specified in the |
| 267 |
output encoding (without the `-q' option ttf2tfm prints the final |
| 268 |
output encoding to standard output). Use the `-u' option if you want |
| 269 |
only glyphs in the virtual font which are defined in the output |
| 270 |
encoding file, and nothing more. |
| 271 |
|
| 272 |
One feature missing in afm2tfm has been added which is needed by the |
| 273 |
LaTeX T1 encoding: ttf2tfm will construct the glyph `Germandbls' (by |
| 274 |
simply concatenating to `S' glyphs) even for normal fonts if possible. |
| 275 |
It appears in the glyph list (written to stdout) as the last item, |
| 276 |
marked with an asterisk. Since this isn't a real glyph it will be |
| 277 |
available only in the virtual font. |
| 278 |
|
| 279 |
For both input and output encoding, an empty code position is |
| 280 |
represented by the glyph name `.notdef'. |
| 281 |
|
| 282 |
In encoding files, you can use `\' as the final character of a line to |
| 283 |
indicate that the input is continued on the next line. The backslash |
| 284 |
and the following newline character will be removed. |
| 285 |
|
| 286 |
ttf2tfm returns 0 on success and 1 on error; warning and error |
| 287 |
messages are written to standard error. |
| 288 |
|
| 289 |
|
| 290 |
other options |
| 291 |
------------- |
| 292 |
|
| 293 |
You can select the font in a TrueType font collection (which usually |
| 294 |
has the extension `.ttc') with `-f'; the default value, zero, |
| 295 |
specifies the first font. For fonts not being a collection this |
| 296 |
parameter is ignored. |
| 297 |
|
| 298 |
The option `-l' makes ttf2tfm create ligatures in subfonts between |
| 299 |
first and second bytes of all the original character codes. Example: |
| 300 |
Character code 0xABCD maps to character position 123 in subfont 45. |
| 301 |
Then a ligature in subfont 45 between position 0xAB and 0xCD pointing |
| 302 |
to character 123 will be produced. The fonts of the Korean HLaTeX |
| 303 |
package use this feature. Note that this option generates correct |
| 304 |
ligatures only for TrueType fonts where the input cmap is identical to |
| 305 |
the output encoding. In case of HLaTeX, TTFs must have platform ID 3 |
| 306 |
and encoding ID 5. |
| 307 |
|
| 308 |
Option `-L' is the same as `-l', but character codes for ligatures are |
| 309 |
specified in a ligature file. For example, `-L KS-HLaTeX' generates |
| 310 |
correct ligatures for the Korean HLaTeX package regardless of the |
| 311 |
platform and encoding ID of the used TrueType font (the file |
| 312 |
`KS-HLaTeX.sfd' is part of the ttf2pk package). Ligature files have |
| 313 |
the same format and extension as SFD files. Both `-L'and `-l' are |
| 314 |
ignored if not in subfont mode. |
| 315 |
|
| 316 |
PostScript encoding vectors containing glyph indices of subfonts, |
| 317 |
primarily used to embed TrueType fonts in pdfLaTeX, can be created |
| 318 |
with option `-w'. ttf2tfm takes the TFM names and replaces the suffix |
| 319 |
with `.enc'; that is, for files `foo01.tfm', `foo02.tfm', ... it |
| 320 |
creates `foo01.enc', `foo02.enc', ... at the same place. |
| 321 |
|
| 322 |
To produce glyphs rotated by 90 degrees counter-clockwise, use `-x'. |
| 323 |
If the font contains a GSUB table (with feature `vert') to specify |
| 324 |
vertical glyph presentation forms, both ttf2pk and ttf2tfm will use |
| 325 |
it. This will work only in subfont mode. The y-offset of rotated |
| 326 |
glyphs can be specified with the `-y' option; its parameter gives the |
| 327 |
fractional amount of shifting downwards (the unit is one EM). If not |
| 328 |
specified, a value of 0.25 (em) is used. |
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
ttf2pk |
| 333 |
====== |
| 334 |
|
| 335 |
Usage: |
| 336 |
|
| 337 |
ttf2pk [-q] [-n] FONT DPI |
| 338 |
ttf2pk -t [-q] FONT |
| 339 |
|
| 340 |
Options: |
| 341 |
|
| 342 |
-q suppresses informational output |
| 343 |
-n only use `.pk' as extension |
| 344 |
-t test for FONT (returns 0 on success) |
| 345 |
--help print this message and exit |
| 346 |
--version print version number and exit |
| 347 |
|
| 348 |
|
| 349 |
The FONT parameter must correspond to an entry in a map file recorded |
| 350 |
in the configuration file ttf2pk.cfg (see below for details), |
| 351 |
otherwise error code 2 is returned -- this can be used for scripts |
| 352 |
like mktexpk to test whether the given font name is a (registered) |
| 353 |
TrueType font. |
| 354 |
|
| 355 |
Another possibility is to use the `-t' switch which will print the |
| 356 |
line of a map file corresponding to FONT and return 0 on success (`-q' |
| 357 |
suppresses any output). |
| 358 |
|
| 359 |
DPI specifies the intended resolution (we always assume a design size |
| 360 |
of 10pt). |
| 361 |
|
| 362 |
|
| 363 |
ttf2pk.cfg |
| 364 |
---------- |
| 365 |
|
| 366 |
ttf2pk uses a small configuration file called ttf2pk.cfg; in each line |
| 367 |
it contains a keyword with its value, separated by whitespace. |
| 368 |
Comment lines can start with any of the following characters: `*', |
| 369 |
`#', `;', and `%'. Leading whitespace is ignored. |
| 370 |
|
| 371 |
Currently, only one keyword, `map', is recognized in this file; it |
| 372 |
takes a map file name as a parameter. If no extension is given to the |
| 373 |
map file name, `.map' is appended. No whitespace is allowed in the |
| 374 |
map file name. The `map' keyword can be given more than once to |
| 375 |
specify multiple map files; if the map file name is prepended by a |
| 376 |
plus sign, it is added to the list of map files to be used. Example: |
| 377 |
|
| 378 |
map foo |
| 379 |
map +bar |
| 380 |
|
| 381 |
This makes ttf2pk to first read `foo.map', then `bar.map'. |
| 382 |
|
| 383 |
If the configuration file is not found, ttf2pk tries to use |
| 384 |
`ttfonts.map' instead. |
| 385 |
|
| 386 |
|
| 387 |
map files |
| 388 |
--------- |
| 389 |
|
| 390 |
Parameters specified to ttf2tfm are preserved for ttf2pk in map files |
| 391 |
-- ttf2tfm writes out to standard output, as the last line, a proper |
| 392 |
entry for a map file. |
| 393 |
|
| 394 |
As an example, a call to |
| 395 |
|
| 396 |
ttf2tfm arial -s 0.25 -P 1 -E 0 -r .g0xc7 caron \ |
| 397 |
-p 8r.enc -t T1-WGL4.enc -v arialsx arials |
| 398 |
|
| 399 |
will produce the following line: |
| 400 |
|
| 401 |
arials arial Slant=0.25 Encoding=8r.enc Pid=1 Eid=0 .g0xc7=caron |
| 402 |
|
| 403 |
The output encoding given with `-t' for the virtual font `arialsx' is |
| 404 |
immaterial to ttf2pk (nevertheless, input encoding files must have the |
| 405 |
same format as with ttf2tfm, and all said above about encoding files |
| 406 |
holds). |
| 407 |
|
| 408 |
Here a table listing the various ttf2tfm parameters and its |
| 409 |
corresponding entries in a map file: |
| 410 |
|
| 411 |
-s Slant |
| 412 |
-e Extend |
| 413 |
-p Encoding |
| 414 |
-f Fontindex |
| 415 |
-P Pid |
| 416 |
-E Eid |
| 417 |
-n PS=Yes |
| 418 |
-N PS=Only |
| 419 |
-R Replacement |
| 420 |
-x Rotate=Yes |
| 421 |
-y Y-Offset |
| 422 |
|
| 423 |
Single replacement glyph names given to ttf2tfm with the `-r' switch |
| 424 |
are directly specified with old-glyphname=new-glyphname. For subfonts |
| 425 |
or if no encoding file is given, replacement glyphs are ignored. |
| 426 |
|
| 427 |
One additional parameter in a map file is unique to ttf2pk: `Hinting', |
| 428 |
which can take the values `On' or `Off'. Some fonts (e.g. the CJKV |
| 429 |
part of cyberbit.ttf) are rendered incorrectly if hinting is |
| 430 |
activated. Default is `On' (you can also use `Yes', `No', `1', and |
| 431 |
`0'). |
| 432 |
|
| 433 |
The format of map files is simple. Each line defines a font; first |
| 434 |
comes the TeX font name, then its TrueType font file name, followed by |
| 435 |
the parameters in any order. Case is significant (even for parameter |
| 436 |
names); the parameters are separated from its values by an equal sign, |
| 437 |
with possible whitespace surrounding it. ttf2pk reads in a map file |
| 438 |
line by line, continuing until the TeX font specified on the command |
| 439 |
line is found, otherwise the programs exits with error code 2. Thus |
| 440 |
you can use any character invalid in a TeX font name to start a |
| 441 |
comment line. |
| 442 |
|
| 443 |
In both map files and encoding files, use `\' as the final character |
| 444 |
of a line to indicate that the input is continued on the next line. |
| 445 |
The backslash and the following newline character will be removed. |
| 446 |
|
| 447 |
ttf2pk will abort if it can't find and read the TeX font metrics file |
| 448 |
of the given TeX font name. |
| 449 |
|
| 450 |
|
| 451 |
Subfont definition files |
| 452 |
======================== |
| 453 |
|
| 454 |
CJKV (Chinese/Japanese/Korean/old Vietnamese) fonts usually contain |
| 455 |
several thousand glyphs; to use them with TeX it is necessary to split |
| 456 |
such large fonts into subfonts. Subfont definition files (usually |
| 457 |
having the extension `.sfd') are a simple means to do this smoothly. |
| 458 |
A subfont file name usually consists of a prefix, a subfont infix, and |
| 459 |
a postfix (which is empty in most cases), e.g. |
| 460 |
|
| 461 |
ntukai23 -> prefix: ntukai, infix: 23, postfix: (empty) |
| 462 |
|
| 463 |
Here the syntax of a line in an SFD file, describing one subfont: |
| 464 |
|
| 465 |
<whitespace> <infix> <whitespace> <ranges> <whitespace> `\n' |
| 466 |
|
| 467 |
<infix> := anything except whitespace. It's best to use only |
| 468 |
alphanumerical characters. |
| 469 |
<whitespace> := space, formfeed, carriage return, horizontal and |
| 470 |
vertical tabs -- no newline characters. |
| 471 |
<ranges> := <ranges> <whitespace> <codepoint> | |
| 472 |
<ranges> <whitespace> <range> | |
| 473 |
<ranges> <whitespace> <offset> <whitespace> <range> |
| 474 |
|
| 475 |
<codepoint> := <number> |
| 476 |
<range> := <number> `_' <number> |
| 477 |
<offset> := <number> `:' |
| 478 |
|
| 479 |
<number> := hexadecimal (prefix `0x'), decimal, or octal |
| 480 |
(prefix `0') |
| 481 |
|
| 482 |
A line can be continued on the next line with a backslash ending the |
| 483 |
line. The ranges must not overlap; offsets have to be in the range |
| 484 |
0-255. |
| 485 |
|
| 486 |
Example: |
| 487 |
|
| 488 |
The line |
| 489 |
|
| 490 |
03 10: 0x2349 0x2345_0x2347 |
| 491 |
|
| 492 |
assigns to the code positions 10, 11, 12, and 13 of the subfont |
| 493 |
having the infix `03' the character codes 0x2349, 0x2345, 0x2346, |
| 494 |
and 0x2347, respectively. |
| 495 |
|
| 496 |
The SFD files in the distribution are customized for the CJK package |
| 497 |
for LaTeX. |
| 498 |
|
| 499 |
You have to embed the SFD file into the TFM font name (at the place |
| 500 |
where the infix will appear) surrounded by two `@' signs, on the |
| 501 |
command line resp. a map file; both ttf2tfm and ttf2pk switch then |
| 502 |
to subfont mode. |
| 503 |
|
| 504 |
It is possible to use more than a single SFD file by separating them |
| 505 |
with commata and no whitespace; for a given subfont, the first file is |
| 506 |
scanned for an entry, then the next file, and so on. Later entries |
| 507 |
override entries found earlier (possibly only partially). For example, |
| 508 |
the first SFD file sets up range 0x10-0xA0, and the next one modifies |
| 509 |
entries 0x12 and 0x25. As can be easily seen, this algorithm allows |
| 510 |
for adding and replacing, but not for removing entries. |
| 511 |
|
| 512 |
Subfont mode disables the options `-n', `-N', `-p', `-r', `-R', `-t', |
| 513 |
`-T', `-u', `-v', `-w', and `-V' for ttf2tfm; similarly, no `Encoding' |
| 514 |
and `Replacement' parameter resp. single replacement glyph names are |
| 515 |
allowed in a map file. |
| 516 |
|
| 517 |
ttf2tfm will create ALL subfont TFM files specified in the SFD files |
| 518 |
(provided the subfont contains glyphs) in one run. |
| 519 |
|
| 520 |
Example: |
| 521 |
|
| 522 |
The call |
| 523 |
|
| 524 |
ttf2tfm ntukai.ttf ntukai@Big5,Big5-supp@ |
| 525 |
|
| 526 |
will use `Big5.sfd' and `Big5-supp.sfd', producing the subfont files |
| 527 |
ntukai01.tfm, ntukai02.tfm etc. |
| 528 |
|
| 529 |
ttf2pk should be then called on the subfonts directly: |
| 530 |
|
| 531 |
ttf2pk ntukai01 600 |
| 532 |
ttf2pk ntukai02 600 |
| 533 |
... |
| 534 |
|
| 535 |
|
| 536 |
Some notes on file searching |
| 537 |
============================ |
| 538 |
|
| 539 |
Both ttf2pk and ttf2tfm use either the kpathsea, emtexdir, or MiKTeX |
| 540 |
library for searching files (emtexdir will work only on operating |
| 541 |
systems which have an MS-DOSish background, i.e. MS-DOS, OS/2, |
| 542 |
Windows; MiKTeX is specific to MS Windows). |
| 543 |
|
| 544 |
During compilation, you have to define HAVE_KPATHSEA, HAVE_EMTEXDIR, |
| 545 |
or MIKTEX to activate the specific file search code. |
| 546 |
|
| 547 |
As a last resort, both programs can be compiled without a search |
| 548 |
library; the searched files must be then in the current directory or |
| 549 |
specified with a path. Default extensions will be appended also (with |
| 550 |
the exception that only `.ttf' is appended and not `.ttc'). |
| 551 |
|
| 552 |
|
| 553 |
kpathsea |
| 554 |
-------- |
| 555 |
|
| 556 |
Please note that older versions of kpathsea (<3.2) have no special |
| 557 |
means to search for TrueType fonts and related files, thus we use the |
| 558 |
paths for PostScript related stuff. The actual version of kpathsea is |
| 559 |
displayed on screen if you call either ttf2pk or ttf2tfm with the |
| 560 |
`--version' command line switch. |
| 561 |
|
| 562 |
Here is a table of the file type and the corresponding kpathsea |
| 563 |
variables. TTF2PKINPUTS and TTF2TFMINPUTS are program specific |
| 564 |
environment variables introduced in kpathsea version 3.2: |
| 565 |
|
| 566 |
.ttf and .ttc TTFONTS |
| 567 |
ttf2pk.cfg TTF2PKINPUTS |
| 568 |
.map TTF2PKINPUTS |
| 569 |
.enc TTF2PKINPUTS, TTF2TFMINPUTS |
| 570 |
.rpl TTF2PKINPUTS, TTF2TFMINPUTS |
| 571 |
.tfm TFMFONTS |
| 572 |
.sfd TTF2PKINPUTS, TTF2TFMINPUTS |
| 573 |
|
| 574 |
And here the same for pre-3.2-versions of kpathsea: |
| 575 |
|
| 576 |
.ttf and .ttc T1FONTS |
| 577 |
ttf2pk.cfg TEXCONFIG |
| 578 |
.map TEXCONFIG |
| 579 |
.enc TEXPSHEADERS |
| 580 |
.rpl TEXPSHEADERS |
| 581 |
.tfm TFMFONTS |
| 582 |
.sfd TEXPSHEADERS |
| 583 |
|
| 584 |
Finally, the same for pre-3.0-versions: |
| 585 |
|
| 586 |
.ttf and .ttc DVIPSHEADERS |
| 587 |
ttf2pk.cfg TEXCONFIG |
| 588 |
.map TEXCONFIG |
| 589 |
.enc DVIPSHEADERS |
| 590 |
.rpl DVIPSHEADERS |
| 591 |
.tfm TFMFONTS |
| 592 |
.sfd DVIPSHEADERS |
| 593 |
|
| 594 |
Please consult the info files for kpathsea for details on these |
| 595 |
variables. The decision whether to use the old or the new scheme will |
| 596 |
be done during compilation. |
| 597 |
|
| 598 |
You should set the TEXMFCNF variable to the directory where your |
| 599 |
texmf.cnf configuration file resides. |
| 600 |
|
| 601 |
The default TDS location for the files in the data subdirectory is |
| 602 |
|
| 603 |
$TEXMF/ttf2tfm |
| 604 |
|
| 605 |
(or $TEXMF/ttf2pk; you should either make a symbolic link |
| 606 |
|
| 607 |
% ln -s $TEXMF/ttf2tfm $TEXMF/ttf2pk |
| 608 |
|
| 609 |
or set the variable TTF2PKINPUTS to $TEXMF/ttf2tfm for newer kpathsea |
| 610 |
versions) |
| 611 |
|
| 612 |
Here is the proper command to find out to which value a kpathsea |
| 613 |
variable is set (we use `TTFONTS' as an example). This is especially |
| 614 |
useful if a variable isn't set in texmf.cnf or in the environment, |
| 615 |
thus pointing to the default value which is hard-coded into the |
| 616 |
kpathsea library. |
| 617 |
|
| 618 |
% kpsewhich --progname=ttf2tfm --expand-var='$TTFONTS' |
| 619 |
|
| 620 |
We select the program name also since it is possible to specify |
| 621 |
variables which are searched only for a certain program -- in our |
| 622 |
example it would be `TTFONTS.ttf2tfm'. |
| 623 |
|
| 624 |
A similar but not identical method is to say |
| 625 |
|
| 626 |
% kpsewhich --progname=ttf2tfm --show-path='truetype fonts' |
| 627 |
|
| 628 |
[A full list of format types can be obtained by saying `kpsewhich |
| 629 |
--help' on the command line prompt.] This is exactly how ttf2tfm (and |
| 630 |
ttf2pk) searches for files; the disadvantage is that all variables are |
| 631 |
expanded which can cause a very long string. |
| 632 |
|
| 633 |
|
| 634 |
emtexdir |
| 635 |
-------- |
| 636 |
|
| 637 |
Here the list of suffixes and its related environment variables to be |
| 638 |
set in autoexec.bat (resp. in config.sys for OS/2): |
| 639 |
|
| 640 |
.ttf and .ttc TTFONTS |
| 641 |
ttf2pk.cfg TTFCFG |
| 642 |
.map TTFCFG |
| 643 |
.enc TTFCFG |
| 644 |
.rpl TTFCFG |
| 645 |
.tfm TEXTFM |
| 646 |
.sfd TTFCFG |
| 647 |
|
| 648 |
With other words, all files in the `data' subdirectory should be moved |
| 649 |
to a place in your emtex tree with TTFCFG pointing to this directory. |
| 650 |
|
| 651 |
If one of the variables isn't set, a warning message is emitted. The |
| 652 |
current directory will always be searched. As usual, one exclamation |
| 653 |
mark appended to a directory path causes subdirectories one level deep |
| 654 |
to be searched, two exclamation marks causes all subdirectories to be |
| 655 |
searched. Example: |
| 656 |
|
| 657 |
TTFONTS=c:\fonts\truetype!!;d:\myfonts\truetype! |
| 658 |
|
| 659 |
Constructions like `c:\fonts!!\truetype' aren't possible. |
| 660 |
|
| 661 |
|
| 662 |
MiKTeX |
| 663 |
------ |
| 664 |
|
| 665 |
Both ttf2tfm and ttf2pk have been fully integrated into MiKTeX. |
| 666 |
Please refer to the documentation of MiKTeX for more details on file |
| 667 |
searching. |
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
A full example |
| 672 |
============== |
| 673 |
|
| 674 |
Here an example how to handle the font `verdana.ttf' and its variants. |
| 675 |
|
| 676 |
|
| 677 |
1. Construct the font name |
| 678 |
-------------------------- |
| 679 |
|
| 680 |
[This is the most complicated part -- in case you are too lazy to |
| 681 |
construct font names compliant to TeX's `fontname' scheme, just use |
| 682 |
your own names.] |
| 683 |
|
| 684 |
Using the `ftdump' utility (which is part of FreeType 1) you can |
| 685 |
find out the PostScript name of the specific TTF which is probably |
| 686 |
the best choice to adapt TrueType fonts to the PostScript-oriented |
| 687 |
`fontname' scheme. |
| 688 |
|
| 689 |
In our example, the PostScript name is `Verdana'. |
| 690 |
|
| 691 |
`fontname' uses the scheme |
| 692 |
|
| 693 |
S TT W [V...] [N] [E] [DD] |
| 694 |
|
| 695 |
as documented in `fontname.texi' resp. `fontname.dvi'. Now you have |
| 696 |
to check the various mapping files: |
| 697 |
|
| 698 |
S: supplier.map: `j' for `Microsoft' |
| 699 |
TT: typeface.map: `vn' for `Verdana' |
| 700 |
W: weight.map: `r' for `Regular Roman', |
| 701 |
`b' for `bold' |
| 702 |
V, |
| 703 |
N: variant.map: `8r' for the raw base font |
| 704 |
`8t' for the virtual font |
| 705 |
(i.e., LaTeX's T1 encoding) |
| 706 |
[additionally an inserted `c' for small caps, |
| 707 |
`o' for slanted (`oblique'), or `i' for italic |
| 708 |
fonts] |
| 709 |
|
| 710 |
Here the standard combinations: |
| 711 |
|
| 712 |
`jvnr8r' for the default base font. |
| 713 |
`jvnr8t' for the virtual default font. |
| 714 |
`jvnrc8t' for the virtual font with small caps. [As you can |
| 715 |
see, no additional raw font is needed.] |
| 716 |
`jvnro8r' for the slanted base font. |
| 717 |
`jvnro8t' for the virtual slanted font. |
| 718 |
|
| 719 |
The corresponding variants are: |
| 720 |
|
| 721 |
bold: verdanab.ttf -> jvnb{8r,8t} |
| 722 |
small caps: jvnbc8t |
| 723 |
slanted: jvnbo{8r,8t} |
| 724 |
italic: verdanai.ttf -> jvni{8r,8t} |
| 725 |
bold and italic: verdanaz.ttf -> jvnbi{8r,8t} |
| 726 |
|
| 727 |
|
| 728 |
* NOTE: Be careful to use different names for the virtual font and the |
| 729 |
* raw font! In the above example, `*8r' and `*8t' is used. You |
| 730 |
* could also use the postfix `*-raw', to name an example, for |
| 731 |
* the raw font if you don't follow the `fontname' naming scheme. |
| 732 |
|
| 733 |
|
| 734 |
2. Font definition files |
| 735 |
------------------------ |
| 736 |
|
| 737 |
The FD file should be called `t1jvn.fd' (as you can see, this is T1 |
| 738 |
encoding). It is very similar to `t1ptm.fd', part of the PSNFSS |
| 739 |
package (which can be found in almost all TeX distributions). A |
| 740 |
`verdana.sty' file can also be modeled after `times.sty'. |
| 741 |
|
| 742 |
|
| 743 |
3. Calling ttf2tfm |
| 744 |
------------------ |
| 745 |
|
| 746 |
To make the example simpler, we use `T1-WGL4.enc' for both the raw |
| 747 |
and the virtual encoding. This should be sufficient for most |
| 748 |
TrueType fonts mapped to T1 encoding. Other packages may define |
| 749 |
other encodings (e.g. the `t2' package available from CTAN defines |
| 750 |
mapping files for Cyrillic encodings) -- it may also be necessary to |
| 751 |
use the `-n' or `-N' switch together with replacement glyph names to |
| 752 |
access all glyph names in the TrueType font. |
| 753 |
|
| 754 |
To create `jvnr8r' and `jvnr8t', just call |
| 755 |
|
| 756 |
ttf2tfm verdana -T T1-WGL4 -v jvnr8t jvnr8r |
| 757 |
vptovf jvnr8t |
| 758 |
|
| 759 |
For `jvnrc8t', do |
| 760 |
|
| 761 |
ttf2tfm verdana -T T1-WGL4 -V jvnrc8t jvnr8r |
| 762 |
vptovf jvnrc8t |
| 763 |
|
| 764 |
Note that almost always some warnings will appear about missing |
| 765 |
glyphs. |
| 766 |
|
| 767 |
The last line written to stdout by ttf2tfm is a suitable entry for a |
| 768 |
map file -- let's call it `verdana.map'. Since ttf2pk doesn't care |
| 769 |
about virtual fonts, both calls below produce the same. |
| 770 |
|
| 771 |
Now just repeat this procedure. For slanted fonts you should |
| 772 |
additionally use the switch `-s 0.176' (of course you can change the |
| 773 |
slanting amount to make it fit your needs). |
| 774 |
|
| 775 |
|
| 776 |
4. Modifying ttf2pk.cfg |
| 777 |
----------------------- |
| 778 |
|
| 779 |
The final step is to add `verdana.map' to ttf2pk's configuration |
| 780 |
file. Simply insert the following line at the end of `ttf2pk.cfg': |
| 781 |
|
| 782 |
map +verdana |
| 783 |
|
| 784 |
|
| 785 |
Problems |
| 786 |
======== |
| 787 |
|
| 788 |
Most vptovf implementations allow only 100 bytes for the TFM header |
| 789 |
(the limit is 1024 in the TFM file itself): 8 bytes for checksum and |
| 790 |
design size, 40 bytes for the family name, 20 bytes for the encoding, |
| 791 |
and 4 bytes for a face byte. There remain only 28 bytes for some |
| 792 |
additional information which is used by ttf2tfm for an identification |
| 793 |
string (which is essentially a copy of the command line), and this |
| 794 |
limit is always exceeded. |
| 795 |
|
| 796 |
The optimal solution is to increase the value of `max_header_bytes' in |
| 797 |
the file vptovf.w (and probably pltotf.w) to, say, 400 and recompile |
| 798 |
vptovf (and pltotf). Otherwise you will get some (harmless) error |
| 799 |
messages like |
| 800 |
|
| 801 |
This HEADER index is too big for my present table size |
| 802 |
|
| 803 |
which can be safely ignored. |
| 804 |
|
| 805 |
|
| 806 |
--- end of ttf2pk.doc --- |