1 (require 'cwiki-common)
3 (setq file-name-coding-system 'utf-8-jp)
5 (defun www-glyph-generate-png (ccs code-point &optional size)
8 (let (png-file dir font char ret plain)
11 (setq char (decode-char '=gt code-point)
12 png-file (format "/opt/chisewiki/glyphs/%d/GT/%05d.png"
15 (while (and (<= plain 11)
17 (setq ret (encode-char
19 (intern (format "=gt-pj-%d" plain))))))
20 (setq plain (1+ plain)))
22 "/usr/local/share/fonts/TrueType/GT/gt2000%02d.ttf"
24 char (decode-char '=jis-x0208@1990 ret))
25 (when (setq ret (encode-char char '=ucs@jis/1990))
26 (setq char (decode-char '=ucs ret)))
29 (setq char (decode-char '=gt-k code-point)
30 png-file (format "/opt/chisewiki/glyphs/%d/GT-K/%05d.png"
33 (while (and (<= plain 11)
35 (setq ret (encode-char
37 (intern (format "=gt-pj-k%d" plain))))))
38 (setq plain (1+ plain)))
40 "/usr/local/share/fonts/TrueType/GT/gt2000k%d.ttf"
42 char (decode-char '=jis-x0208@1990 ret))
43 (when (setq ret (encode-char char '=ucs@jis/1990))
44 (setq char (decode-char '=ucs ret)))
47 (setq font "/usr/local/share/fonts/TrueType/Arphic/bsmi00lp.ttf"
48 char (decode-char '=big5 code-point)
49 png-file (format "/opt/chisewiki/glyphs/%d/Big5/%04X.png"
51 (when (setq ret (or (encode-char char '=ucs@big5)
53 (setq char (decode-char '=ucs ret)))
56 (setq font "/usr/local/share/fonts/TrueType/CDP/Cdpeudc.ttf"
57 char (decode-char '=big5-pua code-point)
58 png-file (format "/opt/chisewiki/glyphs/%d/CDP/%04X.png"
61 ((eq ccs '=ruimoku-v6)
62 (setq font "/usr/local/share/fonts/TrueType/Zinbun/rui6-eudc.ttf"
63 char (decode-char '=ucs code-point)
64 png-file (format "/opt/chisewiki/glyphs/%d/Ruimoku-v6/%04X.png"
70 "-size" (format "%dx%d" size size)
72 (concat "label:" (char-to-string char))
74 (setq dir (file-name-directory png-file))
75 (unless (file-exists-p dir)
76 (make-directory dir t))
81 (defun www-glyph-display-png (char-rep &optional size)
83 (setq size (string-to-int size)))
86 ((string-match "^GT-\\([0-9]+\\)" char-rep)
87 (www-glyph-generate-png
89 (string-to-int (match-string 1 char-rep))
92 ((string-match "^GT-K\\([0-9]+\\)" char-rep)
93 (www-glyph-generate-png
95 (string-to-int (match-string 1 char-rep))
98 ((string-match "^B-\\([0-9A-F]+\\)" char-rep)
99 (www-glyph-generate-png
101 (string-to-int (match-string 1 char-rep) 16)
104 ((string-match "^CDP-\\([0-9A-F]+\\)" char-rep)
105 (www-glyph-generate-png
107 (string-to-int (match-string 1 char-rep) 16)
110 ((string-match "^RUI6-\\([0-9A-F]+\\)" char-rep)
111 (www-glyph-generate-png
113 (string-to-int (match-string 1 char-rep) 16)
118 (princ (format "Content-Type: %s"
123 "-b" "--mime" png-file)
125 (let ((coding-system-for-read 'binary)
126 (coding-system-for-write 'binary))
127 (insert-file-contents-literally png-file))
128 (buffer-string)))))))
130 (defun www-batch-display-glyph ()
131 (setq terminal-coding-system 'binary)
133 (let* ((target (pop command-line-args-left))
134 ;; (user (pop command-line-args-left))
135 ;; (accept-language (pop command-line-args-left))
138 ;; (car (split-string
139 ;; (car (split-string
140 ;; (car (split-string accept-language ","))
147 (mapcar (lambda (cell)
148 (if (string-match "=" cell)
152 (substring cell 0 (match-beginning 0))
154 (substring cell (match-end 0)))
155 (list (decode-uri-string cell 'utf-8-mcs-er))))
156 (split-string target "&")))
157 (setq ret (car target))
158 (cond ((eq (car ret) 'char)
159 (www-glyph-display-png
161 (cdr (assq 'size target)))
166 (princ (format "%S" err)))