From b233ca80e939c939633b37c41398eb1bb12cb4e9 Mon Sep 17 00:00:00 2001 From: "Jacob S. Gordon" Date: Fri, 9 Jan 2026 16:21:00 -0500 Subject: [PATCH] ; calc: Improve alignment for Unicode strings With higher values of 'calc-string-maximum-character' the string length can differ from the displayed width. Calculate alignment offsets based on the the display width, rounded up to the nearest integer. Refines feature introduced in bug#78528. * lisp/calc/calccomp.el (math-comp-width): Replace 'length' with a ratio of 'string-pixel-width's. --- lisp/calc/calccomp.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/calc/calccomp.el b/lisp/calc/calccomp.el index a59ad82aa57..73a627f178c 100644 --- a/lisp/calc/calccomp.el +++ b/lisp/calc/calccomp.el @@ -1656,7 +1656,11 @@ Not all brackets have midpieces.") ((memq (car c) '(set break)) t))) (defun math-comp-width (c) - (cond ((not (consp c)) (length c)) + (cond ((not (consp c)) + (or (and (stringp c) + (ceiling (string-pixel-width c) + (string-pixel-width "-"))) + (length c))) ((memq (car c) '(horiz subscr supscr)) (let ((accum 0)) (while (setq c (cdr c))