581
574
from Apple and Microsoft. Ghostscript does not support Type 14 (Chameleon)
582
575
fonts, which use a proprietary Adobe format.
584
<h3><a name="Precompiling"></a>Precompiling fonts</h3>
587
You can precompile -- convert -- any Type 1 font into C, then compile and
588
build it into the Ghostscript executable. (Type 1 fonts include any font
589
whose name ends with <tt><b>.pfa</b></tt> or
590
<tt><b>.pfb</b></tt>, and it also includes all the
591
Ghostscript <tt><b>.gsf</b></tt> fonts except the Hershey
592
fonts.) This has no effect on rendering speed, but it eliminates the time
593
to load the font dynamically, which may make a big improvement in total
594
rendering time, especially for multi-page documents. It also reduces the
595
number of auxiliary files required at run time. Fonts precompiled and
596
built into Ghostscript this way need not appear in Fontmap, although if
597
they do appear there, no harm is done.
599
<p><a name="font2c"></a> The utility for precompiling fonts is named
600
<tt><b>font2c</b></tt>. Note that since
601
<tt><b>font2c</b></tt> uses the PostScript language program
602
<tt><b>font2c.ps</b></tt>, Ghostscript must already be
603
available to run it, and Fontmap must contain entries for the fonts you
604
want to compile. For example, to precompile the Times-Italic font,
607
font2c Times-Italic ptmri.c
608
</b></tt></blockquote>
611
The first argument ("<b><tt>Times-Italic</tt></b>" above) is the font's
612
name and the second ("<b><tt>ptmri.c</tt></b>") is the name of the
613
resulting C file. You can use any file name you want, as long as it ends
614
in "<tt><b>.c</b></tt>". It needn't be limited to eight characters unless
615
your operating system requires this. If "<b><tt>XYZ.gsf</tt></b>" or
616
"<b><tt>XYZ.pfa</tt></b>" is the font file's name in Fontmap,
617
"<b><tt>XYZ.c</tt></b>" is a good choice for the C file.
620
Under VMS, or other systems whose the C compilers limit the length of
621
identifiers, you must do something slightly more complicated; for that see
622
the section on <a href="#Short_identifiers">short identifiers in C</a>. On
623
VMS also, you must quote the font name ("{font name}") to preserve the
624
name's mixed upper and lower case. For VMS environments in general see
625
<a href="Make.htm#VMS">the VMS directions</a> in the documentation on
626
building Ghostscript, and ignore the rest of this section.
629
Note that fonts are not supplied with Ghostscript in precompiled form, since
630
those files are quite large and can easily be recreated using <a
631
href="#font2c"><tt><b>font2c</b></tt></a>. There is a makefile target to
632
run <tt><b>font2c</b></tt> on all the fonts supplied with Ghostscript.
636
make fonts_standard_c
637
</tt></b></blockquote>
639
<p>Besides running <tt><b>font2c</b></tt>, you must compile the fonts and
640
link them into the executable. To do this, add the compiled fonts feature
641
to your platform-specific makefile. See the
642
<a href="Make.htm#Makefile_overview">overview of makefiles</a> in the
643
documentation on building Ghostscript for the list of makefiles for each
644
platform. Find the definition of the <tt><b>FEATURE_DEVS</b></tt> macro in
645
the makefile, which looks something like this:
648
FEATURE_DEVS=$(PSD)psl3.dev $(PSD)pdf.dev $(PSD)dpsnext.dev $(PSD)pipe.dev
649
</b></tt></blockquote>
652
and add "ccfonts.dev":
655
FEATURE_DEVS=$(PSD)psl3.dev $(PSD)pdf.dev $(PSD)dpsnext.dev $(PSD)pipe.dev $(PSD)ccfonts.dev
656
</b></tt></blockquote>
659
Next you must add the specific fonts to <tt><b>int.mak</b></tt>, the
660
platform-independent makefile for the interpreter. This makefile already
661
has rules for the standard fonts supplied with Ghostscript, so if you just
662
want to compile the standard fonts, you needn't do anything else. Now we
663
describe how to compile other fonts into the executable, such as the Utopia
664
or Kana fonts, or your own fonts.
667
Suppose you want to compile the Kana fonts into the executable. First pick
668
one of <b><tt>ccfonts10</tt></b> through <b><tt>ccfonts15</tt></b> as the
669
place you will do this, say <b><tt>ccfonts10</tt></b>. Add your compiled
670
font file names, for instance
673
ccfonts10_=$(CFOBJ)fhirw.$(OBJ)
674
</b></tt></blockquote>
677
(Note the underscore "_".) If this makes the line too long, use another
678
line of the same form, for instance,
681
ccfonts11_=$(CFOBJ)fkarw.$(OBJ)
682
</b></tt></blockquote>
685
Just below the <b><tt>ccfonts10_=</tt></b> line is a line
689
</b></tt></blockquote>
692
(Note no underscore.) Add your own fonts to the end of this line, replacing
693
dashes ("-") with underscores ("_") in the font names. For instance:
696
ccfonts10=Calligraphic_Hiragana
697
</b></tt></blockquote>
700
Again, if a line becomes too long, add another line of the same form, for
704
ccfonts10=Calligraphic_Hiragana<br>
705
ccfonts11=Calligraphic_Katakana
706
</b></tt></blockquote>
709
After all the lines of this form, add a pair of lines to compile each font,
710
separating these entries from the "ccfonts*" lines and from each other with
711
a blank line. In our example this becomes
714
<pre>$(CFOBJ)fhirw.$(OBJ): $(CFGEN)fhirw.c $(CCFONT)
715
$(CFCC) $(CFO_)fhirw.$(OBJ) $(C_) $(CFGEN)fhirw.c
717
$(CFOBJ)fkarw.$(OBJ): $(CFGEN)fkarw.c $(CCFONT)
718
$(CFCC) $(CFO_)fkarw.$(OBJ) $(C_) $(CFGEN)fkarw.c
722
Finally, run <tt><b>make</b></tt> to build an executable that includes the
723
fonts you added. They are present in <b><tt>FontDirectory</tt></b> when
724
Ghostscript starts up.
726
<h3><a name="Short_identifiers"></a>Precompiling fonts on platforms with identifier length limits</h3>
729
On some platforms the C compiler or linker limits the number of significant
730
characters usable in an identifier. On such platforms, you must do a
734
Let <em><b>N</b></em> be the maximum number of significant characters in an
735
identifier (typically 31). For each font whose name is longer than
736
<em><b>N</b></em>-5 characters, pick an arbitrary identifier that we will
737
call the "short name". This can be any string you want, as long as it
738
contains only letters, digits, and underscores; is no longer than
739
<em><b>N</b></em>-5 characters; and is different from all other font names
740
and short names. A good choice for this is the name of the C file. There
741
is no harm in doing this for fonts with names shorter than
742
<em><b>N</b></em>-5 characters, but it's unnecessary.
745
You must do two different things for fonts that require a short name.
748
<li>You must supply the short name as a third argument to
749
<tt><b>font2c</b></tt>. For example, to compile
750
<b><tt>NewCenturySchlbk-BoldItalic</tt></b> using the short name
751
<b><tt>pncbi</tt></b>,
754
font2c NewCenturySchlbk-BoldItalic pncbi.c pncbi
755
</b></tt></blockquote>
758
Then when you add the font name to the definition of one of the ccfonts*
759
macros in the makefile, use the short name, not the actual font name, for
762
<blockquote><table cellpadding=0 cellspacing=0>
764
<td>
765
<td><tt><b>ccfonts12=pncbi</b></tt>
768
<td><tt><b>ccfonts12=NewCenturySchlbk_BoldItalic</b></tt>
769
</table></blockquote>
773
Everything else is as described above. This procedure doesn't change the
774
name of the font in Fontmap or as seen from within Ghostscript; it just
775
works around a limitation of some older compilers.
779
577
<h3><a name="Unique_IDs"></a>Font names and unique IDs</h3>
782
580
If you create your own fonts and will use them only within your own
783
581
organization, you should use <tt><b>UniqueID</b></tt> values between
784
4000000 and 4999999, coded like this (see the <a href="#Codes">tables of
785
codes</a> for font file names below):
787
<blockquote><table cellpadding=0 cellspacing=0>
788
<tr><th colspan=5 bgcolor="#CCCC00"><hr><font size="+1">Coding of UniqueID "<tt><b>4TTWVE0</b></tt>"</font><hr>
789
<tr> <td><tt><b>TT</b></tt>
791
<td><a href="#Typeface">Typeface</a>
793
<td>two-digit identifier
794
<tr> <td><tt><b>W</b></tt>
796
<td><a href="#Weight">Weight</a>
798
<td>normal, bold, etc.
799
<tr> <td><tt><b>V</b></tt>
801
<td><a href="#Variant">Variant</a>
803
<td>normal, italic, etc.
804
<tr> <td><tt><b>E</b></tt>
806
<td><a href="#Expansion">Expansion</a>
808
<td>normal, condensed, etc.
809
</table></blockquote>
812
This scheme will not work forever: as soon there are more than 99
813
typefaces, or more than 9 weights or variants, we will have to do something
814
else. But it suffices for the near future.
817
585
If you plan to distribute fonts, ask Adobe to assign you some UniqueIDs and
838
606
font-related files distributed with Ghostscript, is 107; do not use this for
839
607
your own fonts that you distribute.)
842
Because Ghostscript runs on many different systems, including DOS, the
843
names of font files can be no longer than 8 characters. We therefore
844
construct a font's filename <tt><b>FTTWVVVE.gsf</b></tt>
845
similarly to the construction for temporary UniqueIDs.
847
<blockquote><table cellpadding=0 cellspacing=0>
848
<tr><th colspan=5 bgcolor="#CCCC00"><hr><font size="+1">Coding of font file name "<tt><b>FTTWVVVE.gsf</b></tt>"</font><hr>
849
<tr> <td><tt><b>F</b></tt>
851
<td><a href="#Foundries">Foundry</a>
854
<tr> <td><tt><b>TT</b></tt>
856
<td><a href="#Typeface">Typeface</a>
858
<td>two-digit identifier
859
<tr> <td><tt><b>W</b></tt>
861
<td><a href="#Weight">Weight</a>
863
<td>normal, bold, etc.
864
<tr> <td><tt><b>V</b></tt>
866
<td><a href="#Variant">Variant</a>
868
<td>normal, italic, etc.
869
<tr> <td><tt><b>E</b></tt>
871
<td><a href="#Expansion">Expansion</a>
873
<td>normal, condensed, etc.
874
</table></blockquote>
877
Since a font can have multiple variants (for example, Lucida Regular Sans
878
Typewriter Italic) we allocate three letters to that; if a font has four
879
variants, you're on your own. If a font does have multiple variants, it's
880
best to add the expansion letter "<b><tt>r</tt></b>" to make clear which
881
letters are variants and which the expansion. This scheme is very close to
882
the one proposed in "Filenames for fonts", published in the first 1990
883
issue of <em>TUGboat</em> (the journal of the TeX Users Group).
885
<h3><a name="Codes"></a>Codes used to make font file names</h3>
888
In the following tables we make no attempt to be exhaustive: instead we
889
have simply allocated entries for those things that we needed for the fonts
890
that we are actually distributing.
893
<a name="Foundries"></a>
894
<blockquote><table cellpadding=0 cellspacing=0>
895
<tr><th colspan=3 bgcolor="#CCCC00"><hr><font size="+1">Font foundry codes</font><hr>
898
<th align=left>Foundry
899
<tr> <td colspan=3><hr>
900
<tr> <td><tt><b>b</b></tt>
903
<tr> <td><tt><b>f</b></tt>
905
<td>Freely distributable and public-domain
906
<tr> <td><tt><b>hr</b></tt>
909
<tr> <td><tt><b>n</b></tt>
912
<tr> <td><tt><b>p</b></tt>
914
<td>Adobe ("p" for PostScript)
915
<tr> <td><tt><b>u</b></tt>
918
</table></blockquote>
921
<a name="Typeface"></a>
922
<blockquote><table cellpadding=0 cellspacing=0>
923
<tr><th colspan=7 bgcolor="#CCCC00"><hr><font size="+1">Typeface codes</font><hr>
924
<tr valign=bottom> <th>ID
928
<th align=left>Filename<br>prefix
930
<th align=left>Source
931
<tr> <td colspan=7><hr>
932
<tr> <td><tt><b>08</b></tt>
936
<td><tt><b>pag</b></tt>
939
<tr> <td><tt><b>11</b></tt>
943
<td><tt><b>pbk</b></tt>
946
<tr> <td><tt><b>01</b></tt>
950
<td><tt><b>bch</b></tt>
953
<tr> <td><tt><b>02</b></tt>
957
<td><tt><b>ncr</b></tt>
960
<tr> <td><tt><b>03</b></tt>
964
<td><tt><b>phv</b></tt>
967
<tr> <td><tt><b>04</b></tt>
969
<td>New Century Schoolbook
971
<td><tt><b>pnc</b></tt>
974
<tr> <td><tt><b>09</b></tt>
978
<td><tt><b>ppl</b></tt>
981
<tr> <td><tt><b>05</b></tt>
985
<td><tt><b>psy</b></tt>
988
<tr> <td><tt><b>06</b></tt>
992
<td><tt><b>ptm</b></tt>
999
<td><tt><b>put</b></tt>
1002
<tr> <td><tt><b>07</b></tt>
1006
<td><tt><b>zc</b></tt>
1009
<tr> <td><tt><b>10</b></tt>
1013
<td><tt><b>pzd</b></tt>
1016
<tr> <td><tt><b>12</b></tt>
1018
<td>public domain Cyrillic
1020
<td><tt><b>fcy</b></tt>
1023
<tr> <td><tt><b>13</b></tt>
1025
<td>Kevin Hartig Hiragana
1027
<td><tt><b>fhi</b></tt>
1030
<tr> <td><tt><b>14</b></tt>
1032
<td>Kevin Hartig Katakana
1034
<td><tt><b>fka</b></tt>
1037
<tr> <td><tt><b>90</b></tt>
1039
<td>Hershey Gothic English
1041
<td><tt><b>hrge</b></tt>
1044
<tr> <td><tt><b>91</b></tt>
1046
<td>Hershey Gothic Italian
1048
<td><tt><b>hrit</b></tt>
1051
<tr> <td><tt><b>92</b></tt>
1053
<td>Hershey Gothic German
1055
<td><tt><b>hrgr</b></tt>
1058
<tr> <td><tt><b>93</b></tt>
1062
<td><tt><b>hrgk</b></tt>
1065
<tr> <td><tt><b>94</b></tt>
1069
<td><tt><b>hrpl</b></tt>
1072
<tr> <td><tt><b>95</b></tt>
1076
<td><tt><b>hrsc</b></tt>
1079
<tr> <td><tt><b>96</b></tt>
1083
<td><tt><b>hrsy</b></tt>
1086
</table></blockquote>
1089
<a name="Weight"></a>
1090
<blockquote><table cellpadding=0 cellspacing=0>
1091
<tr><th colspan=5 bgcolor="#CCCC00"><hr><font size="+1">Font weight codes</font><hr>
1096
<th align=left>Filename
1097
<tr> <td colspan=5><hr>
1098
<tr> <td><tt><b>0</b></tt>
1102
<td><tt><b>r</b></tt>
1103
<tr> <td><tt><b>1</b></tt>
1107
<td><tt><b>b</b></tt>
1108
<tr> <td><tt><b>2</b></tt>
1112
<td><tt><b>k</b></tt>
1113
<tr> <td><tt><b>3</b></tt>
1117
<td><tt><b>d</b></tt>
1118
<tr> <td><tt><b>4</b></tt>
1122
<td><tt><b>l</b></tt>
1124
<tr><th colspan=5 bgcolor="#CCCC00"><hr><font size="+1"><a name="Variant"></a>Font variants</font><hr>
1129
<th align=left>Filename
1130
<tr> <td colspan=5><hr>
1131
<tr> <td><tt><b>0</b></tt>
1135
<td><tt><b>r</b></tt> (omitted when weight is normal)
1136
<tr> <td><tt><b>1</b></tt>
1140
<td><tt><b>i</b></tt>
1141
<tr> <td><tt><b>2</b></tt>
1145
<td><tt><b>o</b></tt>
1146
<tr valign=top> <td><tt><b>3</b></tt>
1148
<td>script, handwritten, swash
1150
<td><tt><b>w</b></tt>
1152
<tr><th colspan=5 bgcolor="#CCCC00"><hr><font size="+1"><a name="Expansion"></a>Expansion</font><hr>
1157
<th align=left>Filename
1158
<tr> <td colspan=5><hr>
1159
<tr> <td><tt><b>0</b></tt>
1163
<td><tt><b>r</b></tt> (omitted when weight and variant are normal)
1164
<tr> <td><tt><b>1</b></tt>
1168
<td><tt><b>n</b></tt>
1169
</table></blockquote>
1173
611
<h2><a name="Use_gs_fonts_with_X"></a>Using Ghostscript fonts on X Windows displays</h2>