⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gs_fonts.ps

📁 遗传算法工具箱 希望高手指点 GATOOLS
💻 PS
📖 第 1 页 / 共 2 页
字号:
   count exch sub { pop } repeat
 } bind def

% Find an alternate font to substitute for an unknown one.
% We go to some trouble to parse the font name and extract
% properties from it.  Later entries take priority over earlier.
/.substitutefaces [
	% Guess at suitable substitutions for random unknown fonts.
  [(Grot) /Times]
  [(Roman) /Times]
  [(Book) /NewCenturySchlbk]
	% If the family name appears in the font name,
	% use a font from that family.
  [(Arial) /Helvetica]
  [(Avant) /AvantGarde]
  [(Bookman) /Bookman]
  [(Century) /NewCenturySchlbk]
  [(Cour) /Courier]
  [(Geneva) /Helvetica]
  [(Helv) /Helvetica]
  [(NewYork) /Times]
  [(Pala) /Palatino]
  [(Sans) /Helvetica]
  [(Schlbk) /NewCenturySchlbk]
  [(Serif) /Times]
  [(Swiss) /Helvetica]
  [(Times) /Times]
	% Substitute for Adobe Multiple Master fonts.
  [(Myriad) /Times]
  [(Minion) /Helvetica]
	% Condensed or narrow fonts map to the only narrow family we have.
  [(Cond) /Helvetica-Narrow]
  [(Narrow) /Helvetica-Narrow]
	% If the font wants to be monospace, use Courier.
  [(Monospace) /Courier]
  [(Typewriter) /Courier]
] readonly def
/.substituteproperties [
  [(It) 1] [(Oblique) 1]
  [(Bd) 2] [(Bold) 2] [(bold) 2] [(Demi) 2] [(Heavy) 2] [(Sb) 2]
] readonly def
/.substitutefamilies mark
  /AvantGarde
    {/AvantGarde-Book /AvantGarde-BookOblique
     /AvantGarde-Demi /AvantGarde-DemiOblique}
  /Bookman
    {/Bookman-Demi /Bookman-DemiItalic /Bookman-Light /Bookman-LightItalic}
  /Courier
    {/Courier /Courier-Oblique /Courier-Bold /Courier-BoldOblique}
  /Helvetica
    {/Helvetica /Helvetica-Oblique /Helvetica-Bold /Helvetica-BoldOblique}
  /Helvetica-Narrow
    {/Helvetica-Narrow /Helvetica-Narrow-Oblique
     /Helvetica-Narrow-Bold /Helvetica-Narrow-BoldOblique}
  /NewCenturySchlbk
    {/NewCenturySchlbk-Roman /NewCenturySchlbk-Italic
     /NewCenturySchlbk-Bold /NewCenturySchlbk-BoldItalic}
  /Palatino
    {/Palatino-Roman /Palatino-Italic /Palatino-Bold /Palatino-BoldItalic}
  /Times
    {/Times-Roman /Times-Italic /Times-Bold /Times-BoldItalic}
.dicttomark readonly def
/.substitutefont		% <fontname> .substitutefont <altname>
 {	% Look for properties and/or a face name in the font name.
	% If we find any, use Helvetica as the base font;
	% otherwise, use the default font.
	% Note that the "substituted" font name may be the same as
	% the requested one; the caller must check this.
   dup length string cvs
    {defaultfontname /Helvetica-Oblique /Helvetica-Bold /Helvetica-BoldOblique}
   exch 0 exch	% stack: fontname facelist properties fontname
	% Look for a face name.
   .substitutefaces
    { 2 copy 0 get search
       { pop pop pop 1 get .substitutefamilies exch get
	 4 -1 roll pop 3 1 roll
       }
       { pop pop
       }
      ifelse
    }
   forall
   .substituteproperties
    { 2 copy 0 get search
       { pop pop pop 1 get 3 -1 roll or exch }
       { pop pop }
      ifelse
    }
   forall pop get
	% If SUBSTFONT is defined, use it.
   /SUBSTFONT where
    { pop pop /SUBSTFONT load cvn }
    { exec }
   ifelse
	% Only accept fonts known in the Fontmap.
   Fontmap 1 index known not { pop defaultfontname } if
 } bind def

% If requested, make (and recognize) fake entries in FontDirectory for fonts
% present in Fontmap but not actually loaded.  Thanks to Ray Johnston for
% the idea behind this code.
FAKEFONTS not { (%END FAKEFONTS) .skipeof } if

