gs_kanji.ps 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. % Copyright (C) 1994, 1995, 1996 Aladdin Enterprises. All rights reserved.
  2. %
  3. % This file is part of AFPL Ghostscript.
  4. %
  5. % AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  6. % distributor accepts any responsibility for the consequences of using it, or
  7. % for whether it serves any particular purpose or works at all, unless he or
  8. % she says so in writing. Refer to the Aladdin Free Public License (the
  9. % "License") for full details.
  10. %
  11. % Every copy of AFPL Ghostscript must include a copy of the License, normally
  12. % in a plain ASCII text file named PUBLIC. The License grants you the right
  13. % to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14. % conditions described in the License. Among other things, the License
  15. % requires that the copyright notice and this notice be preserved on all
  16. % copies.
  17. % $Id: gs_kanji.ps,v 1.2 2000/09/19 18:29:11 lpd Exp $
  18. % Scaffolding for Kanji fonts. This is based on the Wadalab free font
  19. % from the University of Tokyo; it may not be appropriate for other
  20. % Kanji fonts.
  21. /currentglobal where
  22. { pop currentglobal { setglobal } true setglobal }
  23. { { } }
  24. ifelse
  25. % Define the encoding for the root font.
  26. /KanjiEncoding
  27. % \x00
  28. 0 0 0 0 0 0 0 0
  29. 0 0 0 0 0 0 0 0
  30. 0 0 0 0 0 0 0 0
  31. 0 0 0 0 0 0 0 0
  32. % \x20
  33. 0 1 2 3 4 5 6 7
  34. 8 0 0 0 0 0 0 0
  35. 9 10 11 12 13 14 15 16
  36. 17 18 19 20 21 22 23 24
  37. % \x40
  38. 25 26 27 28 29 30 31 32
  39. 33 34 35 36 37 38 39 40
  40. 41 42 43 44 45 46 47 48
  41. 49 50 51 52 53 54 55 56
  42. % \x60
  43. 57 58 59 60 61 62 63 64
  44. 65 66 67 68 69 70 71 72
  45. 73 74 75 76 77 0 0 0
  46. 0 0 0 0 0 0 0 0
  47. % \x80
  48. 0 0 0 0 0 0 0 0
  49. 0 0 0 0 0 0 0 0
  50. 0 0 0 0 0 0 0 0
  51. 0 0 0 0 0 0 0 0
  52. % \xA0
  53. 0 1 2 3 4 5 6 7
  54. 8 0 0 0 0 0 0 0
  55. 9 10 11 12 13 14 15 16
  56. 17 18 19 20 21 22 23 24
  57. % \xC0
  58. 25 26 27 28 29 30 31 32
  59. 33 34 35 36 37 38 39 40
  60. 41 42 43 44 45 46 47 48
  61. 49 50 51 52 53 54 55 56
  62. % \xE0
  63. 57 58 59 60 61 62 63 64
  64. 65 66 67 68 69 70 71 72
  65. 73 74 75 76 77 0 0 0
  66. 0 0 0 0 0 0 0 0
  67. 256 packedarray def
  68. % Define a stub for the base font encoding.
  69. /KanjiSubEncoding { /KanjiSubEncoding .findencoding } bind def
  70. %% Replace 3 (gs_ksb_e.ps)
  71. EncodingDirectory /KanjiSubEncoding
  72. { (gs_ksb_e.ps) //systemdict begin runlibfile KanjiSubEncoding end }
  73. bind put
  74. % Support procedures and data.
  75. /T1FontInfo 8 dict begin
  76. /version (001.001) readonly def
  77. /FullName (KanjiBase) readonly def
  78. /FamilyName (KanjiBase) readonly def
  79. /Weight (Medium) readonly def
  80. /ItalicAngle 0 def
  81. /isFixedPitch false def
  82. /UnderlinePosition 0 def
  83. /UnderlineThickness 0 def
  84. currentdict end readonly def
  85. /T1NF % <fontname> T1NF <font>
  86. {
  87. 20 dict begin
  88. /FontName exch def
  89. /FontType 1 def
  90. /FontInfo T1FontInfo def
  91. /FontMatrix [.001 0 0 .001 0 0] def
  92. /FontBBox [0 0 1000 1000] def
  93. /Encoding KanjiSubEncoding def
  94. /CharStrings 150 dict def
  95. /PaintType 0 def
  96. /Private 2 dict def
  97. Private begin
  98. /BlueValues [] def
  99. /password 5839 def
  100. end
  101. FontName currentdict end definefont
  102. } def
  103. /T0NF % <fontname> T0NF <font>
  104. {
  105. 20 dict begin
  106. /FontName exch def
  107. /FDepVector exch def
  108. /FontType 0 def
  109. /FontMatrix [1 0 0 1 0 0] def
  110. /FMapType 2 def
  111. /Encoding KanjiEncoding def
  112. FontName currentdict end definefont
  113. } def
  114. % Define the composite font and all the base fonts.
  115. /CompNF % <fontname> CompNF <font>
  116. {
  117. /newname1 exch def
  118. newname1 dup length string cvs /str exch def
  119. str length /len exch def
  120. /fdepvector 78 array def
  121. /j 1 def
  122. 16#21 1 16#74 {
  123. /i exch def
  124. KanjiEncoding i get 0 gt {
  125. len 4 add string /newstr exch def
  126. newstr 0 str putinterval
  127. newstr len (.r) putinterval
  128. newstr len 2 add i 16 2 string cvrs putinterval
  129. newstr cvn /newlit exch def
  130. newlit T1NF /newfont exch def
  131. fdepvector j newfont put
  132. /j j 1 add def
  133. } if
  134. } for
  135. fdepvector 0 fdepvector 1 get put
  136. /j 0 def
  137. fdepvector newname1 T0NF
  138. } def
  139. % Define an individual character in a composite font.
  140. /CompD % <charstring> <(HL)> CompD -
  141. { currentfont /Encoding get 1 index 0 get get % FDepVector index
  142. currentfont /FDepVector get exch get % base font
  143. dup /Encoding get 3 -1 roll 1 get get % base font character name
  144. exch /CharStrings get exch 3 -1 roll put
  145. } bind def
  146. exec