TeX \mathXY folding, account for deceptive codepts

This commit is contained in:
TEC 2020-10-17 15:46:57 +08:00
parent 3f5e109a37
commit 8c8d40dafd
1 changed files with 44 additions and 1 deletions

View File

@ -6478,7 +6478,50 @@ Let's enhance ~TeX-fold-math~ a bit
(defun string-offset-roman-chars (offset word)
"Shift the codepoint of each charachter in WORD by OFFSET with an extra -6 shift if the letter is lowercase"
(apply 'string
(mapcar (lambda (c) (+ (if (>= c 97) (- c 6) c) offset)) word)))
(mapcar (lambda (c)
(string-offset-apply-roman-char-exceptions
(+ (if (>= c 97) (- c 6) c) offset)))
word)))
(defvar string-offset-roman-char-exceptions
'(;; lowercase serif
(119892 . 8462) ;
;; lowercase caligraphic
(119994 . 8495) ;
(119996 . 8458) ;
(120004 . 8500) ;
;; caligraphic
(119965 . 8492) ;
(119968 . 8496) ;
(119969 . 8497) ;
(119971 . 8459) ;
(119972 . 8464) ;
(119975 . 8466) ;
(119976 . 8499) ;
(119981 . 8475) ;
;; fraktur
(120070 . 8493) ;
(120075 . 8460) ;
(120076 . 8465) ;
(120085 . 8476) ;
(120092 . 8488) ;
;; blackboard
(120122 . 8450) ;
(120127 . 8461) ;
(120133 . 8469) ;
(120135 . 8473) ;
(120136 . 8474) ;
(120137 . 8477) ;
(120145 . 8484) ;
)
"An alist of deceptive codepoints, and then where the glyph actually resides.")
(defun string-offset-apply-roman-char-exceptions (char)
"Sometimes the codepoint doesn't contain the char you expect.
Such special cases should be remapped to another value, as given in `string-offset-roman-char-exceptions'."
(if (assoc char string-offset-roman-char-exceptions)
(cdr (assoc char string-offset-roman-char-exceptions))
char))
(defun TeX-fold-parenthesize-as-neccesary (tokens &optional suppress-left suppress-right)
"Add ❪ ❫ parenthesis as if multiple LaTeX tokens appear to be present"