Scribble PDF/Latex: Hangul support

original commit: 008f476210498537dc4e6812b154aadb9cf4e864
This commit is contained in:
Matthew Flatt 2012-11-02 06:51:20 -06:00
parent e9ed7ce065
commit b951c48fca
2 changed files with 32 additions and 27 deletions

View File

@ -966,33 +966,37 @@
[(#\u207a) "$^+$"] [(#\u207a) "$^+$"]
[(#\u207b) "$^-$"] [(#\u207b) "$^-$"]
[else [else
;; Detect characters that can be formed with combining characters
;; and translate them to Latex combinations:
(define s (string-normalize-nfd (string c)))
(define len (string-length s))
(cond (cond
[(len . > . 1) [(char<=? #\uAC00 c #\uD7AF) ; Korean Hangul
(define combiner (case (string-ref s (sub1 len)) (format "\\begin{CJK}{UTF8}{mj}~a\\end{CJK}" c)]
[(#\u300) "\\`{~a}"] [else
[(#\u301) "\\'{~a}"] ;; Detect characters that can be formed with combining characters
[(#\u302) "\\^{~a}"] ;; and translate them to Latex combinations:
[(#\u303) "\\~~{~a}"] (define s (string-normalize-nfd (string c)))
[(#\u304) "\\={~a}"] (define len (string-length s))
[(#\u306) "\\u{~a}"] (cond
[(#\u307) "\\.{~a}"] [(len . > . 1)
[(#\u308) "\\\"{~a}"] (define combiner (case (string-ref s (sub1 len))
[(#\u30a) "\\r{~a}"] [(#\u300) "\\`{~a}"]
[(#\u30b) "\\H{~a}"] [(#\u301) "\\'{~a}"]
[(#\u30c) "\\v{~a}"] [(#\u302) "\\^{~a}"]
[(#\u327) "\\c{~a}"] [(#\u303) "\\~~{~a}"]
[(#\u328) "\\k{~a}"] [(#\u304) "\\={~a}"]
[else #f])) [(#\u306) "\\u{~a}"]
(define base (string-normalize-nfc (substring s 0 (sub1 len)))) [(#\u307) "\\.{~a}"]
(if (and combiner [(#\u308) "\\\"{~a}"]
(= 1 (string-length base))) [(#\u30a) "\\r{~a}"]
(format combiner (char-loop (string-ref base 0))) [(#\u30b) "\\H{~a}"]
c)] [(#\u30c) "\\v{~a}"]
[else c])]) [(#\u327) "\\c{~a}"]
[(#\u328) "\\k{~a}"]
[else #f]))
(define base (string-normalize-nfc (substring s 0 (sub1 len))))
(if (and combiner
(= 1 (string-length base)))
(format combiner (char-loop (string-ref base 0)))
c)]
[else c])])])
c)]))) c)])))
(loop (add1 i))))))) (loop (add1 i)))))))

View File

@ -11,7 +11,8 @@
\usepackage[htt]{hyphenat} \usepackage[htt]{hyphenat}
\usepackage[usenames,dvipsnames]{color} \usepackage[usenames,dvipsnames]{color}
\hypersetup{bookmarks=true,bookmarksopen=true,bookmarksnumbered=true} \hypersetup{bookmarks=true,bookmarksopen=true,bookmarksnumbered=true}
\IfFileExists{tocstyle.sty}{\usepackage{tocstyle}\usetocstyle{standard}} \IfFileExists{tocstyle.sty}{\usepackage{tocstyle}\usetocstyle{standard}}{}
\IfFileExists{CJK.sty}{\usepackage{CJK}}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Configuration that is especially meant to be overridden: % Configuration that is especially meant to be overridden: