星火微课系统客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gs_typ32.ps 4.3KB

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