From 6e37af1fe89316fa921539340fcce9af94e9e69d Mon Sep 17 00:00:00 2001 From: "Jacob S. Gordon" Date: Fri, 9 Jan 2026 16:22:00 -0500 Subject: [PATCH] ; calc: Correct width of rules composed of Unicode glyphs With higher values of 'calc-string-maximum-character', rules made up of glyphs of non-unit width can be the wrong length. Calculate the number of characters in the rule based on the display width, rounded up to the nearest integer. Refines feature introduced in bug#78528. * lisp/calc/calccomp.el (math-comp-simplify-term): Calculate rule width with a ratio of 'string-pixel-width's. --- lisp/calc/calccomp.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lisp/calc/calccomp.el b/lisp/calc/calccomp.el index 73a627f178c..86a2c405272 100644 --- a/lisp/calc/calccomp.el +++ b/lisp/calc/calccomp.el @@ -1558,8 +1558,12 @@ Not all brackets have midpieces.") (setq c (cdr c)) (while (setq c (cdr c)) (if (eq (car-safe (car c)) 'rule) - (math-comp-add-string (make-string maxwid (nth 1 (car c))) - math-comp-hpos math-comp-vpos) + (let* ((sep (nth 1 (car c))) + (rule-width (ceiling + (* maxwid (string-pixel-width "-")) + (string-pixel-width (char-to-string sep))))) + (math-comp-add-string (make-string rule-width sep) + math-comp-hpos math-comp-vpos)) (let ((math-comp-hpos (+ math-comp-hpos (/ (* bias (- maxwid (car widths))) 2))))