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 font "/usr/local/share/fonts/TrueType/Arphic/bsmi00lp.ttf"
30 char (decode-char '=big5 code-point)
31 png-file (format "/opt/chisewiki/glyphs/%d/Big5/%04X.png"
33 (when (setq ret (or (encode-char char '=ucs@big5)
35 (setq char (decode-char '=ucs ret)))
38 (setq font "/usr/local/share/fonts/TrueType/CDP/Cdpeudc.ttf"
39 char (decode-char '=big5-pua code-point)
40 png-file (format "/opt/chisewiki/glyphs/%d/CDP/%04X.png"
46 "-size" (format "%dx%d" size size)
48 (concat "label:" (char-to-string char))
50 (setq dir (file-name-directory png-file))
51 (unless (file-exists-p dir)
52 (make-directory dir t))
57 (defun www-glyph-display-png (char-rep &optional size)
59 (setq size (string-to-int size)))
62 ((string-match "^GT-\\([0-9]+\\)" char-rep)
63 (www-glyph-generate-png
65 (string-to-int (match-string 1 char-rep))
68 ((string-match "^B-\\([0-9A-F]+\\)" char-rep)
69 (www-glyph-generate-png
71 (string-to-int (match-string 1 char-rep) 16)
74 ((string-match "^CDP-\\([0-9A-F]+\\)" char-rep)
75 (www-glyph-generate-png
77 (string-to-int (match-string 1 char-rep) 16)
82 (princ (format "Content-Type: %s"
87 "-b" "--mime" png-file)
89 (let ((coding-system-for-read 'binary)
90 (coding-system-for-write 'binary))
91 (insert-file-contents-literally png-file))
94 (defun www-batch-display-glyph ()
95 (setq terminal-coding-system 'binary)
97 (let* ((target (pop command-line-args-left))
98 ;; (user (pop command-line-args-left))
99 ;; (accept-language (pop command-line-args-left))
102 ;; (car (split-string
103 ;; (car (split-string
104 ;; (car (split-string accept-language ","))
111 (mapcar (lambda (cell)
112 (if (string-match "=" cell)
116 (substring cell 0 (match-beginning 0))
118 (substring cell (match-end 0)))
119 (list (decode-uri-string cell 'utf-8-mcs-er))))
120 (split-string target "&")))
121 (setq ret (car target))
122 (cond ((eq (car ret) 'char)
123 (www-glyph-display-png
125 (cdr (assq 'size target)))
130 (princ (format "%S" err)))