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"
64 "-size" (format "%dx%d" size size)
66 (concat "label:" (char-to-string char))
68 (setq dir (file-name-directory png-file))
69 (unless (file-exists-p dir)
70 (make-directory dir t))
75 (defun www-glyph-display-png (char-rep &optional size)
77 (setq size (string-to-int size)))
80 ((string-match "^GT-\\([0-9]+\\)" char-rep)
81 (www-glyph-generate-png
83 (string-to-int (match-string 1 char-rep))
86 ((string-match "^GT-K\\([0-9]+\\)" char-rep)
87 (www-glyph-generate-png
89 (string-to-int (match-string 1 char-rep))
92 ((string-match "^B-\\([0-9A-F]+\\)" char-rep)
93 (www-glyph-generate-png
95 (string-to-int (match-string 1 char-rep) 16)
98 ((string-match "^CDP-\\([0-9A-F]+\\)" char-rep)
99 (www-glyph-generate-png
101 (string-to-int (match-string 1 char-rep) 16)
106 (princ (format "Content-Type: %s"
111 "-b" "--mime" png-file)
113 (let ((coding-system-for-read 'binary)
114 (coding-system-for-write 'binary))
115 (insert-file-contents-literally png-file))
116 (buffer-string)))))))
118 (defun www-batch-display-glyph ()
119 (setq terminal-coding-system 'binary)
121 (let* ((target (pop command-line-args-left))
122 ;; (user (pop command-line-args-left))
123 ;; (accept-language (pop command-line-args-left))
126 ;; (car (split-string
127 ;; (car (split-string
128 ;; (car (split-string accept-language ","))
135 (mapcar (lambda (cell)
136 (if (string-match "=" cell)
140 (substring cell 0 (match-beginning 0))
142 (substring cell (match-end 0)))
143 (list (decode-uri-string cell 'utf-8-mcs-er))))
144 (split-string target "&")))
145 (setq ret (car target))
146 (cond ((eq (car ret) 'char)
147 (www-glyph-display-png
149 (cdr (assq 'size target)))
154 (princ (format "%S" err)))