home *** CD-ROM | disk | FTP | other *** search
/ The Net Power 1997 April / NETDisc0497.iso / pc / demos / mmedia / xres / data.z / CIDINIT.PS < prev    next >
Encoding:
Text File  |  1996-03-29  |  4.7 KB  |  204 lines

  1. %!
  2. %%VMusage: 0 0
  3. %%VMlocation: global
  4. %%
  5. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  6. %%                                    %%
  7. %% CIDInit: the procedures used when defining CMap and CIDfont        %%
  8. %% resources.  The implementation is more or less defined by the    %%
  9. %% requirement of the composefont procedure in systemdict.        %%
  10. %%                                    %%
  11. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  12.  
  13. /CIDInit <<
  14.  
  15. /begincmap {
  16.   /CodeSpace [] def
  17.   /CIDRange [] def
  18.   /CIDIndex 0 def
  19.   /NotDefRange [] def
  20.   /NotDefIndex 0 def
  21.   /BFRange [] def
  22.   /BFIndex 0 def
  23.   /FontIndex 0 def
  24.   /FontMatrices 1 dict def
  25. } bind
  26.  
  27. /endcmap {
  28.   currentdict definecmap
  29.   currentdict /CodeSpace undef
  30.   currentdict /CIDRange undef
  31.   currentdict /NotDefRange undef
  32.   currentdict /BFRange undef
  33. } bind
  34.  
  35. /beginrearrangedfont {
  36.   32 dict begin 
  37.   /FDepVector exch def
  38.   /FontName exch def
  39.   /FontMatrices 1 dict def
  40.   begincmap
  41. } bind
  42.  
  43. /endrearrangedfont {
  44.   0 1 FDepVector length 1 sub {
  45.     /ind exch def
  46.     FDepVector ind get
  47.     dup type /nametype eq {
  48.       dup /CIDFont resourcestatus {
  49.         pop pop /CIDFont findresource
  50.       } {
  51.         findfont
  52.       } ifelse
  53.     } if
  54.     FontMatrices ind known {
  55.       FontMatrices ind get makefont
  56.     } if
  57.     FDepVector ind 3 -1 roll put
  58.   } for
  59.   currentdict definerearrangedcmap
  60.   currentdict /CodeSpace undef
  61.   currentdict /CIDRange undef
  62.   currentdict /NotDefRange undef
  63.   currentdict /BFRange undef
  64.   currentdict /FontMatrices undef
  65.   FontName currentdict FDepVector
  66.   end
  67.   composefont
  68. } bind
  69.  
  70. /usefont {
  71.   /FontIndex exch def
  72. } bind
  73.  
  74. /beginusematrix {
  75. } bind
  76.  
  77. /endusematrix {
  78.   FontMatrices 3 1 roll put
  79. } bind
  80.  
  81. /usecmap {
  82.   /UseCMap exch /CMap findresource def
  83. } bind
  84.  
  85. /begincodespacerange {
  86.   2 mul CodeSpace length add array
  87.   dup 0 CodeSpace putinterval
  88.   /CodeSpace exch def
  89.   mark
  90. } bind
  91.  
  92. /endcodespacerange {
  93.   ] dup length neg CodeSpace length add exch
  94.   CodeSpace 3 1 roll putinterval
  95. } bind
  96.  
  97. /begincidrange {
  98.   4 mul CIDIndex add array
  99.   dup 0 CIDRange putinterval
  100.   /CIDRange exch def
  101. } bind
  102.  
  103. /endcidrange {
  104.   CIDRange length 4 sub -4 CIDIndex {
  105.     CIDRange 1 index 3 add 4 -1 roll put
  106.     CIDRange 1 index 2 add FontIndex put
  107.     CIDRange 1 index 1 add 4 -1 roll put
  108.     CIDRange exch 3 -1 roll put
  109.   } for
  110.   /CIDIndex CIDRange length def
  111. } bind
  112.  
  113. /begincidchar {
  114.   4 mul CIDIndex add array
  115.   dup 0 CIDRange putinterval
  116.   /CIDRange exch def
  117. } bind
  118.  
  119. /endcidchar {
  120.   CIDRange length 4 sub -4 CIDIndex {
  121.     CIDRange 1 index 3 add 4 -1 roll put
  122.     CIDRange 1 index 2 add FontIndex put
  123.     CIDRange 1 index 1 add 3 index put
  124.     CIDRange exch 3 -1 roll put
  125.   } for
  126.   /CIDIndex CIDRange length def
  127. } bind
  128.  
  129. /beginbfrange {
  130.   4 mul BFIndex add array
  131.   dup 0 BFRange putinterval
  132.   /BFRange exch def
  133. } bind
  134.  
  135. /endbfrange {
  136.   BFRange length 4 sub -4 BFIndex {
  137.     BFRange 1 index 3 add 4 -1 roll put
  138.     BFRange 1 index 2 add FontIndex put
  139.     BFRange 1 index 1 add 4 -1 roll put
  140.     BFRange exch 3 -1 roll put
  141.   } for
  142.   /BFIndex BFRange length def
  143. } bind
  144.  
  145. /beginbfchar {
  146.   4 mul BFIndex add array
  147.   dup 0 BFRange putinterval
  148.   /BFRange exch def
  149. } bind
  150.  
  151. /endbfchar {
  152.   BFRange length 4 sub -4 BFIndex {
  153.     BFRange 1 index 3 add 4 -1 roll put
  154.     BFRange 1 index 2 add FontIndex put
  155.     BFRange 1 index 1 add 3 index put
  156.     BFRange exch 3 -1 roll put
  157.   } for
  158.   /BFIndex BFRange length def
  159. } bind
  160.  
  161. /beginnotdefrange {
  162.   4 mul NotDefIndex add array
  163.   dup 0 NotDefRange putinterval
  164.   /NotDefRange exch def
  165. } bind
  166.  
  167. /endnotdefrange {
  168.   NotDefRange length 4 sub -4 NotDefIndex {
  169.     NotDefRange 1 index 3 add 4 -1 roll put
  170.     NotDefRange 1 index 2 add FontIndex put
  171.     NotDefRange 1 index 1 add 4 -1 roll put
  172.     NotDefRange exch 3 -1 roll put
  173.   } for
  174.   /NotDefIndex NotDefRange length def
  175. } bind
  176.  
  177.  
  178. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  179. %%                                    %%
  180. %% StartData just builds an appropriate CIDFont dictionary and        %%
  181. %% passes it to definefont.  We take the lazy way out for        %%
  182. %% hex-encoded CID fonts and reads them into a GlyphData string,    %%
  183. %% exploiting the fact that TPro supports strings of arbitrary        %%
  184. %% length.                                %%
  185. %%                                    %%
  186. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  187.  
  188. /StartData {
  189.   /GlyphData exch def
  190.   dup (hex) eq exch (Hex) eq or {
  191.     /GlyphData GlyphData string def
  192.     currentfile GlyphData readhexstring pop pop
  193.   } {
  194.     /CIDFile currentfile def
  195.   } ifelse
  196.   CIDFontName currentdict definefont
  197.   CIDFontName end exch /CIDFont defineresource pop
  198.   end
  199.   currentfile closefile
  200. } bind
  201.  
  202. >> /ProcSet defineresource
  203.  
  204.