home *** CD-ROM | disk | FTP | other *** search
/ jppd.dyndns.org / jppd.dyndns.org.tar / jppd.dyndns.org / QUERYPRO / Impressora_PDF / converter.exe / GPLGS / gs_typ32.ps < prev    next >
Text File  |  2002-06-03  |  4KB  |  128 lines

  1. %    Copyright (C) 1997 Aladdin Enterprises.  All rights reserved.
  2. % This software is provided AS-IS with no warranty, either express or
  3. % implied.
  4. % This software is distributed under license and may not be copied,
  5. % modified or distributed except as expressly authorized under the terms
  6. % of the license contained in the file LICENSE in this distribution.
  7. % For more information about licensing, please refer to
  8. % http://www.ghostscript.com/licensing/. For information on
  9. % commercial licensing, go to http://www.artifex.com/licensing/ or
  10. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  12.  
  13. % $Id: gs_typ32.ps,v 1.6 2002/06/02 12:03:28 mpsuzuki Exp $
  14. % Initialization file for Type 32 fonts.
  15.  
  16. % ------ Type 32 fonts ------ %
  17.  
  18. % We need LanguageLevel 2 or higher in order to have defineresource.
  19. languagelevel dup 2 .max .setlanguagelevel
  20.  
  21. /BitmapFontInit mark
  22.  
  23. /.makeglyph32 systemdict /.makeglyph32 get
  24. systemdict /.makeglyph32 .undef
  25.  
  26. /addglyph {    % ([wx wy llx lly urx ury] |
  27.         %     [w0x w0y llx lly urx ury w1x w1y vx vy])
  28.         %   <bitmap> <cid> <type32font> addglyph -
  29.   1 index dup 2 index .removeglyphs
  30.   22 string .makeglyph32
  31.         % Stack: metrics bitmap cid font metstr
  32.   3 index () ne {
  33.         % Use G4 encoding to compress the bitmap.
  34.         % Define a string large enough to hold the metrics,
  35.         % an uncompressed bitmap (worst case = 5x expansion),
  36.         % and the 2 RTC codes (3 bytes).
  37.     dup length 4 index length 5 mul add 10 add string
  38.         % Stack: metrics bitmap cid font metstr buffer
  39.     dup 0 3 index putinterval
  40.     dup 2 index length 1 index length 1 index sub getinterval
  41.         % Stack: metrics bitmap cid font metstr buffer bitbuf
  42.     mark /Columns 8 index dup 4 get exch 2 get sub
  43.       /Rows 10 index dup 5 get exch 3 get sub
  44.       /K -1 /EndOfBlock true /BlackIs1 true
  45.     .dicttomark /CCITTFaxEncode filter
  46.         % Stack: metrics bitmap cid font metstr buffer filter
  47.     dup 6 index writestring closefile
  48.         % Find the end of the data by scanning backwards for the RTC.
  49.         % There are 2 RTCs x 12 bits = 3 bytes to remove.
  50.     {
  51.       dup dup length 1 sub get 0 ne { exit } if
  52.       0 1 index length 1 sub getinterval
  53.     } loop
  54.     0 1 index length 3 sub getinterval
  55.     exch pop    % metstr
  56.   } if
  57.   1 index /CharStrings get 3 index 3 -1 roll put
  58.   pop pop pop pop
  59. } obind
  60.  
  61. /removeall {        % <type32font> removeall -
  62.   0 65535 2 index removeglyphs pop
  63. } obind
  64.  
  65. /.removeglyphs systemdict /.removeglyphs get
  66. systemdict /.removeglyphs .undef
  67.  
  68. /removeglyphs {        % <cid_min> <cid_max> <type32font> .removeglyphs -
  69.   3 copy .removeglyphs
  70.   dup /CharStrings get dup {
  71.         % Stack: cidmin cidmax font CharStrings cid bitmap
  72.     pop dup 5 index ge { dup 4 index le { 2 copy undef } if } if pop
  73.   } forall pop pop pop pop
  74. } obind
  75.  
  76. .dicttomark /ProcSet defineresource pop
  77.  
  78. /.cidfonttypes where { pop } { /.cidfonttypes 6 dict def } ifelse
  79. .cidfonttypes begin
  80.  
  81. 4    % CIDFontType 4 = FontType 32
  82. { dup /FontType 32 put
  83.   dup /CharStrings 20 dict put
  84.   1 index exch .buildfont32 exch pop
  85. } bind def
  86.  
  87. end        % .cidfonttypes
  88.  
  89. % Define the BuildGlyph procedure.
  90. % Since Type 32 fonts are indexed by CID, there is no BuildChar procedure.
  91. % The name %Type32BuildGlyph is known to the interpreter.
  92. (%Type32BuildGlyph) cvn {    % <font> <cid> %Type32BuildGlyph -
  93.   1 index /CharStrings get
  94.         % Stack: font cid CharStrings
  95.   dup 2 index .knownget
  96.  { exch pop } { 0 get } ifelse
  97.         % Stack: font cid cstr
  98.   dup //.getmetrics32    % use // because of .undef below
  99.   dup 14 gt {
  100.     8 index 8 index 13 3 roll setcachedevice2
  101.   } {
  102.     4 index 4 index 9 3 roll setcachedevice
  103.   } ifelse
  104.         % Stack: font cid cstr w h nmetrics llx lly
  105.   6 -1 roll 4 -1 roll 1 index length 1 index sub getinterval
  106.         % Stack: font cid w h llx lly bitstr
  107.   dup () eq {
  108.     pop pop pop
  109.   } {
  110.     mark /Columns 6 index /Rows 7 index /K -1 /EndOfBlock false /BlackIs1 true
  111.     .dicttomark /CCITTFaxDecode filter 4 index 4 index true
  112.         % Stack: font cid w h llx lly filter w h true
  113.     [ 1 0 0 1 11 -2 roll exch neg exch neg ] 5 -1 roll imagemask
  114.   } ifelse
  115.   pop pop pop pop
  116. } bind def
  117.  
  118. systemdict /.getmetrics32 .undef
  119.  
  120. buildfontdict 32 /.buildfont32 cvx put
  121.  
  122. 32 dup /FontType defineresource pop
  123.  
  124. .setlanguagelevel
  125.