Sfoglia il codice sorgente

修大运算符的两处对齐

1) 下限压到字形上了
   上一版把上限往下拽 3px、下限往上拽 3px,是想对称收紧。但字形在行框里
   的墨迹**并不上下居中**(∑ 偏上、基线以下留白多),同样拽 3px 对上限
   正好、对下限就压过头了。下限不再上拽。

2) lim 下面箭头的终点没正对数字
   箭头那一行里 x 用的是 0.6 倍字号、数字用的是 0.5 倍。两个大小不同的框
   居中对齐,基线就错开了 —— 横着的箭头没法同时正对两端的 x 和数字。
   三个元素统一成 0.6 倍。

(未做真机复验,用户要求先只改。)

Co-Authored-By: Claude Code <noreply@anthropic.com>
nonvioce 4 settimane fa
parent
commit
7fafce69f8
1 ha cambiato i file con 8 aggiunte e 6 eliminazioni
  1. 8 6
      lib/expr_editor.dart

+ 8 - 6
lib/expr_editor.dart

@@ -419,11 +419,10 @@ class _NodeView extends StatelessWidget {
     final body = _slot(context, b.body, parent.push(index, 0));
     final variable = _slot(context, b.variable, parent.push(index, 1));
     // 上下限紧贴运算符:槽的上下内边距收掉,再往中间拽几像素
-    final lower = Transform.translate(
-      offset: const Offset(0, -3),
-      child: _slot(context, b.lower, parent.push(index, 2),
-          scale: 0.5, vpad: 0),
-    );
+    // 下限**不**上拽。字形在行框里的墨迹并不上下居中(∑ 偏上、基线以下留白多),
+    // 上下对称地拽同样的量,上限正好、下限就压到字形上了。
+    final lower = _slot(context, b.lower, parent.push(index, 2),
+        scale: 0.5, vpad: 0);
     final upper = Transform.translate(
       offset: const Offset(0, 3),
       child: _slot(context, b.upper, parent.push(index, 3),
@@ -432,13 +431,16 @@ class _NodeView extends StatelessWidget {
 
     if (b.kind == 'Limit') {
       // lim 下面写"x→0"
+      // 三个元素**必须同一个字号**:框大小不同时居中对齐会让基线错开,
+      // 横着的箭头就没法同时正对两端的 x 和数字。
       final under = Row(
         mainAxisSize: MainAxisSize.min,
         children: [
           _slot(context, b.variable, parent.push(index, 1),
               scale: 0.6, vpad: 0),
           Text('→', style: _mathStyle(context, 0.6).copyWith(height: 1.0)),
-          lower,
+          _slot(context, b.lower, parent.push(index, 2),
+              scale: 0.6, vpad: 0),
         ],
       );
       return _row([