% We use the presence or absence of the FontMatrix key to indicate whether
% a font is real or fake.

/definefont		% <name> <font> definefont <font>
 { dup /FontMatrix known not { /FontName get findfont } if
   //definefont
 } bind odef

/scalefont		% <font> <scale> scalefont <font>
 { exch dup /FontMatrix known not { /FontName get findfont } if
   exch //scalefont
 } bind odef

/makefont		% <font> <matrix> makefont <font>
 { exch dup /FontMatrix known not { /FontName get findfont } if
   exch //makefont
 } bind def

/setfont		% <font> setfont -
 { dup /FontMatrix known not { /FontName get findfont } if
   //setfont
 } bind odef

%END FAKEFONTS

% Define findfont so it tries to load a font if it's not found.
% The Red Book requires that findfont be a procedure, not an operator.
/findfont
 { mark exch
    { .dofindfont
    } stopped
    { counttomark 1 sub { pop } repeat exch pop stop
    }
    {	% Define any needed aliases.
      counttomark 1 sub { .aliasfont } repeat
      exch pop
    }
   ifelse
 } bind def
% Check whether the font name we are about to look for is already on the list
% of aliases we're accumulating; if so, cause an error.
/.checkalias		% -mark- <alias1> ... <name> .checkalias <<same>>
 { counttomark 1 sub -1 1
    { index 1 index eq
       { pop QUIET not
	  { (Unable to substitute for font.\n) print flush
	  } if
	 /findfont cvx /invalidfont signalerror
       }
      if
    }
   for
 } bind def
% Get a (non-fake) font if present in a FontDirectory.
/.fontknownget		% <fontdir> <fontname> .fontknownget <font> true
			% <fontdir> <fontname> .fontknownget false
 { .knownget
    { FAKEFONTS
       { dup /FontMatrix known { true } { pop false } ifelse }
       { true }
      ifelse
    }
    { false
    }
   ifelse
 } bind def
% Do the work of findfont, including substitution, defaulting, and
% scanning of FONTPATH.
/.dofindfont		% <fontname> .dofindfont <font>
 {  { .tryfindfont { exit } if
			% We didn't find the font.  If we haven't scanned
			% all the directories in FONTPATH, scan the next one now,
			% and look for the font again.
      null 0 1 FONTPATH length 1 sub
       { FONTPATH 1 index get null ne { exch pop exit } if pop
       }
      for dup null ne
       { dup 0 eq { .scanfontbegin } if
	 FONTPATH 1 index get .scanfontdir
	 FONTPATH exch null put
			% Start over with an empty alias list.
	 counttomark 1 sub { pop } repeat
	 .dofindfont exit
       }
      if pop
			% No luck, substitute for the font.
      dup defaultfontname eq
       { QUIET not
	  { (Unable to load default font ) print
	    dup =only (!  Giving up.\n) print flush
	  }
	 if /findfont cvx /invalidfont signalerror
       }
      if dup .substitutefont
      2 copy eq { pop defaultfontname } if
      .checkalias
      QUIET not
       { (Substituting font ) print dup =only ( for ) print
	 1 index =only (.\n) print flush
       }
      if
    }
   loop
 } bind def
% Try to find a font using only the present contents of Fontmap.
/.tryfindfont		% <fontname> .tryfindfont <font> true
			% <fontname> .tryfindfont false
 { FontDirectory 1 index .fontknownget
    {			% Already loaded
      exch pop true
    }
    { dup Fontmap exch .knownget not
       {		% Unknown font name
	 false
       }

       {		% Try each element of the Fontmap in turn.
	false exch	% (in case we exhaust the list)
	 { exch pop
	   dup type /nametype eq
	    {			% Font alias
	      .checkalias .tryfindfont exit
	    }
	    { dup dup type dup /arraytype eq exch /packedarraytype eq or exch xcheck and
	       {		% Font with a procedural definition
		 exec		% The procedure will load the font.
				% Check to make sure this really happened.
		 FontDirectory 1 index .knownget
		  { exch pop true exit }
		 if
	       }
	       {		% Font file name
		 .loadfontloop { true exit } if
	       }
	      ifelse
	    }
	   ifelse false
	 }
	forall
       }
      ifelse
    }
   ifelse
 } bind def
