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.

157 lines
3.9 KiB

1 month ago
  1. % Copyright (C) 2001-2023 Artifex Software, Inc.
  2. % All Rights Reserved.
  3. %
  4. % This software is provided AS-IS with no warranty, either express or
  5. % implied.
  6. %
  7. % This software is distributed under license and may not be copied,
  8. % modified or distributed except as expressly authorized under the terms
  9. % of the license contained in the file LICENSE in this distribution.
  10. %
  11. % Refer to licensing information at http://www.artifex.com or contact
  12. % Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
  13. % CA 94129, USA, for further information.
  14. %
  15. % Scaffolding for Kanji fonts. This is based on the Wadalab free font
  16. % from the University of Tokyo; it may not be appropriate for other
  17. % Kanji fonts.
  18. /currentglobal where
  19. { pop currentglobal { setglobal } true setglobal }
  20. { { } }
  21. ifelse
  22. % Define the encoding for the root font.
  23. /KanjiEncoding
  24. % \x00
  25. 0 0 0 0 0 0 0 0
  26. 0 0 0 0 0 0 0 0
  27. 0 0 0 0 0 0 0 0
  28. 0 0 0 0 0 0 0 0
  29. % \x20
  30. 0 1 2 3 4 5 6 7
  31. 8 0 0 0 0 0 0 0
  32. 9 10 11 12 13 14 15 16
  33. 17 18 19 20 21 22 23 24
  34. % \x40
  35. 25 26 27 28 29 30 31 32
  36. 33 34 35 36 37 38 39 40
  37. 41 42 43 44 45 46 47 48
  38. 49 50 51 52 53 54 55 56
  39. % \x60
  40. 57 58 59 60 61 62 63 64
  41. 65 66 67 68 69 70 71 72
  42. 73 74 75 76 77 0 0 0
  43. 0 0 0 0 0 0 0 0
  44. % \x80
  45. 0 0 0 0 0 0 0 0
  46. 0 0 0 0 0 0 0 0
  47. 0 0 0 0 0 0 0 0
  48. 0 0 0 0 0 0 0 0
  49. % \xA0
  50. 0 1 2 3 4 5 6 7
  51. 8 0 0 0 0 0 0 0
  52. 9 10 11 12 13 14 15 16
  53. 17 18 19 20 21 22 23 24
  54. % \xC0
  55. 25 26 27 28 29 30 31 32
  56. 33 34 35 36 37 38 39 40
  57. 41 42 43 44 45 46 47 48
  58. 49 50 51 52 53 54 55 56
  59. % \xE0
  60. 57 58 59 60 61 62 63 64
  61. 65 66 67 68 69 70 71 72
  62. 73 74 75 76 77 0 0 0
  63. 0 0 0 0 0 0 0 0
  64. 256 packedarray def
  65. % Define a stub for the base font encoding.
  66. /KanjiSubEncoding { /KanjiSubEncoding .findencoding } bind def
  67. %% Replace 3 (gs_ksb_e.ps)
  68. EncodingDirectory /KanjiSubEncoding
  69. { (gs_ksb_e.ps) //systemdict begin runlibfile KanjiSubEncoding end }
  70. bind put
  71. % Support procedures and data.
  72. /T1FontInfo 8 dict begin
  73. /version (001.001) readonly def
  74. /FullName (KanjiBase) readonly def
  75. /FamilyName (KanjiBase) readonly def
  76. /Weight (Medium) readonly def
  77. /ItalicAngle 0 def
  78. /isFixedPitch false def
  79. /UnderlinePosition 0 def
  80. /UnderlineThickness 0 def
  81. currentdict end readonly def
  82. /T1NF % <fontname> T1NF <font>
  83. {
  84. 20 dict begin
  85. /FontName exch def
  86. /FontType 1 def
  87. /FontInfo T1FontInfo def
  88. /FontMatrix [.001 0 0 .001 0 0] def
  89. /FontBBox [0 0 1000 1000] def
  90. /Encoding KanjiSubEncoding def
  91. /CharStrings 150 dict def
  92. /PaintType 0 def
  93. /Private 2 dict def
  94. Private begin
  95. /BlueValues [] def
  96. /password 5839 def
  97. end
  98. FontName currentdict end definefont
  99. } def
  100. /T0NF % <fontname> T0NF <font>
  101. {
  102. 20 dict begin
  103. /FontName exch def
  104. /FDepVector exch def
  105. /FontType 0 def
  106. /FontMatrix [1 0 0 1 0 0] def
  107. /FMapType 2 def
  108. /Encoding KanjiEncoding def
  109. FontName currentdict end definefont
  110. } def
  111. % Define the composite font and all the base fonts.
  112. /CompNF % <fontname> CompNF <font>
  113. {
  114. /newname1 exch def
  115. newname1 dup length string cvs /str exch def
  116. str length /len exch def
  117. /fdepvector 78 array def
  118. /j 1 def
  119. 16#21 1 16#74 {
  120. /i exch def
  121. KanjiEncoding i get 0 gt {
  122. len 4 add string /newstr exch def
  123. newstr 0 str putinterval
  124. newstr len (.r) putinterval
  125. newstr len 2 add i 16 2 string cvrs putinterval
  126. newstr cvn /newlit exch def
  127. newlit T1NF /newfont exch def
  128. fdepvector j newfont put
  129. /j j 1 add def
  130. } if
  131. } for
  132. fdepvector 0 fdepvector 1 get put
  133. /j 0 def
  134. fdepvector newname1 T0NF
  135. } def
  136. % Define an individual character in a composite font.
  137. /CompD % <charstring> <(HL)> CompD -
  138. { currentfont /Encoding get 1 index 0 get get % FDepVector index
  139. currentfont /FDepVector get exch get % base font
  140. dup /Encoding get 3 -1 roll 1 get get % base font character name
  141. exch /CharStrings get exch 3 -1 roll put
  142. } bind def
  143. exec