_cidfontdata.py 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. #Copyright ReportLab Europe Ltd. 2000-2017
  2. #see license.txt for license details
  3. #history https://hg.reportlab.com/hg-public/reportlab/log/tip/src/reportlab/pdfbase/_cidfontdata.py
  4. #$Header $
  5. __version__='3.3.0'
  6. __doc__="""
  7. This defines additional static data to support CID fonts.
  8. Canned data is provided for the Japanese fonts supported by Adobe. We
  9. can add Chinese, Korean and Vietnamese in due course. The data was
  10. extracted by creating very simple postscript documents and running
  11. through Distiller, then examining the resulting PDFs.
  12. Each font is described as a big nested dictionary. This lets us keep
  13. code out of the module altogether and avoid circular dependencies.
  14. The encoding and font data are grouped by some standard 'language
  15. prefixes'::
  16. chs = Chinese Simplified (mainland)
  17. cht = Chinese Traditional (Taiwan)
  18. kor = Korean
  19. jpn = Japanese
  20. """
  21. languages = ['jpn', 'kor', 'cht', 'chs']
  22. #breaking down the lists let us check if something is present
  23. #for a specific language
  24. typeFaces_chs = ['STSong-Light'] # to do
  25. typeFaces_cht = ['MSung-Light'] #, 'MHei-Medium'] # to do
  26. typeFaces_jpn = ['HeiseiMin-W3', 'HeiseiKakuGo-W5']
  27. typeFaces_kor = ['HYSMyeongJo-Medium','HYGothic-Medium']
  28. allowedTypeFaces = typeFaces_chs + typeFaces_cht + typeFaces_jpn + typeFaces_kor
  29. encodings_jpn = [
  30. # official encoding names, comments taken verbatim from PDF Spec
  31. '83pv-RKSJ-H', #Macintosh, JIS X 0208 character set with KanjiTalk6
  32. #extensions, Shift-JIS encoding, Script Manager code 1
  33. '90ms-RKSJ-H', #Microsoft Code Page 932 (lfCharSet 0x80), JIS X 0208
  34. #character set with NEC and IBM extensions
  35. '90ms-RKSJ-V', #Vertical version of 90ms-RKSJ-H
  36. '90msp-RKSJ-H', #Same as 90ms-RKSJ-H, but replaces half-width Latin
  37. #characters with proportional forms
  38. '90msp-RKSJ-V', #Vertical version of 90msp-RKSJ-H
  39. '90pv-RKSJ-H', #Macintosh, JIS X 0208 character set with KanjiTalk7
  40. #extensions, Shift-JIS encoding, Script Manager code 1
  41. 'Add-RKSJ-H', #JIS X 0208 character set with Fujitsu FMR extensions,
  42. #Shift-JIS encoding
  43. 'Add-RKSJ-V', #Vertical version of Add-RKSJ-H
  44. 'EUC-H', #JIS X 0208 character set, EUC-JP encoding
  45. 'EUC-V', #Vertical version of EUC-H
  46. 'Ext-RKSJ-H', #JIS C 6226 (JIS78) character set with NEC extensions,
  47. #Shift-JIS encoding
  48. 'Ext-RKSJ-V', #Vertical version of Ext-RKSJ-H
  49. 'H', #JIS X 0208 character set, ISO-2022-JP encoding,
  50. 'V', #Vertical version of H
  51. 'UniJIS-UCS2-H', #Unicode (UCS-2) encoding for the Adobe-Japan1 character
  52. #collection
  53. 'UniJIS-UCS2-V', #Vertical version of UniJIS-UCS2-H
  54. 'UniJIS-UCS2-HW-H', #Same as UniJIS-UCS2-H, but replaces proportional Latin
  55. #characters with half-width forms
  56. 'UniJIS-UCS2-HW-V' #Vertical version of UniJIS-UCS2-HW-H
  57. ]
  58. encodings_kor = [
  59. 'KSC-EUC-H', # KS X 1001:1992 character set, EUC-KR encoding
  60. 'KSC-EUC-V', # Vertical version of KSC-EUC-H
  61. 'KSCms-UHC-H', # Microsoft Code Page 949 (lfCharSet 0x81), KS X 1001:1992
  62. #character set plus 8,822 additional hangul, Unified Hangul
  63. #Code (UHC) encoding
  64. 'KSCms-UHC-V', #Vertical version of KSCms-UHC-H
  65. 'KSCms-UHC-HW-H', #Same as KSCms-UHC-H, but replaces proportional Latin
  66. # characters with halfwidth forms
  67. 'KSCms-UHC-HW-V', #Vertical version of KSCms-UHC-HW-H
  68. 'KSCpc-EUC-H', #Macintosh, KS X 1001:1992 character set with MacOS-KH
  69. #extensions, Script Manager Code 3
  70. 'UniKS-UCS2-H', #Unicode (UCS-2) encoding for the Adobe-Korea1 character collection
  71. 'UniKS-UCS2-V' #Vertical version of UniKS-UCS2-H
  72. ]
  73. encodings_chs = [
  74. 'GB-EUC-H', # Microsoft Code Page 936 (lfCharSet 0x86), GB 2312-80
  75. # character set, EUC-CN encoding
  76. 'GB-EUC-V', # Vertical version of GB-EUC-H
  77. 'GBpc-EUC-H', # Macintosh, GB 2312-80 character set, EUC-CN encoding,
  78. # Script Manager code 2
  79. 'GBpc-EUC-V', # Vertical version of GBpc-EUC-H
  80. 'GBK-EUC-H', # Microsoft Code Page 936 (lfCharSet 0x86), GBK character
  81. # set, GBK encoding
  82. 'GBK-EUC-V', # Vertical version of GBK-EUC-V
  83. 'UniGB-UCS2-H', # Unicode (UCS-2) encoding for the Adobe-GB1
  84. # character collection
  85. 'UniGB-UCS2-V' # Vertical version of UniGB-UCS2-H.
  86. ]
  87. encodings_cht = [
  88. 'B5pc-H', # Macintosh, Big Five character set, Big Five encoding,
  89. # Script Manager code 2
  90. 'B5pc-V', # Vertical version of B5pc-H
  91. 'ETen-B5-H', # Microsoft Code Page 950 (lfCharSet 0x88), Big Five
  92. # character set with ETen extensions
  93. 'ETen-B5-V', # Vertical version of ETen-B5-H
  94. 'ETenms-B5-H', # Microsoft Code Page 950 (lfCharSet 0x88), Big Five
  95. # character set with ETen extensions; this uses proportional
  96. # forms for half-width Latin characters.
  97. 'ETenms-B5-V', # Vertical version of ETenms-B5-H
  98. 'CNS-EUC-H', # CNS 11643-1992 character set, EUC-TW encoding
  99. 'CNS-EUC-V', # Vertical version of CNS-EUC-H
  100. 'UniCNS-UCS2-H', # Unicode (UCS-2) encoding for the Adobe-CNS1
  101. # character collection
  102. 'UniCNS-UCS2-V' # Vertical version of UniCNS-UCS2-H.
  103. ]
  104. # the Identity encodings simply dump out all character
  105. # in the font in the order they were defined.
  106. allowedEncodings = (['Identity-H', 'Identity-V'] +
  107. encodings_chs +
  108. encodings_cht +
  109. encodings_jpn +
  110. encodings_kor
  111. )
  112. defaultUnicodeEncodings = {
  113. #we ddefine a default Unicode encoding for each face name;
  114. #this should be the most commonly used horizontal unicode encoding;
  115. #also define a 3-letter language code.
  116. 'HeiseiMin-W3': ('jpn','UniJIS-UCS2-H'),
  117. 'HeiseiKakuGo-W5': ('jpn','UniJIS-UCS2-H'),
  118. 'STSong-Light': ('chs', 'UniGB-UCS2-H'),
  119. 'MSung-Light': ('cht', 'UniGB-UCS2-H'),
  120. #'MHei-Medium': ('cht', 'UniGB-UCS2-H'),
  121. 'HYSMyeongJo-Medium': ('kor', 'UniKS-UCS2-H'),
  122. 'HYGothic-Medium': ('kor','UniKS-UCS2-H'),
  123. }
  124. typeFaces_chs = ['STSong-Light'] # to do
  125. typeFaces_cht = ['MSung-Light', 'MHei-Medium'] # to do
  126. typeFaces_jpn = ['HeiseiMin-W3', 'HeiseiKakuGo-W5']
  127. typeFaces_kor = ['HYSMyeongJo-Medium','HYGothic-Medium']
  128. #declare separately those used for unicode
  129. unicode_encodings = [enc for enc in allowedEncodings if 'UCS2' in enc]
  130. CIDFontInfo = {}
  131. #statically describe the fonts in Adobe's Japanese Language Packs
  132. CIDFontInfo['HeiseiMin-W3'] = {
  133. 'Type':'/Font',
  134. 'Subtype':'/Type0',
  135. 'Name': '/%(internalName)s' , #<-- the internal name
  136. 'BaseFont': '/HeiseiMin-W3',
  137. 'Encoding': '/%(encodings)s',
  138. #there could be several descendant fonts if it is an old-style
  139. #type 0 compound font. For CID fonts there is just one.
  140. 'DescendantFonts': [{
  141. 'Type':'/Font',
  142. 'Subtype':'/CIDFontType0',
  143. 'BaseFont':'/HeiseiMin-W3',
  144. 'FontDescriptor': {
  145. 'Type': '/FontDescriptor',
  146. 'Ascent': 723,
  147. 'CapHeight': 709,
  148. 'Descent': -241,
  149. 'Flags': 6,
  150. 'FontBBox': (-123, -257, 1001, 910),
  151. 'FontName': '/HeiseiMin-W3',
  152. 'ItalicAngle': 0,
  153. 'StemV': 69,
  154. 'XHeight': 450#,
  155. # 'Style': {'Panose': '<010502020400000000000000>'}
  156. },
  157. 'CIDSystemInfo': {
  158. 'Registry': '(Adobe)',
  159. 'Ordering': '(Japan1)',
  160. 'Supplement': 2
  161. },
  162. #default width is 1000 em units
  163. 'DW': 1000,
  164. #widths of any which are not the default.
  165. 'W': [1, [250, 333, 408, 500],
  166. 5, [500, 833, 778, 180, 333],
  167. 10, [333, 500, 564, 250, 333, 250, 278, 500],
  168. 18, 26, 500, 27, 28, 278, 29, 31, 564,
  169. 32, [444, 921, 722, 667],
  170. 36, [667, 722, 611, 556, 722],
  171. 41, [722, 333, 389, 722, 611, 889, 722],
  172. 48, [722, 556, 722, 667, 556, 611, 722],
  173. 55, [722, 944, 722],
  174. 58, [722, 611, 333, 500, 333, 469, 500, 333,
  175. 444, 500, 444, 500, 444, 333, 500],
  176. 73, [500, 278],
  177. 75, [278, 500, 278, 778, 500], 80, 82, 500,
  178. 83, [333, 389, 278, 500],
  179. 87, [500, 722, 500],
  180. 90, [500, 444, 480, 200, 480, 333],
  181. 97, [278], 99, [200], 101, [333, 500], 103, [500, 167],
  182. 107, [500], 109, [500, 333], 111, [333, 556],
  183. 113, [556, 500], 117, [250], 119, [350, 333, 444],
  184. 123, [500], 126, [444, 333], 128, 137, 333,
  185. 138, [1000, 889, 276, 611, 722, 889, 310, 667, 278],
  186. 147, [278, 500, 722, 500, 564, 760, 564, 760],
  187. 157, 158, 300, 159, [500, 300, 750], 162, 163, 750,
  188. 164, 169, 722, 170, [667, 611], 172, 174, 611, 175,
  189. 178, 333, 179, 185, 722, 187, 191, 722, 192,
  190. [556, 444], 194, 203, 444, 204, 207, 278, 208,
  191. 214, 500, 216, 222, 500,
  192. 223, [556, 722, 611, 500, 389, 980, 444],
  193. 231, [500], 323, [500], 325, [500],
  194. 327, 389, 500]
  195. ## 'W': (
  196. ## # starting at character ID 1, next n characters have the widths given.
  197. ## 1, (277,305,500,668,668,906,727,305,445,445,508,668,305,379,305,539),
  198. ## # all Characters from ID 17 to 26 are 668 em units wide
  199. ## 17, 26, 668,
  200. ## 27, (305, 305, 668, 668, 668, 566, 871, 727, 637, 652, 699, 574, 555,
  201. ## 676, 687, 242, 492, 664, 582, 789, 707, 734, 582, 734, 605, 605,
  202. ## 641, 668, 727, 945, 609, 609, 574, 445, 668, 445, 668, 668, 590,
  203. ## 555, 609, 547, 602, 574, 391, 609, 582, 234, 277, 539, 234, 895,
  204. ## 582, 605, 602, 602, 387, 508, 441, 582, 562, 781, 531, 570, 555,
  205. ## 449, 246, 449, 668),
  206. ## # these must be half width katakana and the like.
  207. ## 231, 632, 500
  208. ## )
  209. }]# end list of descendant fonts
  210. } #end HeiseiMin-W3
  211. CIDFontInfo['HeiseiKakuGo-W5'] = {'Type':'/Font',
  212. 'Subtype':'/Type0',
  213. 'Name': '/%(internalName)s', #<-- the internal name
  214. 'BaseFont': '/HeiseiKakuGo-W5',
  215. 'Encoding': '/%(encodings)s',
  216. 'DescendantFonts': [{'Type':'/Font',
  217. 'Subtype':'/CIDFontType0',
  218. 'BaseFont':'/HeiseiKakuGo-W5',
  219. 'FontDescriptor': {
  220. 'Type': '/FontDescriptor',
  221. 'Ascent': 752,
  222. 'CapHeight': 737,
  223. 'Descent': -221,
  224. 'Flags': 4,
  225. 'FontBBox': [-92, -250, 1010, 922],
  226. 'FontName': '/HeiseKakuGo-W5',
  227. 'ItalicAngle': 0,
  228. 'StemH': 0,
  229. 'StemV': 114,
  230. 'XHeight': 553,
  231. ## 'Style': {'Panose': '<0801020b0600000000000000>'}
  232. },
  233. 'CIDSystemInfo': {
  234. 'Registry': '(Adobe)',
  235. 'Ordering': '(Japan1)',
  236. 'Supplement': 2
  237. },
  238. 'DW': 1000,
  239. 'W': (
  240. 1, (277,305,500,668,668,906,727,305,445,445,508,668,305,379,305,539),
  241. 17, 26, 668,
  242. 27, (305, 305, 668, 668, 668, 566, 871, 727, 637, 652, 699, 574, 555,
  243. 676, 687, 242, 492, 664, 582, 789, 707, 734, 582, 734, 605, 605,
  244. 641, 668, 727, 945, 609, 609, 574, 445, 668, 445, 668, 668, 590,
  245. 555, 609, 547, 602, 574, 391, 609, 582, 234, 277, 539, 234, 895,
  246. 582, 605, 602, 602, 387, 508, 441, 582, 562, 781, 531, 570, 555,
  247. 449, 246, 449, 668),
  248. 231, 632, 500
  249. )
  250. }] # end descendant fonts
  251. }
  252. CIDFontInfo['HYGothic-Medium'] = {'Type':'/Font',
  253. 'Subtype':'/Type0',
  254. 'Name': '/%(internalName)s', #<-- the internal name
  255. 'BaseFont': '/' + 'HYGothic-Medium',
  256. 'Encoding': '/%(encodings)s',
  257. 'DescendantFonts': [{'Type':'/Font',
  258. 'Subtype':'/CIDFontType0',
  259. 'BaseFont':'/'+'HYGothic-Medium',
  260. 'FontDescriptor': {
  261. 'Type': '/FontDescriptor',
  262. 'Ascent': 752,
  263. 'AvgWidth': -271,
  264. 'CapHeight': 737,
  265. 'Descent': -142,
  266. 'Flags': 6,
  267. 'FontBBox': [-6, -145, 1003, 880],
  268. 'FontName': '/'+'HYSMyeongJo-Medium',
  269. 'ItalicAngle': 0,
  270. 'Leading': 148,
  271. 'MaxWidth': 1000,
  272. 'MissingWidth': 500,
  273. 'StemH': 0,
  274. 'StemV': 58,
  275. 'XHeight': 553
  276. },
  277. 'CIDSystemInfo': {
  278. 'Registry': '(Adobe)',
  279. 'Ordering': '(Korea1)',
  280. 'Supplement': 1
  281. },
  282. 'DW': 1000,
  283. 'W': (1, 94, 500)
  284. }] # end descendant fonts
  285. }
  286. CIDFontInfo['HYSMyeongJo-Medium'] = {'Type':'/Font',
  287. 'Subtype':'/Type0',
  288. 'Name': '/%(internalName)s', #<-- the internal name
  289. 'BaseFont': '/' + 'HYSMyeongJo-Medium',
  290. 'Encoding': '/%(encodings)s',
  291. 'DescendantFonts': [{'Type':'/Font',
  292. 'Subtype':'/CIDFontType2',
  293. 'BaseFont':'/'+'HYSMyeongJo-Medium',
  294. 'FontDescriptor': {
  295. 'Type': '/FontDescriptor',
  296. 'Ascent': 752,
  297. 'AvgWidth': 500,
  298. 'CapHeight': 737,
  299. 'Descent': -271,
  300. 'Flags': 6,
  301. 'FontBBox': [0, -148, 1001, 880],
  302. 'FontName': '/'+'HYSMyeongJo-Medium',
  303. 'ItalicAngle': 0,
  304. 'Leading': 148,
  305. 'MaxWidth': 1000,
  306. 'MissingWidth': 500,
  307. 'StemH': 91,
  308. 'StemV': 58,
  309. 'XHeight': 553
  310. },
  311. 'CIDSystemInfo': {
  312. 'Registry': '(Adobe)',
  313. 'Ordering': '(Korea1)',
  314. 'Supplement': 1
  315. },
  316. 'DW': 1000,
  317. 'W': [1, [333, 416],
  318. 3, [416, 833, 625, 916, 833, 250, 500],
  319. 10, 11, 500,
  320. 12, [833, 291, 833, 291, 375, 625],
  321. 18, 26, 625, 27, 28, 333, 29, 30, 833,
  322. 31, [916, 500, 1000, 791, 708],
  323. 36, [708, 750, 708, 666, 750, 791, 375,
  324. 500, 791, 666, 916, 791, 750, 666,
  325. 750, 708, 666, 791],
  326. 54, [791, 750, 1000, 708],
  327. 58, [708, 666, 500, 375, 500],
  328. 63, 64, 500,
  329. 65, [333, 541, 583, 541, 583],
  330. 70, [583, 375, 583],
  331. 73, [583, 291, 333, 583, 291, 875, 583],
  332. 80, 82, 583,
  333. 83, [458, 541, 375, 583],
  334. 87, [583, 833, 625],
  335. 90, [625, 500, 583], 93, 94, 583,
  336. 95, [750]
  337. ]
  338. }] # end descendant fonts
  339. }
  340. #WARNING - not checked, just copied Korean to get some output
  341. CIDFontInfo['STSong-Light'] = {'Type':'/Font',
  342. 'Subtype':'/Type0',
  343. 'Name': '/%(internalName)s', #<-- the internal name
  344. 'BaseFont': '/' + 'STSong-Light',
  345. 'Encoding': '/%(encodings)s',
  346. 'DescendantFonts': [{'Type':'/Font',
  347. 'Subtype':'/CIDFontType0',
  348. 'BaseFont':'/'+'STSong-Light',
  349. 'FontDescriptor': {
  350. 'Type': '/FontDescriptor',
  351. 'Ascent': 752,
  352. 'CapHeight': 737,
  353. 'Descent': -271,
  354. 'Flags': 6,
  355. 'FontBBox': [-25, -254, 1000, 880],
  356. 'FontName': '/'+'STSongStd-Light',
  357. 'ItalicAngle': 0,
  358. 'Leading': 148,
  359. 'MaxWidth': 1000,
  360. 'MissingWidth': 500,
  361. 'StemH': 91,
  362. 'StemV': 58,
  363. 'XHeight': 553
  364. },
  365. 'CIDSystemInfo': {
  366. 'Registry': '(Adobe)',
  367. 'Ordering': '(GB1)',
  368. 'Supplement': 0
  369. },
  370. 'DW': 1000,
  371. 'W': [1, [207, 270, 342, 467, 462, 797, 710, 239, 374],
  372. 10, [374, 423, 605, 238, 375, 238, 334, 462],
  373. 18, 26, 462, 27, 28, 238, 29, 31, 605,
  374. 32, [344, 748, 684, 560, 695, 739, 563, 511, 729,
  375. 793, 318, 312, 666, 526, 896, 758, 772, 544,
  376. 772, 628, 465, 607, 753, 711, 972, 647, 620,
  377. 607, 374, 333, 374, 606, 500, 239, 417, 503,
  378. 427, 529, 415, 264, 444, 518, 241, 230, 495,
  379. 228, 793, 527, 524],
  380. 81, [524, 504, 338, 336, 277, 517, 450, 652, 466,
  381. 452, 407, 370, 258, 370, 605]
  382. ]
  383. }] # end descendant fonts
  384. }
  385. CIDFontInfo['MSung-Light'] = {'Type':'/Font',
  386. 'Subtype':'/Type0',
  387. 'Name': '/%(internalName)s', #<-- the internal name
  388. 'BaseFont': '/' + 'MSung-Light',
  389. 'Encoding': '/%(encodings)s',
  390. 'DescendantFonts': [{'Type':'/Font',
  391. 'Subtype':'/CIDFontType0',
  392. 'BaseFont':'/'+'MSung-Light',
  393. 'FontDescriptor': {
  394. 'Type': '/FontDescriptor',
  395. 'Ascent': 752,
  396. 'CapHeight': 737,
  397. 'Descent': -271,
  398. 'Flags': 6,
  399. 'FontBBox': [-160, -249, 1015, 888],
  400. 'FontName': '/'+'MSung-Light',
  401. 'ItalicAngle': 0,
  402. 'Leading': 148,
  403. 'MaxWidth': 1000,
  404. 'MissingWidth': 500,
  405. 'StemH': 45,
  406. 'StemV': 58,
  407. 'XHeight': 553
  408. },
  409. 'CIDSystemInfo': {
  410. 'Registry': '(Adobe)',
  411. 'Ordering': '(CNS1)',
  412. 'Supplement': 1
  413. },
  414. 'DW': 1000,
  415. 'W': [1, 2, 250, 3, [408, 668, 490, 875, 698, 250, 240],
  416. 10, [240, 417, 667, 250, 313, 250, 520, 500],
  417. 18, 26, 500, 27, 28, 250, 29, 31, 667,
  418. 32, [396, 921, 677, 615, 719, 760, 625, 552, 771,
  419. 802, 354],
  420. 43, [354, 781, 604, 927, 750, 823, 563, 823, 729,
  421. 542, 698, 771, 729, 948, 771, 677, 635, 344,
  422. 520, 344, 469, 500, 250, 469, 521, 427, 521,
  423. 438, 271, 469, 531, 250],
  424. 75, [250, 458, 240, 802, 531, 500, 521],
  425. 82, [521, 365, 333, 292, 521, 458, 677, 479, 458,
  426. 427, 480, 496, 480, 667]]
  427. }] # end descendant fonts
  428. }
  429. #this data was derived from the above width information and removes all dependency on CMAP files as long as we only use the unicode fonts.
  430. widthsByUnichar = {}
  431. widthsByUnichar["MSung-Light"] = {u' ': 250, u'$': 490, u'(': 240, u',': 250, u'0': 500, u'4': 500, u'8': 500, u'<': 667, u'@': 921, u'D': 760, u'H': 802, u'L': 604, u'P': 563, u'T': 698, u'X': 771, u'\\': 520, u'`': 250, u'd': 521, u'h': 531, u'l': 240, u'p': 521, u't': 292, u'x': 479, u'|': 496, u'#': 668, u"'": 250, u'+': 667, u'/': 520, u'3': 500, u'7': 500, u';': 250, u'?': 396, u'C': 719, u'G': 771, u'K': 781, u'O': 823, u'S': 542, u'W': 948, u'[': 344, u'_': 500, u'c': 427, u'g': 469, u'k': 458, u'o': 500, u's': 333, u'w': 677, u'{': 480, u'"': 408, u'&': 698, u'*': 417, u'.': 250, u'2': 500, u'6': 500, u':': 250, u'>': 667, u'B': 615, u'F': 552, u'J': 354, u'N': 750, u'R': 729, u'V': 729, u'Z': 635, u'^': 469, u'b': 521, u'f': 271, u'j': 250, u'n': 531, u'r': 365, u'v': 458, u'z': 427, u'~': 667, u'!': 250, u'%': 875, u')': 240, u'-': 313, u'1': 500, u'5': 500, u'9': 500, u'=': 667, u'A': 677, u'E': 625, u'I': 354, u'M': 927, u'Q': 823, u'U': 771, u'Y': 677, u']': 344, u'a': 469, u'e': 438, u'i': 250, u'm': 802, u'q': 521, u'u': 521, u'y': 458, u'}': 480}
  432. widthsByUnichar["HeiseiKakuGo-W5"] = {u'\uff81': 500, u'\uff85': 500, u'\uff89': 500, u'\uff8d': 500, u'\uff91': 500, u'\uff95': 500, u'\uff99': 500, u'\uff9d': 500, u' ': 277, u'$': 668, u'(': 445, u',': 305, u'0': 668, u'\u0332': 668, u'4': 668, u'8': 668, u'<': 668, u'@': 871, u'D': 699, u'H': 687, u'L': 582, u'P': 582, u'T': 641, u'X': 609, u'`': 590, u'\uff62': 500, u'd': 602, u'\uff66': 500, u'h': 582, u'\uff6a': 500, u'l': 234, u'\uff6e': 500, u'p': 602, u'\uff72': 500, u't': 441, u'\uff76': 500, u'x': 531, u'\uff7a': 500, u'|': 246, u'\uff7e': 500, u'\uff82': 500, u'\uff86': 500, u'\uff8a': 500, u'\uff8e': 500, u'\uff92': 500, u'\uff96': 500, u'\uff9a': 500, u'\uff9e': 500, u'#': 668, u"'": 305, u'+': 668, u'/': 539, u'3': 668, u'7': 668, u';': 305, u'?': 566, u'C': 652, u'G': 676, u'K': 664, u'O': 734, u'S': 605, u'W': 945, u'[': 445, u'_': 668, u'\uff61': 500, u'c': 547, u'\uff65': 500, u'g': 609, u'\uff69': 500, u'k': 539, u'\uff6d': 500, u'o': 605, u'\uff71': 500, u's': 508, u'\uff75': 500, u'w': 781, u'\uff79': 500, u'{': 449, u'\uff7d': 500, u'\u0300': 590, u'\uff83': 500, u'\u2002': 500, u'\uff87': 500, u'\uff8b': 500, u'\uff8f': 500, u'\uff93': 500, u'\uff97': 500, u'\uff9b': 500, u'\uff9f': 500, u'"': 500, u'\xa5': 668, u'&': 727, u'*': 508, u'.': 305, u'2': 668, u'6': 668, u':': 305, u'>': 668, u'B': 637, u'F': 555, u'J': 492, u'N': 707, u'\u203e': 500, u'R': 605, u'V': 727, u'Z': 574, u'^': 668, u'b': 609, u'\uff64': 500, u'f': 391, u'\uff68': 500, u'j': 277, u'\uff6c': 500, u'n': 582, u'\uff70': 500, u'r': 387, u'\uff74': 500, u'v': 562, u'\uff78': 500, u'z': 555, u'\uff7c': 500, u'~': 668, u'\uff80': 500, u'\u0303': 668, u'\uff84': 500, u'\uff88': 500, u'\uff8c': 500, u'\u2011': 379, u'\uff90': 500, u'\uff94': 500, u'\uff98': 500, u'\uff9c': 500, u'!': 305, u'%': 906, u')': 445, u'-': 379, u'1': 668, u'5': 668, u'9': 668, u'=': 668, u'A': 727, u'E': 574, u'I': 242, u'M': 789, u'Q': 734, u'U': 668, u'Y': 609, u']': 445, u'a': 555, u'\uff63': 500, u'e': 574, u'\uff67': 500, u'i': 234, u'\uffe8': 500, u'\uff6b': 500, u'm': 895, u'\uff6f': 500, u'q': 602, u'\uff73': 500, u'u': 582, u'\uff77': 500, u'y': 570, u'\uff7b': 500, u'}': 449, u'\uff7f': 500}
  433. widthsByUnichar["HYSMyeongJo-Medium"] = {u' ': 333, u'$': 625, u'(': 500, u',': 291, u'0': 625, u'4': 625, u'8': 625, u'<': 833, u'D': 750, u'H': 791, u'L': 666, u'P': 666, u'T': 791, u'X': 708, u'\\': 375, u'`': 333, u'd': 583, u'h': 583, u'l': 291, u'p': 583, u't': 375, u'x': 625, u'|': 583, u'#': 833, u"'": 250, u'+': 833, u'/': 375, u'3': 625, u'7': 625, u';': 333, u'?': 500, u'C': 708, u'G': 750, u'K': 791, u'O': 750, u'S': 666, u'[': 500, u'_': 500, u'c': 541, u'g': 583, u'k': 583, u'o': 583, u's': 541, u'w': 833, u'{': 583, u'"': 416, u'&': 833, u'*': 500, u'.': 291, u'2': 625, u'6': 625, u':': 333, u'>': 916, u'B': 708, u'F': 666, u'J': 500, u'N': 791, u'R': 708, u'V': 750, u'Z': 666, u'^': 500, u'b': 583, u'f': 375, u'j': 333, u'n': 583, u'r': 458, u'v': 583, u'z': 500, u'~': 750, u'!': 416, u'%': 916, u')': 500, u'-': 833, u'1': 625, u'5': 625, u'9': 625, u'=': 833, u'A': 791, u'E': 708, u'I': 375, u'M': 916, u'Q': 750, u'U': 791, u'Y': 708, u']': 500, u'a': 541, u'e': 583, u'i': 291, u'm': 875, u'q': 583, u'u': 583, u'y': 625, u'}': 583}
  434. widthsByUnichar["STSong-Light"] = {u' ': 207, u'$': 462, u'(': 374, u',': 238, u'0': 462, u'4': 462, u'8': 462, u'<': 605, u'@': 748, u'D': 739, u'H': 793, u'L': 526, u'P': 544, u'T': 607, u'X': 647, u'\\': 333, u'`': 239, u'd': 529, u'h': 518, u'l': 228, u'p': 524, u't': 277, u'x': 466, u'|': 258, u'#': 467, u"'": 239, u'+': 605, u'/': 334, u'3': 462, u'7': 462, u';': 238, u'?': 344, u'C': 695, u'G': 729, u'K': 666, u'O': 772, u'S': 465, u'W': 972, u'[': 374, u'_': 500, u'c': 427, u'g': 444, u'k': 495, u'o': 524, u's': 336, u'w': 652, u'{': 370, u'"': 342, u'&': 710, u'*': 423, u'.': 238, u'2': 462, u'6': 462, u':': 238, u'>': 605, u'B': 560, u'F': 511, u'J': 312, u'N': 758, u'R': 628, u'V': 711, u'Z': 607, u'^': 606, u'b': 503, u'f': 264, u'j': 230, u'n': 527, u'r': 338, u'v': 450, u'z': 407, u'~': 605, u'!': 270, u'%': 797, u')': 374, u'-': 375, u'1': 462, u'5': 462, u'9': 462, u'=': 605, u'A': 684, u'E': 563, u'I': 318, u'M': 896, u'Q': 772, u'U': 753, u'Y': 620, u']': 374, u'a': 417, u'e': 415, u'i': 241, u'm': 793, u'q': 504, u'u': 517, u'y': 452, u'}': 370}
  435. widthsByUnichar["HeiseiMin-W3"] = {u'\uff81': 500, u'\u0302': 333, u'\uff85': 500, u'\u0306': 333, u'\uff89': 500, u'\u030a': 333, u'\uff8d': 500, u'\uff91': 500, u'\ufb02': 556, u'\uff95': 500, u'\uff99': 500, u'\uff9d': 500, u' ': 250, u'\xa3': 500, u'\u2122': 980, u'$': 500, u'(': 333, u'\xab': 500, u',': 250, u'\xaf': 333, u'0': 500, u'\xb3': 300, u'\u0332': 500, u'4': 500, u'\xb7': 250, u'8': 500, u'\xbb': 500, u'<': 564, u'\xbf': 444, u'@': 921, u'\xc3': 722, u'\u0142': 278, u'D': 722, u'\xc7': 667, u'H': 722, u'\xcb': 611, u'L': 611, u'\xcf': 333, u'P': 556, u'\xd3': 722, u'\u0152': 889, u'T': 611, u'X': 722, u'\xdb': 722, u'\\': 278, u'\xdf': 500, u'\uff64': 500, u'`': 333, u'\xe3': 444, u'\uff62': 500, u'd': 500, u'\xe7': 444, u'\uff66': 500, u'h': 500, u'\xeb': 444, u'\uff6a': 500, u'l': 278, u'\xef': 278, u'\uff6e': 500, u'p': 500, u'\xf3': 500, u'\uff72': 500, u't': 278, u'\uff76': 500, u'x': 500, u'\xfb': 500, u'\uff7a': 500, u'|': 200, u'\xff': 500, u'\u017e': 444, u'\u0301': 333, u'\uff82': 500, u'\u0305': 500, u'\uff86': 500, u'\uff8a': 500, u'\uff8e': 500, u'\u2013': 500, u'\uff92': 500, u'\uff96': 500, u'\uff9a': 500, u'\uff9e': 500, u'#': 500, u'\xa4': 500, u"'": 180, u'\u203a': 333, u'+': 564, u'\xac': 564, u'/': 278, u'\u0131': 278, u'3': 500, u'7': 500, u'\xb8': 333, u';': 278, u'\xbc': 750, u'?': 444, u'\u0141': 611, u'\xc0': 722, u'C': 667, u'\xc4': 722, u'G': 722, u'\xc8': 611, u'K': 722, u'\xcc': 333, u'O': 722, u'\xd0': 722, u'S': 556, u'\u2022': 350, u'\xd4': 722, u'W': 944, u'\uff78': 500, u'\xd8': 722, u'[': 333, u'\xdc': 722, u'_': 500, u'\u0161': 389, u'\xe0': 444, u'c': 444, u'\uff65': 500, u'\xe4': 444, u'g': 500, u'\uff69': 500, u'\xe8': 444, u'k': 500, u'\uff6d': 500, u'\xec': 278, u'o': 500, u'\uff71': 500, u'\xf0': 500, u's': 389, u'\uff75': 500, u'\xf4': 500, u'w': 722, u'\uff79': 500, u'\xf8': 500, u'{': 480, u'\uff7e': 500, u'\u017d': 611, u'\xfc': 500, u'\u0300': 333, u'\uff83': 500, u'\u2002': 500, u'\u0304': 333, u'\uff87': 500, u'\u0308': 333, u'\uff8b': 500, u'\u030c': 333, u'\uff8f': 500, u'\uff93': 500, u'\u2012': 500, u'\uff97': 500, u'\uff9b': 500, u'\u201a': 333, u'\uff9f': 500, u'\u201e': 444, u'\xa1': 333, u'"': 408, u'\xa5': 500, u'&': 778, u'\xa9': 760, u'\u0328': 333, u'*': 500, u'\xad': 564, u'.': 250, u'\uffe8': 500, u'2': 500, u'\xb5': 500, u'6': 500, u'\xb9': 300, u':': 278, u'\xbd': 750, u'>': 564, u'\xc1': 722, u'\uff61': 500, u'B': 667, u'\xc5': 722, u'F': 556, u'\xc9': 611, u'J': 389, u'\xcd': 333, u'N': 722, u'\xd1': 722, u'\u203e': 500, u'R': 667, u'\xd5': 722, u'V': 722, u'\xd9': 722, u'Z': 611, u'\xdd': 722, u'^': 469, u'\xe1': 444, u'\u0160': 556, u'b': 500, u'\xe5': 444, u'\u2039': 333, u'f': 333, u'\xe9': 444, u'\uff68': 500, u'j': 278, u'\xed': 278, u'\uff6c': 500, u'n': 500, u'\xf1': 500, u'\uff70': 500, u'r': 333, u'\xf5': 500, u'\uff74': 500, u'v': 500, u'\xf9': 500, u'\u0178': 722, u'z': 444, u'\xfd': 500, u'\uff7c': 500, u'~': 333, u'\uff80': 500, u'\u0303': 333, u'\uff84': 500, u'\u0307': 333, u'\uff88': 500, u'\u030b': 333, u'\uff8c': 500, u'\u2011': 333, u'\uff90': 500, u'\uff94': 500, u'\uff98': 500, u'\uff9c': 500, u'\u2044': 167, u'!': 333, u'\xa2': 500, u'%': 833, u'\u0327': 333, u'\xa6': 200, u')': 333, u'\xaa': 276, u'-': 333, u'\xae': 760, u'1': 500, u'\xb2': 300, u'5': 500, u'9': 500, u'\xba': 310, u'=': 564, u'\xbe': 750, u'A': 722, u'\u01c0': 200, u'\xc2': 722, u'E': 611, u'\xc6': 889, u'I': 333, u'\xca': 611, u'M': 889, u'\xce': 333, u'Q': 722, u'\u0153': 722, u'\xd2': 722, u'U': 722, u'\xd6': 722, u'Y': 722, u'\ufb01': 556, u'\xda': 722, u']': 333, u'\xde': 556, u'a': 444, u'\uff63': 500, u'\xe2': 444, u'e': 444, u'\uff67': 500, u'\xe6': 667, u'i': 278, u'\uff7d': 500, u'\uff6b': 500, u'\xea': 444, u'm': 778, u'\uff6f': 500, u'\xee': 278, u'q': 500, u'\uff73': 500, u'\xf2': 500, u'u': 500, u'\uff77': 500, u'\xf6': 500, u'y': 500, u'\uff7b': 500, u'\xfa': 500, u'}': 480, u'\uff7f': 500, u'\xfe': 500}
  436. widthsByUnichar["HYGothic-Medium"] = {u' ': 500, u'$': 500, u'(': 500, u',': 500, u'0': 500, u'4': 500, u'8': 500, u'<': 500, u'@': 500, u'D': 500, u'H': 500, u'L': 500, u'P': 500, u'T': 500, u'X': 500, u'\\': 500, u'`': 500, u'd': 500, u'h': 500, u'l': 500, u'p': 500, u't': 500, u'x': 500, u'|': 500, u'#': 500, u"'": 500, u'+': 500, u'/': 500, u'3': 500, u'7': 500, u';': 500, u'?': 500, u'C': 500, u'G': 500, u'K': 500, u'O': 500, u'S': 500, u'W': 500, u'[': 500, u'_': 500, u'c': 500, u'g': 500, u'k': 500, u'o': 500, u's': 500, u'w': 500, u'{': 500, u'"': 500, u'&': 500, u'*': 500, u'.': 500, u'2': 500, u'6': 500, u':': 500, u'>': 500, u'B': 500, u'F': 500, u'J': 500, u'N': 500, u'R': 500, u'V': 500, u'Z': 500, u'^': 500, u'b': 500, u'f': 500, u'j': 500, u'n': 500, u'r': 500, u'v': 500, u'z': 500, u'!': 500, u'%': 500, u')': 500, u'-': 500, u'1': 500, u'5': 500, u'9': 500, u'=': 500, u'A': 500, u'E': 500, u'I': 500, u'M': 500, u'Q': 500, u'U': 500, u'Y': 500, u']': 500, u'a': 500, u'e': 500, u'i': 500, u'm': 500, u'q': 500, u'u': 500, u'y': 500, u'}': 500}
  437. #shift-jis saying 'This is Heisei-Minchou'
  438. message1 = '\202\261\202\352\202\315\225\275\220\254\226\276\222\251\202\305\202\267\201B'
  439. message2 = '\202\261\202\352\202\315\225\275\220\254\212p\203S\203V\203b\203N\202\305\202\267\201B'
  440. ##def pswidths(text):
  441. ## words = text.split()
  442. ## out = []
  443. ## for word in words:
  444. ## if word == '[':
  445. ## out.append(word)
  446. ## else:
  447. ## out.append(word + ',')
  448. ## return eval(''.join(out),{})