The attached patch corrects an oversight in implementing rule 18a in
appendix G of the TeXbook. I attach a .lyx file demonstrating what the
problem is and three screenshots showing the appearance on screen before
and after the patch, as well as the dvi output.

I'll put it in later tonight unless I get objections.

I am aware that some other fine tuning is needed and, time permitting,
will take care of that in the near future.

-- 
Enrico
Index: src/mathed/InsetMathScript.C
===================================================================
--- src/mathed/InsetMathScript.C        (revisione 17506)
+++ src/mathed/InsetMathScript.C        (copia locale)
@@ -15,6 +15,7 @@
 #include "MathStream.h"
 #include "MathSupport.h"
 #include "InsetMathSymbol.h"
+#include "InsetMathFont.h"
 #include "dispatchresult.h"
 #include "cursor.h"
 #include "debug.h"
@@ -150,18 +151,28 @@ int InsetMathScript::dy01(int asc, int d
 {
        int dasc = 0;
        int slevel = 0;
+       MathAtom const & at = nuc().back();
+       bool isCharBox = at->asCharInset();
+       if (!isCharBox && at->asFontInset()) {
+               MathArray const & ar = at->asFontInset()->cell(0);
+               for (size_t i = 0; i < ar.size(); ++i) {
+                       isCharBox = ar[i]->asCharInset();
+                       if (!isCharBox)
+                               break;
+               }
+       }
        if (hasDown()) {
                dasc = down().ascent();
                slevel = nuc().slevel();
                int ascdrop = dasc - slevel;
-               int desdrop = des + nuc().sshift();
+               int desdrop = isCharBox ? 0 : des + nuc().sshift();
                int mindes = nuc().mindes();
                des = max(desdrop, ascdrop);
                des = max(mindes, des);
        }
        if (hasUp()) {
                int minasc = nuc().minasc();
-               int ascdrop = asc - up().mindes();
+               int ascdrop = isCharBox ? 0 : asc - up().mindes();
                int udes = up().descent();
                asc = udes + nuc().sshift();
                asc = max(ascdrop, asc);
Index: src/mathed/MathData.C
===================================================================
--- src/mathed/MathData.C       (revisione 17506)
+++ src/mathed/MathData.C       (copia locale)
@@ -242,8 +242,11 @@ bool isInside(DocIterator const & it, Ma
 
 void MathArray::metrics(MetricsInfo & mi) const
 {
-       dim_ = theFontMetrics(mi.base.font).dimension('I');
-       int xascent = theFontMetrics(mi.base.font).dimension('x').ascent();
+       frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
+       dim_ = fm.dimension('I');
+       int xascent = fm.dimension('x').ascent();
+       if (xascent >= dim_.asc)
+               xascent = (2 * dim_.asc) / 3;
        minasc_ = xascent;
        mindes_ = (3 * xascent) / 4;
        slevel_ = (4 * xascent) / 5;

Attachment: test.lyx
Description: application/lyx

Attachment: test_before.png
Description: PNG image

Attachment: test_after.png
Description: PNG image

Attachment: test_dvi.png
Description: PNG image

Reply via email to