+;; (let (gt ret)
+;; (dolist (ccs '(=gt-pj-1
+;; =gt-pj-2
+;; =gt-pj-3
+;; =gt-pj-4
+;; =gt-pj-5
+;; =gt-pj-6
+;; =gt-pj-7
+;; =gt-pj-8
+;; =gt-pj-9
+;; =gt-pj-10
+;; =gt-pj-11))
+;; (map-char-attribute
+;; (lambda (c v)
+;; (when (setq gt (encode-char c '=gt))
+;; (put-char-attribute c '=gt gt)
+;; (put-char-attribute (decode-char ccs v) '=gt gt))
+;; nil)
+;; ccs)))
+
+;; (let (ret)
+;; (dolist (feature
+;; (let (dest)
+;; (dolist (feature (char-attribute-list))
+;; (when (string-match "\\*sources\\($\\|@[^\\*]+$\\)"
+;; (symbol-name feature))
+;; (setq dest (cons feature dest))))
+;; dest))
+;; (map-char-attribute
+;; (lambda (c v)
+;; (when (setq ret (memq 'shinjigen-1 v))
+;; (setcar ret 'shinjigen@1ed))
+;; (when (setq ret (memq 'shinjigen-2 v))
+;; (setcar ret 'shinjigen@rev))
+;; nil)
+;; feature)))
+
+;; (map-char-attribute
+;; (lambda (c v)
+;; (when (eq (encode-char c '=shinjigen@rev) v)
+;; (put-char-attribute c '=shinjigen v)
+;; (remove-char-attribute c '=shinjigen@1ed)
+;; (remove-char-attribute c '=shinjigen@rev)
+;; )
+;; nil)
+;; '=shinjigen@1ed)
+
+;; (let (ret)
+;; (dolist (feature
+;; (let (dest)
+;; (dolist (feature (char-attribute-list))
+;; (when (string-match "\\*sources\\($\\|@[^\\*]+$\\)"
+;; (symbol-name feature))
+;; (setq dest (cons feature dest))))
+;; dest))
+;; (map-char-attribute
+;; (lambda (c v)
+;; (cond ((setq ret (memq 'shinjigen@1ed v))
+;; (when (memq 'shinjigen@rev ret)
+;; (setcar ret 'shinjigen)
+;; (delq 'shinjigen@rev ret)
+;; ))
+;; ((setq ret (memq 'shinjigen@rev v))
+;; (when (memq 'shinjigen@1ed ret)
+;; (setcar ret 'shinjigen)
+;; (delq 'shinjigen@1ed ret)
+;; )))
+;; nil)
+;; feature)))
+
+(dolist (ccs '(=jis-x0208 =jis-x0208@1990))
+ (map-char-attribute
+ (lambda (c v)
+ (unless (eq (encode-char c '=jis-x0213-1@2000) v)
+ (put-char-attribute c '=jis-x0213-1 v))
+ nil)
+ ccs))
+
+(with-temp-buffer
+ (buffer-disable-undo)
+ (insert-file-contents "../etc/char-data/JX3-JX1-rep-diff.txt")
+ (goto-char (point-min))
+ (let (ku ten char code ucs rep-char)
+ (while (re-search-forward "^1-\\([0-9]+\\)-\\([0-9]+\\)[ \t]+" nil t)
+ (setq ku (string-to-number (match-string 1))
+ ten (string-to-number (match-string 2)))
+ (setq char (make-char '=jis-x0213-1@2000 (+ ku 32)(+ ten 32)))
+ (setq code (encode-char char '=jis-x0213-1@2000))
+ (setq ucs (encode-char char '=ucs@jis/2000))
+ (setq rep-char (decode-char '==jis-x0213-1@2000 code))
+ (cond
+ ((or (eq char rep-char)
+ (null rep-char))
+ (put-char-attribute char '=jis-x0213-1@2000 code)
+ (remove-char-attribute char '=jis-x0213-1)
+ (remove-char-attribute char '=jis-x0213-1@2004)
+ (remove-char-attribute char '=ucs@jis)
+ (remove-char-attribute char '=ucs@jis/2004)
+ (when (setq char (decode-char '=jis-x0213-1@2004 code))
+ (unless (eq (encode-char char '=ucs@jis/2004) ucs)
+ (put-char-attribute char '=ucs@jis/2004 ucs)))
+ )
+ (rep-char
+ (unless (and (= ku 47)(= ten 64))
+ (put-char-attribute rep-char '==jis-x0213-1@2000 code)
+ (remove-char-attribute rep-char '==jis-x0213-1)
+ (remove-char-attribute rep-char '==jis-x0213-1@2004)
+ (setq ucs (or (encode-char rep-char '==ucs@jis/2000)
+ ucs))
+ (remove-char-attribute rep-char '==ucs@jis)
+ (remove-char-attribute rep-char '==ucs@jis/2004))
+ (when (setq rep-char (decode-char '==jis-x0213-1@2004 code))
+ (unless (eq (encode-char rep-char '==ucs@jis/2004) ucs)
+ (put-char-attribute rep-char '==ucs@jis/2004 ucs)))
+ ))
+ (unless (eq code #x332A)
+ (when (setq char (decode-char '=>jis-x0208@1997 code 'defined-only))
+ (unless (eq (encode-char char '=>>jis-x0208) code)
+ (unless (eq (encode-char char '=+>jis-x0208) code)
+ (put-char-attribute char '=>jis-x0208 code)
+ (remove-char-attribute char '=>jis-x0208@1997)))))
+ )))
+
+(map-char-attribute
+ (lambda (c v)
+ (unless (eq (encode-char c '=>jis-x0213-1) v)
+ (put-char-attribute c '=>jis-x0213-1 v))
+ nil)
+ '=>jis-x0208)
+
+(let (dg-chr)
+ (map-char-attribute
+ (lambda (c v)
+ (when (setq dg-chr (decode-char '===jis-x0212 v))
+ (unless (eq c dg-chr)
+ (put-char-attribute dg-chr '===hanyo-denshi/jb v)))
+ nil)
+ '==hanyo-denshi/jb)
+ (map-char-attribute
+ (lambda (c v)
+ (when (setq dg-chr (decode-char '===jis-x0213-1@2000 v))
+ (unless (eq c dg-chr)
+ (put-char-attribute dg-chr '===hanyo-denshi/jc v)))
+ nil)
+ '==hanyo-denshi/jc)
+ (map-char-attribute
+ (lambda (c v)
+ (when (setq dg-chr (decode-char '===jis-x0213-2 v))
+ (unless (eq c dg-chr)
+ (put-char-attribute dg-chr '===hanyo-denshi/jd v)))
+ nil)
+ '==hanyo-denshi/jd)
+ )
+
+(let (j-chr)
+ (map-char-attribute
+ (lambda (c v)
+ (if (and (setq j-chr (decode-char '=ucs@JP v))
+ (not (eq j-chr c))
+ (null (encode-char c '=ucs)))
+ (put-char-attribute c '=ucs@JP/hanazono nil))
+ nil)
+ '=ucs@unicode)
+ (map-char-attribute
+ (lambda (c v)
+ (if (and (setq j-chr (decode-char '==ucs@JP v))
+ (not (eq j-chr c)))
+ (put-char-attribute c '==ucs@JP/hanazono nil))
+ nil)
+ '==ucs@unicode)
+ )
+
+(defun glyph-form-feature-to-glyph-image-char-spec (dg-fn
+ code-point
+ &optional
+ rep-gi-fn dg-char)
+ (unless rep-gi-fn
+ (setq rep-gi-fn (intern (format "=%s" dg-fn))))
+ (unless dg-char
+ (setq dg-char (decode-char dg-fn code-point)))
+ (let (code)
+ (when (find-charset rep-gi-fn)
+ (cons (cons rep-gi-fn code-point)
+ (cond
+ ((eq dg-fn '==gt)
+ (if (setq code (encode-char dg-char '==gt-k))
+ (list (cons '===gt-k code)))
+ )
+ ((eq dg-fn '==hanyo-denshi/jc)
+ (cond ((encode-char dg-char '==jis-x0213-1)
+ (list (cons '===jis-x0213-1 code-point))
+ )
+ ((encode-char dg-char '==jis-x0213-1@2000)
+ (list (cons '===jis-x0213-1@2000 code-point))
+ ))
+ )
+ ((eq dg-fn '==hanyo-denshi/jd)
+ (list (cons '===jis-x0213-2 code-point))
+ )
+ ((eq dg-fn '==jis-x0208)
+ (cond ((encode-char dg-char '==jis-x0213-1)
+ (list (cons '===jis-x0213-1 code-point))
+ )
+ ((encode-char dg-char '==jis-x0213-1@2000)
+ (list (cons '===jis-x0213-1@2000 code-point))
+ ))
+ )
+ ((eq dg-fn '==ks-x1001)
+ (if (setq code (encode-char dg-char '==ucs@ks))
+ (list (cons '===ucs@ks code)))
+ ))))))
+
+(let (dest rep-gi-fn rep-gi spec target-dg-fns)
+ (dolist (fn (char-attribute-list))
+ (when (and (find-charset fn)
+ (string-match "^==[^*=>]+$" (symbol-name fn)))
+ (setq dest (cons fn dest))))
+ (setq dest (sort dest
+ (lambda (a b)
+ (cond ((eq a '==daikanwa)
+ t)
+ ((eq a '==daikanwa/+p)
+ t)
+ ((eq a '==daikanwa/ho)
+ t)
+ ((eq a '==jis-x0208)
+ (cond ((memq b '(==daikanwa
+ ==daikanwa/+p ==daikanwa/ho))
+ nil)
+ (t)))
+ ((eq a '==jis-x0208@1978)
+ (cond ((memq b '(==daikanwa
+ ==daikanwa/+p ==daikanwa/ho
+ ==jis-x0208))
+ nil)
+ (t)))
+ ((eq a '==jis-x0208@1983)
+ (cond ((memq b '(==daikanwa
+ ==daikanwa/+p ==daikanwa/ho
+ ==jis-x0208
+ ==jis-x0208@1978))
+ nil)
+ (t)))
+ ((eq a '==jis-x0208@1990)
+ (cond ((memq b '(==daikanwa
+ ==daikanwa/+p ==daikanwa/ho
+ ==jis-x0208
+ ==jis-x0208@1978
+ ==jis-x0208@1983))
+ nil)
+ (t)))
+ ((eq a '==jis-x0212)
+ (cond ((memq b '(==daikanwa
+ ==daikanwa/+p ==daikanwa/ho
+ ==jis-x0208
+ ==jis-x0208@1978
+ ==jis-x0208@1983 ==jis-x0208@1990))
+ nil)
+ (t)))
+ ((eq a '==jis-x0213-1)
+ (cond ((memq b '(==daikanwa
+ ==daikanwa/+p ==daikanwa/ho
+ ==jis-x0208
+ ==jis-x0208@1978
+ ==jis-x0208@1983 ==jis-x0208@1990
+ ==jis-x0212))
+ nil)
+ (t)))
+ ((eq a '==jis-x0213-2)
+ (cond ((memq b '(==daikanwa
+ ==daikanwa/+p ==daikanwa/ho
+ ==jis-x0208
+ ==jis-x0208@1978
+ ==jis-x0208@1983 ==jis-x0208@1990
+ ==jis-x0212 ==jis-x0213-1))
+ nil)
+ (t)))
+ (t
+ (cond ((memq b '(==daikanwa
+ ==daikanwa/+p ==daikanwa/ho
+ ==jis-x0208
+ ==jis-x0208@1978
+ ==jis-x0208@1983 ==jis-x0208@1990
+ ==jis-x0212
+ ==jis-x0213-1 ==jis-x0213-2))
+ nil)
+ (t
+ (string< (symbol-name a)(symbol-name b)))))))))
+ (dolist (dg-fn dest)
+ (setq rep-gi-fn (intern (format "=%s" dg-fn)))
+ (when (find-charset rep-gi-fn)
+ (map-char-attribute
+ (lambda (c v)
+ (setq rep-gi (decode-char rep-gi-fn v))
+ (unless (or (and (eq dg-fn '==jis-x0208)
+ (eq (get-char-attribute
+ (decode-char '===jis-x0208@1990 v)
+ '===jis-x0208@1990)
+ v))
+ (and (eq dg-fn '==jis-x0213-1)
+ (eq (get-char-attribute
+ (decode-char '===jis-x0213-1@2000 v)
+ '===jis-x0213-1@2000)
+ v))
+ (and rep-gi
+ (not (eq c rep-gi))))
+ (if (get-char-attribute c '->subsumptive)
+ (if (setq rep-gi
+ (define-char
+ (glyph-form-feature-to-glyph-image-char-spec
+ dg-fn v rep-gi-fn c)
+ ;; (list (cons rep-gi-fn v))
+ ))
+ (put-char-attribute rep-gi '<-subsumptive (list c)))
+ (setq spec (char-attribute-alist c))
+ (setq target-dg-fns nil)
+ (dolist (fp spec)
+ (unless (memq (car fp)
+ '(==ks-x1001
+ ==hanyo-denshi/jb
+ ==hanyo-denshi/jc ==hanyo-denshi/jd
+ ==gt-k))
+ (when (find-charset (intern (format "=%s" (car fp))))
+ (setq target-dg-fns (cons (car fp) target-dg-fns)))))
+ (when (cdr target-dg-fns)
+ (setq rep-gi
+ (define-char
+ (glyph-form-feature-to-glyph-image-char-spec
+ dg-fn v rep-gi-fn c)))
+ (if rep-gi
+ (put-char-attribute rep-gi '<-subsumptive (list c))))))
+ nil)
+ dg-fn))))
+
+(let (chr ucs)
+ (map-char-attribute
+ (lambda (c v)
+ (when (and (setq chr (decode-char '=ks-x1001 v))
+ (setq ucs (encode-char chr '=ucs@ks)))
+ (put-char-attribute c '===ucs@ks ucs))
+ nil)
+ '===ks-x1001))