From: MORIOKA Tomohiko Date: Fri, 18 Mar 2016 08:06:50 +0000 (+0900) Subject: (www-glyph-big5-to-ucs-pua): New function. X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f72299d8ebd6189b936a58e4f87daed22865f21e;p=chise%2Fest.git (www-glyph-big5-to-ucs-pua): New function. (www-glyph-generate-png): Use `www-glyph-big5-to-ucs-pua' as a fall-back. (www-glyph-display-png): Support HZK-hhhh. --- diff --git a/cwiki-glyph.el b/cwiki-glyph.el index 9fcbaa0..3b637db 100644 --- a/cwiki-glyph.el +++ b/cwiki-glyph.el @@ -2,6 +2,34 @@ (setq file-name-coding-system 'utf-8-jp) +(defun www-glyph-big5-to-ucs-pua (code-point) + (let ((H (lsh code-point -8)) + (L (logand code-point #xff))) + (if (<= #x8140 code-point) + (if (<= code-point #x8DFE) + (+ #xEEB8 (* 157 (- H 0x81)) + (if (< L #x80) + (- L #x40) + (- L #x62))) + (if (<= #x8E40 code-point) + (if (<= code-point #xA0FE) + (+ #xE311 (* 157 (- H #x8e)) + (if (< L #x80) + (- L #x40) + (- L #x62))) + (if (<= #xC6A1 code-point) + (if (<= code-point #xC8FE) + (+ #xF672 (* 157 (- H #xC6)) + (if (< L #x80) + (- L #x40) + (- L #x62))) + (if (<= #xFA40 code-point) + (if (<= code-point #xFEFE) + (+ #xE000 (* 157 (- H #xFA)) + (if (< L #x80) + (- L #x40) + (- L #x62))))))))))))) + (defun www-glyph-generate-png (ccs code-point &optional size) (unless size (setq size 40)) @@ -63,10 +91,108 @@ ) ((eq ccs '=big5-cdp) (setq font "/usr/local/share/fonts/TrueType/CDP/Cdpeudc.ttf" - char (decode-char '=big5-pua code-point) + char (or (decode-char '=big5-pua code-point) + (decode-char '=ucs + (www-glyph-big5-to-ucs-pua code-point))) png-file (format "/opt/chisewiki/glyphs/%d/CDP/%04X.png" size code-point)) ) + ((eq ccs '=hanziku-1) + (setq font "/usr/local/share/fonts/TrueType/Hanziku/hzk1u.ttf" + char (or (decode-char '=big5-pua code-point) + (decode-char '=ucs + (www-glyph-big5-to-ucs-pua code-point))) + png-file (format "/opt/chisewiki/glyphs/%d/Hanziku-01/%04X.png" + size code-point)) + ) + ((eq ccs '=hanziku-2) + (setq font "/usr/local/share/fonts/TrueType/Hanziku/hzk2u.ttf" + char (or (decode-char '=big5-pua code-point) + (decode-char '=ucs + (www-glyph-big5-to-ucs-pua code-point))) + png-file (format "/opt/chisewiki/glyphs/%d/Hanziku-02/%04X.png" + size code-point)) + ) + ((eq ccs '=hanziku-3) + (setq font "/usr/local/share/fonts/TrueType/Hanziku/hzk3u.ttf" + char (or (decode-char '=big5-pua code-point) + (decode-char '=ucs + (www-glyph-big5-to-ucs-pua code-point))) + png-file (format "/opt/chisewiki/glyphs/%d/Hanziku-03/%04X.png" + size code-point)) + ) + ((eq ccs '=hanziku-4) + (setq font "/usr/local/share/fonts/TrueType/Hanziku/hzk4u.ttf" + char (or (decode-char '=big5-pua code-point) + (decode-char '=ucs + (www-glyph-big5-to-ucs-pua code-point))) + png-file (format "/opt/chisewiki/glyphs/%d/Hanziku-04/%04X.png" + size code-point)) + ) + ((eq ccs '=hanziku-5) + (setq font "/usr/local/share/fonts/TrueType/Hanziku/hzk5u.ttf" + char (or (decode-char '=big5-pua code-point) + (decode-char '=ucs + (www-glyph-big5-to-ucs-pua code-point))) + png-file (format "/opt/chisewiki/glyphs/%d/Hanziku-05/%04X.png" + size code-point)) + ) + ((eq ccs '=hanziku-6) + (setq font "/usr/local/share/fonts/TrueType/Hanziku/hzk6u.ttf" + char (or (decode-char '=big5-pua code-point) + (decode-char '=ucs + (www-glyph-big5-to-ucs-pua code-point))) + png-file (format "/opt/chisewiki/glyphs/%d/Hanziku-06/%04X.png" + size code-point)) + ) + ((eq ccs '=hanziku-7) + (setq font "/usr/local/share/fonts/TrueType/Hanziku/hzk7u.ttf" + char (or (decode-char '=big5-pua code-point) + (decode-char '=ucs + (www-glyph-big5-to-ucs-pua code-point))) + png-file (format "/opt/chisewiki/glyphs/%d/Hanziku-07/%04X.png" + size code-point)) + ) + ((eq ccs '=hanziku-8) + (setq font "/usr/local/share/fonts/TrueType/Hanziku/hzk8u.ttf" + char (or (decode-char '=big5-pua code-point) + (decode-char '=ucs + (www-glyph-big5-to-ucs-pua code-point))) + png-file (format "/opt/chisewiki/glyphs/%d/Hanziku-08/%04X.png" + size code-point)) + ) + ((eq ccs '=hanziku-9) + (setq font "/usr/local/share/fonts/TrueType/Hanziku/hzk9u.ttf" + char (or (decode-char '=big5-pua code-point) + (decode-char '=ucs + (www-glyph-big5-to-ucs-pua code-point))) + png-file (format "/opt/chisewiki/glyphs/%d/Hanziku-09/%04X.png" + size code-point)) + ) + ((eq ccs '=hanziku-10) + (setq font "/usr/local/share/fonts/TrueType/Hanziku/hzkau.ttf" + char (or (decode-char '=big5-pua code-point) + (decode-char '=ucs + (www-glyph-big5-to-ucs-pua code-point))) + png-file (format "/opt/chisewiki/glyphs/%d/Hanziku-10/%04X.png" + size code-point)) + ) + ((eq ccs '=hanziku-11) + (setq font "/usr/local/share/fonts/TrueType/Hanziku/hzkbu.ttf" + char (or (decode-char '=big5-pua code-point) + (decode-char '=ucs + (www-glyph-big5-to-ucs-pua code-point))) + png-file (format "/opt/chisewiki/glyphs/%d/Hanziku-11/%04X.png" + size code-point)) + ) + ((eq ccs '=hanziku-12) + (setq font "/usr/local/share/fonts/TrueType/Hanziku/hzkcu.ttf" + char (or (decode-char '=big5-pua code-point) + (decode-char '=ucs + (www-glyph-big5-to-ucs-pua code-point))) + png-file (format "/opt/chisewiki/glyphs/%d/Hanziku-12/%04X.png" + size code-point)) + ) ((eq ccs '=ruimoku-v6) (setq font "/usr/local/share/fonts/TrueType/Zinbun/rui6-eudc.ttf" char (decode-char '=ucs code-point) @@ -122,6 +248,15 @@ (string-to-int (match-string 1 char-rep) 16) size) ) + ((string-match + "^HZK\\(0[1-9]\\|1[0-2]\\)-\\([0-9A-F]+\\)" + char-rep) + (www-glyph-generate-png + (intern (format "=hanziku-%d" + (string-to-int (match-string 1 char-rep)))) + (string-to-int (match-string 2 char-rep) 16) + size) + ) ((string-match "^RUI6-\\([0-9A-F]+\\)" char-rep) (www-glyph-generate-png '=ruimoku-v6