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

📄 gs_fonts.ps

📁 GhostScript的源代码
💻 PS
📖 第 1 页 / 共 2 页
字号:
  [(Minion) /Times]
  [(Myriad) /Helvetica]
  [(MyriadPkg) /Helvetica-Narrow]
	% 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 type dup /stringtype eq exch /nametype eq or
    { dup length string cvs } { () } ifelse
    {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 exec
	% 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.  We must pop the arguments at the very end,
% so that stack protection will be effective.

/definefont {		% <name> <font> definefont <font>
  dup /FontMatrix known {
    //definefont
  } {
    2 copy /FontName get findfont //definefont exch pop exch pop
  } ifelse
} bind odef

/scalefont {		% <font> <scale> scalefont <font>
  1 index /FontMatrix known {
    //scalefont
  } {
    1 index /FontName get findfont 1 index //scalefont
    exch pop exch pop
  } ifelse
} bind odef

/makefont {		% <font> <matrix> makefont <font>
  1 index /FontMatrix known {
    //makefont
  } {
    1 index /FontName get findfont 1 index //makefont
    exch pop exch pop
  } ifelse
} bind odef

/setfont {		% <font> setfont -
  dup /FontMatrix known {
    //setfont
  } {
    dup /FontName get findfont //setfont pop
  } ifelse
} 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,
% but it still needs to restore the stacks reliably if it fails,
% so we do all the work in an operator.
/.findfont {
  mark 1 index
  //systemdict begin .dofindfont
	% Define any needed aliases.
  counttomark 1 sub { .aliasfont } repeat end
  exch pop exch pop
} odef
/findfont {
  .findfont
} 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.  Make sure we're not already
			% looking for the default 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
			% Substitute for the font.  Don't alias.
      /SUBSTFONT where {
	pop QUIET not {
	  (Substituting for font ) print dup =only
	  (.\n) print flush
	} if
	cleartomark mark defaultfontname
      } {
	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
			% Remove all the accumulated aliases.
	counttomark 1 add 1 roll cleartomark mark exch
      } ifelse
    }
   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.  Look for a file with the
			% same name as the requested font.
	 dup dup type /nametype eq { .namestring } if .loadfontloop
       }
       {		% Try each element of the Fontmap in turn.
	 false exch	% (in case we exhaust the list)
			% Stack: fontname false fontmaplist
	 { 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
			% Stack: font true -or- fontname false
	 { true
	 }
	 {			% None of the Fontmap entries worked.
				% Try loading a file with the same name
				% as the requested font.
	   dup dup type /nametype eq { .namestring } if .loadfontloop
	 }
	ifelse
       }
      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'.

    {
			% Is the font name a string?
	dup type /stringtype ne
	 { QUIET not
	    { (Can't find font with non-string name: ) print dup =only (.\n) print flush
	    }
	   if pop false exit
	 }
	if
			% 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 .systemvar exec
		% Remove the fake definition, if any.
	   .FontDirectory 3 index .undef
	   1 index (r) file .loadfont .FontDirectory exch
	   /.setglobal .systemvar 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 and FontType defined.
% (We define FontType only for the sake of some questionable code in the
% Apple Printer Utility 2.0 font inquiry code.)
%
% Note that this procedure only creates fake fonts in the FontDirectory
% associated with the current VM.  This is because in multi-context systems,
% creating the fake fonts in local VM leads to undesirable complications.
/.definefakefonts
    {
    }
    {
      (gs_fonts FAKEFONTS) VMDEBUG
      Fontmap {
	pop dup type /stringtype eq { cvn } if
	.FontDirectory 1 index known not {
	  2 dict dup /FontName 3 index put
	  dup /FontType 1 put
	  .FontDirectory 3 1 roll put
	} {
	  pop
	} ifelse
      } forall
    }
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	% current VM is global
 } def			% don't bind, .current/setglobal get redefined

% ---------------- Synthetic font support ---------------- %

% Create a new font by modifying an existing one.  paramdict contains
% entries with the same keys as the ones found in a Type 1 font;
% it should also contain enough empty entries to allow adding the
% corresponding non-overridden entries from the original font dictionary,
% including FID.  If paramdict includes a FontInfo entry, this will
% also override the original font's FontInfo, entry by entry;
% again, it must contain enough empty entries.

% Note that this procedure does not perform a definefont.

/.makemodifiedfont	% <fontdict> <paramdict> .makemodifiedfont <fontdict'>
 { exch
    {			% Stack: destdict key value
      1 index /FID ne
       { 2 index 2 index known
	  {		% Skip fontdict entry supplied in paramdict, but
			% handle FontInfo specially.
	    1 index /FontInfo eq
	     { 2 index 2 index get		% new FontInfo
	       1 index				% old FontInfo
		{	% Stack: destdict key value destinfo key value
		  2 index 2 index known
		   { pop pop }
		   { 2 index 3 1 roll put }
		  ifelse
		}
	       forall pop
	     }
	    if
	  }
	  {		% No override, copy the fontdict entry.
	    2 index 3 1 roll put
	    dup dup	% to match pop pop below
	  }
	 ifelse
       }
      if
      pop pop
    } forall
 } bind def

% Make a modified font and define it.  Note that unlike definefont,
% this does not leave the font on the operand stack.

/.definemodifiedfont	% <fontdict> <paramdict> .definemodifiedfont -
 { .makemodifiedfont
   dup /FontName get exch definefont pop
 } bind def

⌨️ 快捷键说明

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