From f7f51ebffdffde36f306ab236676d075d9e28207 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Thu, 16 Nov 2023 11:03:46 -0600 Subject: [PATCH] add blackboard bold to Scribble's unicode->latex conversion related to racket/gui#319 --- scribble-lib/scribble/latex-render.rkt | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/scribble-lib/scribble/latex-render.rkt b/scribble-lib/scribble/latex-render.rkt index 8811ae19c3..db02c8593e 100644 --- a/scribble-lib/scribble/latex-render.rkt +++ b/scribble-lib/scribble/latex-render.rkt @@ -1093,6 +1093,7 @@ ;; first, try user-defined conversions (or (convs c) (convert-to-latex c) + (convert-bb-bold c) (cond [(char<=? #\uAC00 c #\uD7AF) ; Korean Hangul ;; This likely will not work right if it shows up in a section @@ -1293,6 +1294,37 @@ [(#\u328) "\\k{~a}"] [else #f])) + (define/private (convert-bb-bold c) + (define (mathbb c) (format "$\\mathbb{~a}$" c)) + (cond + [(char<=? #\𝕒 c #\𝕫) + (mathbb (+ (- (char->integer c) + (char->integer #\𝕒)) + (char->integer #\a)))] + [(and (char<=? #\𝔸 c #\𝕐) + ;; the blackboard bold C, H, N, P, Q, R, and Z + ;; are not in this range so handle them specially, below + (not (member c '(#\U0001D53A + #\U0001D53F + #\U0001D545 + #\U0001D547 + #\U0001D548 + #\U0001D549)))) + (mathbb (+ (- (char->integer c) + (char->integer #\𝔸)) + (char->integer #\A)))] + [else + (case c + [(#\U2102) (mathbb "C")] + [(#\U1D554) (mathbb "C")] + [(#\U210D) (mathbb "H")] + [(#\U2115) (mathbb "N")] + [(#\U2119) (mathbb "P")] + [(#\U211A) (mathbb "Q")] + [(#\U211D) (mathbb "R")] + [(#\U2124) (mathbb "Z")] + [else #f])])) + (define/private (convert-to-latex c) ;; latex-prefix.rkt enables utf8 input, but this does not work for ;; all the characters below (e.g. ∞). Some parts of the table