% Attempt to load a font from a file.
/.loadfontloop		% <filename> .loadfontloop <font> true
			% <filename> .loadfontloop false
 {			% See above regarding the use of 'loop'.

    {
			% Can we open the file?
	findlibfile not
	 { QUIET not
	    { (Can't find \(or can't open\) font file ) print dup print
	      (.\n) print flush
	    }
	   if pop false exit
	 }
	if

			% Stack: fontname fontfilename fontfile
	DISKFONTS
	 { .currentglobal true .setglobal
	   2 index (r) file
	   FontFileDirectory exch 5 index exch .growput
	   .setglobal
	 }
	if
	QUIET not
	 { (Loading ) print 2 index =only
	   ( font from ) print 1 index print (... ) print flush
	 }
	if
	% If LOCALFONTS isn't set, load the font into local or global
	% VM according to FontType; if LOCALFONTS is set, load the font
	% into the current VM, which is what Adobe printers (but not
	% DPS or CPSI) do.
	LOCALFONTS { false } { /setglobal where } ifelse
	 { pop /FontType .findfontvalue { 1 eq } { false } ifelse
		% .setglobal, like setglobal, aliases FontDirectory to
		% GlobalFontDirectory if appropriate.  However, we mustn't
		% allow the current version of .setglobal to be bound in,
		% because it's different depending on language level.
	   .currentglobal exch /.setglobal load exec
		% Remove the fake definition, if any.
	   FontDirectory 3 index .undef
	   1 index (r) file .loadfont FontDirectory exch
	   /.setglobal load exec
	 }
	 { .loadfont FontDirectory
	 }
	ifelse
		% Stack: fontname fontfilename fontdirectory
	QUIET not
	 { //systemdict /level2dict known
	    { .currentglobal false .setglobal vmstatus
	      true .setglobal vmstatus 3 -1 roll pop
	      6 -1 roll .setglobal 5
	    }
	    { vmstatus 3
	    }
	   ifelse { =only ( ) print } repeat
	   (done.\n) print flush
	 } if

		% Check to make sure the font was actually loaded.
	dup 3 index .fontknownget
	 { 4 1 roll pop pop pop true exit } if

		% Maybe the file had a different FontName.
		% See if we can get a FontName from the file, and if so,
		% whether a font by that name exists now.
	exch (r) file .findfontname
	 { 2 copy .fontknownget
	    {	% Yes.  Stack: origfontname fontdirectory filefontname fontdict
	      3 -1 roll pop exch
	      QUIET
	       { pop
	       }
	       { (Using ) print =only
	         ( font for ) print 1 index =only
	         (.\n) print flush
	       }
	      ifelse true exit
	    }
	   if pop
	 }
	if pop

		% The font definitely did not load correctly.
	QUIET not
	 { (Loading ) print dup =only
	   ( font failed.\n) print flush
	 } if
	false exit

    } loop		% end of loop

 } bind def

% Define a procedure to load all known fonts.
% This isn't likely to be very useful.
/loadallfonts
 { Fontmap { pop findfont pop } forall
 } bind def

% If requested, load all the fonts defined in the Fontmap into FontDirectory
% as "fake" fonts i.e., font dicts with only FontName defined.
% We must ensure that this happens in both global and local directories.
/.definefakefonts
    {
    }
    { (gs_fonts FAKEFONTS) VMDEBUG
      2
	{ .currentglobal not .setglobal
	  Fontmap
	   { pop dup type /stringtype eq { cvn } if
	     FontDirectory 1 index known not
	      { 1 dict dup /FontName 3 index put       
	        FontDirectory 3 1 roll put
	      }
	     if
	   }
	  forall
       }
      repeat
    }
FAKEFONTS { exch } if pop def		% don't bind, .current/setglobal get redefined

% Install initial fonts from Fontmap.
/.loadinitialfonts
 { NOFONTMAP not
    { /FONTMAP where
	  { pop [ FONTMAP .pathlist ]
	     { dup VMDEBUG findlibfile
		{ exch pop .loadFontmap }
		{ /undefinedfilename signalerror }
	       ifelse
	     }
	  }
	  { LIBPATH
	     { defaultfontmap 2 copy .filenamedirseparator
	       exch concatstrings concatstrings dup VMDEBUG
	       (r) { file } .internalstopped
		{ pop pop } { .loadFontmap } ifelse
	     }
	  }
	 ifelse forall
    }
   if
   .definefakefonts
 } def			% don't bind, .current/setglobal get redefined

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -