+ Changer dummy = mi.base.changeEnsureMath();
+ Dimension dimr;
+ if (root) {
+ Changer script = mi.base.font.changeStyle(LM_ST_SCRIPTSCRIPT);
+ // make sure that the dim is high enough for any character
+ root->metrics(mi, dimr, false);
+ }
+
+ Dimension dimn;
+ nucleus.metrics(mi, dimn);
+
+ // Some room for the decoration
+ // The width of left decoration was 9 pixels with a 10em font
+ int const w = 9 * mathed_font_em(mi.base.font) / 10;
+ /* See rule 11 in Appendix G of Rhe TeXbook for the computation of the spacing
+ * above nucleus.
+ * FIXME more work is needed to implement properly rule 11.
+ * * Ideally, we should use sqrt glyphs from the math fonts. Note
+ that then we would get rule thickness from there.
+ * * The positioning of the root MathData is arbitrary. It should
+ * follow the definition of \root...\of... in The Texbook in
+ * Apprendix B page 360.
+ *
+ */
+ int const t = mi.base.solidLineThickness();
+ int const x_height = mathed_font_x_height(mi.base.font);
+ int const phi = (mi.base.font.style() == LM_ST_DISPLAY) ? x_height : t;
+ // first part is the spacing, second part is the line width
+ // itself, and last one is the spacing above.
+ int const space_above = (t + phi / 4) + t + t;
+ int const a = dimn.ascent();
+ int const d = dimn.descent();
+ // Not sure what the 1 stands for, it is needed to have some spacing at small sizes.
+ dim.asc = max(dimr.ascent() + (d - a) / 2, a + space_above) + 1;
+ dim.des = max(dimr.descent() - (d - a) / 2, d);
+ dim.wid = max(dimr.width() + 3 * w / 8, w) + dimn.width();