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) "$^+$"]
[(#\u207b) "$^-$"]
[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
[(len . > . 1)
(define combiner (case (string-ref s (sub1 len))
[(#\u300) "\\`{~a}"]
[(#\u301) "\\'{~a}"]
[(#\u302) "\\^{~a}"]
[(#\u303) "\\~~{~a}"]
[(#\u304) "\\={~a}"]
[(#\u306) "\\u{~a}"]
[(#\u307) "\\.{~a}"]
[(#\u308) "\\\"{~a}"]
[(#\u30a) "\\r{~a}"]
[(#\u30b) "\\H{~a}"]
[(#\u30c) "\\v{~a}"]
[(#\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])])
[(char<=? #\uAC00 c #\uD7AF) ; Korean Hangul
(format "\\begin{CJK}{UTF8}{mj}~a\\end{CJK}" c)]
[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
[(len . > . 1)
(define combiner (case (string-ref s (sub1 len))
[(#\u300) "\\`{~a}"]
[(#\u301) "\\'{~a}"]
[(#\u302) "\\^{~a}"]
[(#\u303) "\\~~{~a}"]
[(#\u304) "\\={~a}"]
[(#\u306) "\\u{~a}"]
[(#\u307) "\\.{~a}"]
[(#\u308) "\\\"{~a}"]
[(#\u30a) "\\r{~a}"]
[(#\u30b) "\\H{~a}"]
[(#\u30c) "\\v{~a}"]
[(#\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)])))
(loop (add1 i)))))))

View File

@ -11,7 +11,8 @@
\usepackage[htt]{hyphenat}
\usepackage[usenames,dvipsnames]{color}
\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: