diff options
author | Karl Berry <karl@freefriends.org> | 2005-12-28 00:07:27 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2005-12-28 00:07:27 +0000 |
commit | 30dd9f517c9c093ff3319061647a4555264f7914 (patch) | |
tree | 0d7a349bf99be5a42cc9c5a80a30f3b7136c4ccd /Master/xemtex/gslib/gs_type1.ps | |
parent | 08ab8dce83f53b0f915cb66a37bbc8478b22c307 (diff) |
trunk
git-svn-id: svn://tug.org/texlive/trunk@9 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/xemtex/gslib/gs_type1.ps')
-rw-r--r-- | Master/xemtex/gslib/gs_type1.ps | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/Master/xemtex/gslib/gs_type1.ps b/Master/xemtex/gslib/gs_type1.ps new file mode 100644 index 00000000000..ab355e111f0 --- /dev/null +++ b/Master/xemtex/gslib/gs_type1.ps @@ -0,0 +1,183 @@ +% Copyright (C) 1994, 2000 Aladdin Enterprises. All rights reserved. +% +% This program is free software; you can redistribute it and/or modify it +% under the terms of the GNU General Public License as published by the +% Free Software Foundation; either version 2 of the License, or (at your +% option) any later version. +% +% This program is distributed in the hope that it will be useful, but +% WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +% Public License for more details. +% +% You should have received a copy of the GNU General Public License along +% with this program; if not, write to the Free Software Foundation, Inc., +% 59 Temple Place, Suite 330, Boston, MA, 02111-1307. + +% $Id: gs_type1.ps,v 1.5.2.1.2.1 2003/04/12 14:02:38 giles Exp $ +% Type 1 font support code. + +% The standard representation for PostScript compatible fonts is described +% in the book "Adobe Type 1 Font Format", published by Adobe Systems Inc. + +% Define an augmented version of .buildfont1 that inserts UnderlinePosition +% and UnderlineThickness entries in FontInfo if they aren't there already, +% and FontBBox isn't degenerate. +% (This works around the incorrect assumption, made by many word processors, +% that these entries are present in the built-in fonts.) +/.buildfont1 + { + false 1 index /FontBBox .knownget { + { 0 ne { not exit } if } forall + } if + { dup /FontInfo known not + { .growfontdict dup /FontInfo 2 dict put } + if + dup dup /FontInfo get dup dup + /UnderlinePosition known exch /UnderlineThickness known and + { pop pop % entries already present + } + { dup length 2 add dict .copydict + dup /UnderlinePosition known not + { dup /UnderlinePosition 3 index /FontBBox .knownget + { 1 get 2 div } % 1/2 the font descent + { -100 } ifelse put + } + if + dup /UnderlineThickness known not + { dup /UnderlineThickness 3 index /FontBBox .knownget + { dup 3 get exch 1 get sub 20 div } % 1/20 the font height + { 50 } ifelse put + } + if + 1 index /FontInfo get wcheck not { readonly } if + /FontInfo exch put + } + ifelse + } if + //.buildfont1 + } bind def +% If the diskfont feature isn't included, define a dummy .loadfontdict. +/.loadfontdict where + { pop } + { /.loadfontdict 0 dict readonly def } +ifelse +/.loadfontfile % <file> .loadfontfile - + { mark exch + DISKFONTS { .loadfontdict begin } if + % In order to load fonts reliably, we should push systemdict + % here. However, Ed Taft says that Adobe implementations + % push userdict and nothing else! + % We really would just like systemdict on the stack, + % but fonts produced by Fontographer require a writable dictionary. + % However, we can't use any of the other well-known dictionaries + % (such as userdict), since the whole point of pushing systemdict + % is to make sure that nothing important has been redefined. + userdict begin + % We can't just use `run', because we want to check for .PFB files. + currentpacking + { false setpacking .loadfont1 true setpacking } + { .loadfont1 } + ifelse end + { stop } if + DISKFONTS { end } if + cleartomark + } bind def +/.loadfont1 { % <file> .loadfont1 <errorflag> + { % We would like to use `false /PFBDecode filter', + % but this occasionally produces a whitespace character as + % the first of an eexec section, so we can't do it. + % Also, since the real input file never reaches EOF if we are using + % a PFBDecode filter (the filter stops just after reading the last + % character), we must explicitly close the real file in this case. + % Since the file might leave garbage on the operand stack, + % we have to create a procedure to close the file reliably. + dup read not { -1 } if + 2 copy unread 16#80 eq { + dup true /PFBDecode filter cvx + exch .currentresourcefile eq { + dup /.execasresource .systemvar + } { + {exec} + } ifelse + 2 index cvlit + /closefile .systemvar 3 .execn + } { + cvx exec + } ifelse + } stopped +} bind def + +% Here are the BuildChar and BuildGlyph implementation for Type 1 fonts. +% The names %Type1BuildChar and %Type1BuildGlyph are known to the interpreter. +% The real work is done in an operator: +% <font> <code|name> <name> <charstring> .type1execchar - + +(%Type1BuildChar) cvn { % <font> <code> %Type1BuildChar - + 1 index /Encoding get 1 index get .type1build .type1execchar +} bind def +(%Type1BuildGlyph) cvn { % <font> <name> %Type1BuildGlyph - + dup .type1build .type1execchar +} bind def +% Note: this procedure is used for both Type 1 and Type 2 fonts. +/.type1build { % <font> <code|name> <name> .type1build + % <font> <code|name> <name> <charstring> + 2 index begin + dup CharStrings exch .knownget not { + 2 copy eq { exch pop /.notdef exch } if + QUIET not + { (Substituting .notdef for ) print = flush } + { pop } + ifelse + /.notdef CharStrings /.notdef get + } if + end +} bind def +% CCRun is an undocumented procedure provided for Type 4 and Type 0 fonts. +1183615869 internaldict begin +% Apparently there are two different argument lists for CCRun. +% Handling the one with the extra Private dictionary requires fabricating +% a Type 1 font on the fly, since we aren't currently prepared to parse the +% dictionary any other way. +/CCRun { % <font> <code|name> <charstring> CCRun - + % <font> <code|name> <charstring> <Private> CCRun - + dup type /dicttype eq { + dup 4 index /Private .knownget { ne } { pop true } ifelse { + % The Private dictionary was supplied, and is different + % from the Private dictionary of the font. Fabricate a + % Type 1 font with this Private dictionary. Most of the + % font entries are arbitrary or not needed. + .currentglobal false .setglobal 10 dict exch .setglobal begin + /Private exch def + /FontType 1 def + /FontMatrix 3 index /FontMatrix get def + /Encoding 3 index /Encoding .knownget not { StandardEncoding } if def + /FontBBox 3 index /FontBBox .knownget not { {0 0 0 0} } if def + /PaintType 0 def + /CharStrings 1 dict dup /.notdef () put def + 3 -1 roll pop () currentdict end .buildfont1 exch pop 3 1 roll + } { + pop + } ifelse + } if + 1 index dup type /integertype eq { + 3 index /Encoding get exch get + } if exch .type1execchar +} bind def +end + +% Register the font types for definefont. +buildfontdict 1 /.buildfont1 cvx put +buildfontdict 4 /.buildfont4 cvx put + +% Add Type 2 support if applicable. +/.buildfont2 where not { (%END2) .skipeof } if +pop +(%Type2BuildChar) cvn { % <font> <code> %Type2BuildChar - + 1 index /Encoding get 1 index get .type1build .type2execchar +} bind def +(%Type2BuildGlyph) cvn { % <font> <name> %Type2BuildGlyph - + dup .type1build .type2execchar +} bind def +buildfontdict 2 /.buildfont2 cvx put +%END2 |