]> git.eshelyaron.com Git - emacs.git/commitdiff
Unicode integrals in Calc
authorMattias Engdegård <mattiase@acm.org>
Sun, 6 Dec 2020 10:07:33 +0000 (11:07 +0100)
committerMattias Engdegård <mattiase@acm.org>
Sun, 6 Dec 2020 12:11:18 +0000 (13:11 +0100)
* lisp/calc/calccomp.el (math-compose-integ): Use Unicode integral
signs when available instead of a crude ASCII approximation, with a
shorter stem to save space.

lisp/calc/calccomp.el

index e4f6e989ecf256e974b45d8e55bbe1c4895948c0..0631eb48f9ff5e2c910499bb03050c61b2562c12 100644 (file)
                                         (nth 1 a)) 185))
              (calc-language 'flat)
              (low (and (nth 3 a) (math-compose-expr (nth 3 a) 0)))
-             (high (and (nth 4 a) (math-compose-expr (nth 4 a) 0))))
+             (high (and (nth 4 a) (math-compose-expr (nth 4 a) 0)))
+              ;; Check if we have Unicode integral top/bottom parts.
+              (fancy (and (char-displayable-p ?⌠)
+                          (char-displayable-p ?⌡)))
+              ;; If we do, find the most suitable middle part.
+              (fancy-stem (cond ((not fancy))
+                                ;; U+23AE INTEGRAL EXTENSION
+                                ((char-displayable-p ?⎮) "⎮ ")
+                                ;; U+2502 BOX DRAWINGS LIGHT VERTICAL
+                                ((char-displayable-p ?│) "│ ")
+                                ;; U+007C VERTICAL LINE
+                                (t "| "))))
         (list 'horiz
               (if parens "(" "")
-              (append (list 'vcent (if high 3 2))
-                      (and high (list (list 'horiz "  " high)))
-                      '("  /"
-                        " | "
-                        " | "
-                        " | "
-                        "/  ")
-                      (and low (list (list 'horiz low "  "))))
+              (append (list 'vcent (if fancy
+                                        (if high 2 1)
+                                      (if high 3 2)))
+                      (and high (list (if fancy
+                                           (list 'horiz high " ")
+                                         (list 'horiz "  " high))))
+                       (if fancy
+                           (list "⌠ " fancy-stem "⌡ ")
+                        '("  /"
+                          " | "
+                          " | "
+                          " | "
+                          "/  "))
+                      (and low (list (if fancy
+                                          (list 'horiz low " ")
+                                        (list 'horiz low "  ")))))
               expr
               (if over
                   ""