星火微课系统客户端
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_cidtt.ps 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. % Copyright (C) 2000 Artifex Software, Inc. 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_cidtt.ps 9834 2009-07-03 09:27:02Z ken $
  16. % Redefine CIDFont category with an emulation with True Type fonts.
  17. languagelevel 2 .setlanguagelevel
  18. 15 dict begin % a temporary dictionary for local binding.
  19. %------------------Copy the FontEmulationProcs here : -------------------
  20. /FontEmulationProcs /ProcSet findresource {
  21. def
  22. } forall
  23. currentdict /super.complete_instance currentdict /complete_instance get put
  24. %-------Auxiliary procedures for building CIDFontType 2 from TT file -----------
  25. /GenerateCIDMap % <font> GenerateCIDMap <font>
  26. { begin
  27. % Obtain the maximal CID :
  28. % This implementation doesn't check whether glyphs really present.
  29. Decoding /CIDCount get /CIDCount exch def
  30. % Prepare the CIDMap structure :
  31. /CIDMap [
  32. CIDCount 22000 le {
  33. CIDCount 2 mul string
  34. } {
  35. 44000 string
  36. CIDCount 44000 gt {
  37. % need three strings
  38. 44000 string % 22000 2 mul string
  39. CIDCount 44000 sub 2 mul string
  40. } {
  41. CIDCount 22000 sub 2 mul string
  42. } ifelse
  43. } ifelse
  44. ] def
  45. % Now fill it :
  46. Decoding TT_cmap SubstNWP GDBytes CIDMap .fillCIDMap
  47. currentdict end
  48. } bind def
  49. /GenerateIdentityCIDMap % <font> GenerateCIDMap <font>
  50. { begin
  51. /CIDMap [ 44000 string 44000 string 44000 string] def
  52. CIDMap .fillIdentityCIDMap
  53. currentdict end
  54. } bind def
  55. /load_sfnts % <FontDict> load_sfnts <FontDict>
  56. { % Read the True Type file from the path /Path, and buld /sfnts,
  57. % skipping glyf and loca.
  58. dup /Path get % <font> (path)
  59. QUIET not {
  60. (Loading a TT font from ) print dup print
  61. ( to emulate a CID font ) print 1 index /CIDFontName get =only ( ... ) print
  62. } if
  63. (r) file dup % <font> file file
  64. 3 1 roll % file <font> file
  65. 1 index /SubfontID .knownget not { 0 } if % file <font> file SubfontID
  66. .load_tt_font_stripped exch copy % file <font>
  67. QUIET not {
  68. (Done.) =
  69. } if
  70. dup 3 1 roll % <font> file <font>
  71. exch /File exch put % <font>
  72. dup dup /CIDSystemInfo get /Ordering get (.) % <font> () ()
  73. 2 index /Decoding get =string cvs % <font> () () ()
  74. concatstrings concatstrings cvn /Decoding exch put % <font>
  75. dup dup /CIDSystemInfo get /Ordering get (-WMode) % <font> <font> () ()
  76. concatstrings cvn /SubstCID
  77. 2 copy resourcestatus {
  78. pop pop
  79. findresource /subst_CID_on_WMode exch put % <font>
  80. } {
  81. pop pop pop
  82. } ifelse
  83. dup /Decoding get /Identity.Unicode eq {
  84. //ChooseDecoding exec % <font>
  85. //GenerateIdentityCIDMap exec % <font>
  86. } {
  87. //ChooseDecoding exec % <font>
  88. //GenerateCIDMap exec % <font>
  89. } ifelse
  90. } bind def
  91. %-----------TrueType-specific methods for category redefinition : -----------
  92. /RefinePath % <FontDict> RefinePath <FontDict>
  93. { dup begin
  94. Path .libfile {
  95. dup .filename {
  96. currentdict exch /Path exch put
  97. } if
  98. closefile
  99. } {
  100. (Can't find the font file ) print =
  101. /findfont cvx /undefinedfilename signalerror
  102. } ifelse
  103. end
  104. } bind def
  105. /complete_instance % <font_name> <FontDict> <Options> complete_FAPI_Font <font_name> <FontDict>
  106. { 1 index /CIDFontType 2 put % Other types are not emulated yet.
  107. //super.complete_instance exec
  108. //RefinePath exec
  109. //load_sfnts exec
  110. } bind def
  111. /IsMyRecord % <raw_record> -> <raw_record> bool
  112. { dup type /dicttype eq { dup /FileType .knownget { /TrueType eq } { false } ifelse } { false } ifelse
  113. } bind def
  114. /IsActive % <record> IsActive <bool>
  115. { pop true
  116. } bind def
  117. /CIDFontRecordVirtualMethods //RecordVirtualMethodsStub dup length 3 add dict copy begin
  118. /GetCSI //TranslateCSI def
  119. /IsActive //IsActive def
  120. /MakeInstance % <Name> <record> MakeInstance <Name> <Instance> <size>
  121. { currentglobal 3 1 roll true setglobal
  122. //CIDFontOptions //complete_instance exec
  123. 2 copy //GetSize exec
  124. 4 3 roll setglobal
  125. } bind def
  126. currentdict end def
  127. % Redefine the /CIDFont category :
  128. 4 dict begin
  129. /CategoryName /CIDFont def
  130. /IsMapFileOptional true def
  131. /VerifyMap { pop } bind def
  132. /PreprocessRecord % <map> <Name> <raw_record> PreprocessRecord <map> <Name> <record> <bool>
  133. { //IsMyRecord exec dup {
  134. pop dup /RecordVirtualMethods //CIDFontRecordVirtualMethods put
  135. true
  136. } if
  137. } bind def
  138. currentdict end
  139. /MappedCategoryRedefiner /ProcSet findresource /Redefine get exec
  140. end % the temporary dictionary for local binding.
  141. .setlanguagelevel