commit b951c48fca62ef7dbe36f8691f5a6c418afe033a
parent e9ed7ce065fcb72b02db1879837dd60297f307c1
Author: Matthew Flatt <mflatt@racket-lang.org>
Date: Fri, 2 Nov 2012 06:51:20 -0600
Scribble PDF/Latex: Hangul support
original commit: 008f476210498537dc4e6812b154aadb9cf4e864
Diffstat:
2 files changed, 32 insertions(+), 27 deletions(-)
diff --git a/collects/scribble/latex-render.rkt b/collects/scribble/latex-render.rkt
@@ -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)))))))
diff --git a/collects/scribble/scribble.tex b/collects/scribble/scribble.tex
@@ -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: