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

📄 wrfont.ps

📁 GhostScript的源代码
💻 PS
📖 第 1 页 / 共 2 页
字号:
  /FID dup
  /FontInfo dup
  /Metrics dup
  /Metrics2 dup
  /Private dup
.dicttomark def
/.minfontskipkeys mark
  .fontskipkeys { } forall
  /FontName dup
  /UniqueID dup
.dicttomark def
/.privateskipkeys mark
  /ND dup
  /NP dup
  /RD dup
  /Subrs dup
.dicttomark def
/.minprivateskipkeys mark
  .privateskipkeys { } forall
  /MinFeature dup
  /Password dup
  /UniqueID dup
.dicttomark def

% Define the procedures for the Private dictionary.
% These must be defined without `bind',
% for the sake of the DISKFONTS feature.
4 dict begin
 /-! {string currentfile exch readhexstring pop} def
 /-| {string currentfile exch readstring pop} def
 /|- {readonly def} def
 /| {readonly put} def
currentdict end /encrypted_procs exch def
4 dict begin
 /-! {string currentfile exch readhexstring pop
   4330 exch dup .type1encrypt exch pop} def
 /-| {string currentfile exch readstring pop
   4330 exch dup .type1encrypt exch pop} def
 /|- {readonly def} def
 /| {readonly put} def
currentdict end /unencrypted_procs exch def

% Construct an inverse dictionary of encodings.
/encodingnames mark
 StandardEncoding /StandardEncoding
 ISOLatin1Encoding /ISOLatin1Encoding
 SymbolEncoding /SymbolEncoding
 DingbatsEncoding /DingbatsEncoding
 /resourceforall where
  { pop (*) { cvn dup findencoding exch } 100 string /Encoding resourceforall }
 if
.dicttomark def

% Invert the standard encodings.
.knownEncodings length 256 mul dict begin
  0 .knownEncodings
   {  { currentdict 1 index known { pop } { 1 index def } ifelse
	1 add
      }
     forall
   }
  forall pop
currentdict end /inverseencodings exch def

/writefont		% <psfile> writefont - (writes the current font)
 { /psfile exch def
   /Font currentfont def
   /FontInfo Font /FontInfo .knownget not { 0 dict } if def
   /FontType Font /FontType get def
   /hasPrivate Font /Private known def
   /Private hasPrivate { Font /Private get } { 0 dict } ifelse def
   /readproc binary_CharStrings { (-| ) } { (-! ) } ifelse def
   /privateprocs
     encrypt_CharStrings binary_tokens not and
      { encrypted_procs } { unencrypted_procs } ifelse
     def
   /addlenIV false def
   /changelenIV use_lenIV 0 lt
    { 0 }
    { use_lenIV Private /lenIV .knownget not
       { 4 /addlenIV use_lenIV 4 ne def } if sub }
   ifelse def
   /minimize
     smallest_output
     FontType 1 eq and
     Font /UniqueID known and
   def
   (%!FontType) ws FontType wtstring cvs ws (-1.0: ) ws
     currentfont /FontName get wt
     FontInfo /version .knownget not { (001.001) } if wl
   FontInfo /CreationDate .knownget { (%%Creation Date: ) ws wl } if
   FontInfo /VMusage .knownget
    { (%%VMusage: ) ws dup wt wtstring cvs wl }
   if
   (systemdict begin) wl

% If we're going to use eexec, create the filters now.
   /realpsfile psfile def
   eexec_encrypt
    { /eexecfilter psfile binary_CharStrings not
       { pop /bxstring 35 string def
	  { pop dup length 0 ne
	     { realpsfile exch writehexstring realpsfile (\n) writestring }
	     { pop }
	    ifelse bxstring
	  }
	 /NullEncode filter dup /hexfilter exch def
       }
      if 55665 /eexecEncode filter def
    }
   if

% Turn on binary tokens if relevant.
   binary_tokens { (currentobjectformat 1 setobjectformat) wl } if

% If the file has a UniqueID, write out a check against loading it twice.
   minimize
    { Font /FontName get wo
      Font /UniqueID get wo
      Private length addlenIV { 1 add } if wo
      Font length 1 add wo		% +1 for FontFile
      ( .checkexistingfont) wl
    }
    { Font /UniqueID known
       { ({} FontDirectory) ws Font /FontName get dup wo ( known) wl
	 ( {) ws wo ( findfont dup /UniqueID known) wl
	 (    { dup /UniqueID get) ws Font /UniqueID get wo ( eq exch /FontType get 1 eq and }) wl
	 (    { pop false } ifelse) wl
	 (    { pop save /restore load } if) wl
	 ( } if) wl
       }
      if
    }
   ifelse

% If we are writing unencrypted CharStrings for a standard environment,
% write out the encryption procedures.
   privateprocs unencrypted_procs eq standard_only and
    { (systemdict /.type1encrypt known) wl
      ( { save /restore load } { { } } ifelse) wl
      (userdict begin) wl
      enc_dict { we } forall
      (end exec) wl
    }
   if

% Write out the creation of the font dictionary and FontInfo.
   minimize not
    { Font length 1 add wo {dict begin} wol		% +1 for FontFile
    }
   if
   (/FontInfo ) ws FontInfo wd {readonly def} wol

% Write out the other fixed entries in the font dictionary.
   Font begin
   Font
    { minimize
       { .minfontskipkeys 2 index known
	  { pop pop
	  }
	  { //.compactfontdefault 2 index .knownget
	     { 1 index valueeq { pop pop } { we } ifelse }
	     { we }
	    ifelse
	  }
	 ifelse
       }
       { .fontskipkeys 2 index known { pop pop } { we } ifelse
       }
      ifelse
    } forall
   /Encoding
   encodingnames Encoding known
   name_all_Encodings
   Encoding StandardEncoding eq or
   Encoding ISOLatin1Encoding eq or and
    { encodingnames Encoding get cvx }
    { Encoding }
   ifelse
   dup /StandardEncoding cvx eq minimize and
    { pop pop }
    { we }
   ifelse

% Write the FDepVector, if any.
   Font /FDepVector .knownget
    { {/FDepVector [} wol
       { /FontName get wo {findfont} wol () wl } forall
      {] readonly def} wol
    }
   if

% Write out the Metrics, if any.
   Font /Metrics .knownget
    { (/Metrics ) ws wld {readonly def} wol
    }
   if
   Font /Metrics2 .knownget
    { (/Metrics2 ) ws wld {readonly def} wol
    }
   if

% Start the eexec-encrypted section, if applicable.
  eexec_encrypt
   { {currentdict currentfile eexec} wol () wl
     /psfile eexecfilter store
     (\000\000\000\000) ws {begin} wol
   }
  if

% Create and initialize the Private dictionary, if any.
   hasPrivate
{
   Private
   minimize
    { begin {Private dup begin}
    }
    {  dup length privateprocs length add dict copy begin
       privateprocs { readonly def } forall
       /Private wo
       currentdict length 1 add wo {dict dup begin}
    }
   ifelse wol () wl
   currentdict
    { 1 index minimize { .minprivateskipkeys } { .privateskipkeys } ifelse
      exch known
       { pop pop }
       { 1 index /lenIV eq use_lenIV 0 ge and { pop use_lenIV } if we }
      ifelse
    } forall
   addlenIV { /lenIV use_lenIV we } if
}
if

% Write the Subrs entries, if any.
   currentdict /Subrs known
    { (/Subrs[) wl
      Subrs
       { dup null ne
	  { wcs minimize not { () wl } if }
	  { pop /null cvx wo }
	 ifelse
       } forall
      {] dup {readonly pop} forall readonly def} wol () wl
    }
   if

% Wrap up the Private dictionary.
   hasPrivate
    { end			% Private
      minimize
       { {end readonly pop} }	% Private
       { {end readonly def} }	% Private in font
      ifelse wol
    }
   if

% Write the CharStrings entries.
% Detect identical (eq) entries, which bdftops produces.
   currentdict /CharStrings known
{
   /CharStrings wo CharStrings length wo
   minimize
    { encrypt_CharStrings not wo ( .readCharStrings) wl
      CharStrings length dict
      CharStrings
       { exch inverseencodings 1 index .knownget not { dup } if wo
		% Stack: vdict value key
	 3 copy pop .knownget { wo pop pop } { 3 copy put pop wcs } ifelse
       } forall
    }
    { {dict dup Private begin begin} wol () wl
      CharStrings length dict
      CharStrings
       { 2 index 1 index known
	  { exch wo 1 index exch get wo {load def} wol () wl
	  }
	  { 2 index 1 index 3 index put
	    exch wo wcs ( |-) wl
	  }
	 ifelse
       } forall
      {end end} wol
    }
   ifelse
   pop
    { readonly def }	% CharStrings in font
   wol
}
if

% Terminate the output.
   end			% Font
   eexec_encrypt
    { {end mark currentfile closefile} wol () wl
      eexecfilter dup flushfile closefile	% psfile is eexecfilter
      binary_CharStrings not { hexfilter dup flushfile closefile } if
      /psfile realpsfile store
      8
       { (0000000000000000000000000000000000000000000000000000000000000000)
         wl
       }
      repeat {cleartomark} wol
    }
   if
    { FontName currentdict end definefont pop
    }
   wol
   Font /UniqueID known { /exec cvx wo } if
   binary_tokens { /setobjectformat cvx wo } if
   ( end) wl		% systemdict

 } bind def

% ------ Other utilities ------ %

% Prune garbage characters and OtherSubrs out of the current font,
% if the relevant dictionaries are writable.
/prunefont
 { currentfont /CharStrings get wcheck
    { currentfont /CharStrings get dup [ exch
       { pop dup (S????00?) .stringmatch not { pop } if
       } forall
      ] { 2 copy undef pop } forall pop
    }
   if
 } bind def

end			% wrfont_dict

/writefont { wrfont_dict begin writefont end } def

⌨️ 快捷键说明

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