Пример #1
0
        private void MeasureLimits(MathNode node, MathNode underscript, MathNode overscript)
        {
            if (node.Children[0].Core.MoveLimits)
            {
                List<MathNode> subs = new List<MathNode>();
                List<MathNode> supers = new List<MathNode>();
                if (underscript != null)
                    subs.Add(underscript);
                if (overscript != null)
                    supers.Add(overscript);
                MeasureScripts(node, subs, supers);
                return;
            }

            node.UnderScript = underscript;
            node.OverScript = overscript;
            SetNodeBase(node, node.Children[0]);

            node.Width = node.Base.Width;
            if (overscript != null)
                node.Width = Math.Max(node.Width, overscript.Width);

            if (underscript != null)
                node.Width = Math.Max(node.Width, underscript.Width);

            Stretch(node.Base, node.Width, null, null);
            Stretch(overscript, node.Width, null, null);
            Stretch(underscript, node.Width, null, null);

            double gap = node.NominalLineGap();

            if (overscript != null)
            {
                double overscriptBaselineHeight = node.Base.Height + gap + overscript.Depth;
                node.Height = overscriptBaselineHeight + overscript.Height;
                node.Ascender = node.Height;
            }
            else
            {
                node.Height = node.Base.Height;
                node.Ascender = node.Base.Ascender;
            }
            if (underscript != null)
            {
                double underscriptBaselineDepth = node.Base.Depth + gap + underscript.Height;
                node.Depth = underscriptBaselineDepth + underscript.Depth;
                node.Descender = node.Depth;
            }
            else
            {
                node.Depth = node.Base.Depth;
                node.Descender = node.Base.Descender;
            }
        }
Пример #2
0
        private void AddRadicalEnclosure(MathNode node)
        {
            // The below is full of heuristics
            node.LineWidth = node.NominalThinStrokeWidth();
            node.ThickLineWidth = node.NominalThickStrokeWidth();
            node.Gap = node.NominalLineGap();
            if (!node.DisplayStyle)
                node.Gap /= 2; // more compact style if inline

            node.RootHeight = Math.Max(node.Base.Height, node.Base.Ascender);
            node.RootHeight = Math.Max(node.RootHeight, node.NominalAscender());
            node.RootHeight += node.Gap + node.LineWidth;
            node.Height = node.RootHeight;

            node.AlignToAxis = node.Base.AlignToAxis;
            // Root extends to baseline for elements aligned on the baseline,
            // and to the bottom for elements aligned on the axis. An extra
            // line width is added to the depth, to account for radical sign 
            // protruding below the baseline.
            if (node.AlignToAxis)
            {
                node.RootDepth = Math.Max(0, node.Base.Depth - node.LineWidth);
                node.Depth = Math.Max(node.Base.Depth, node.RootDepth + node.LineWidth);
            }
            else
            {
                node.RootDepth = 0;
                node.Depth = Math.Max(node.Base.Depth, node.LineWidth);
            }
            node.RootWidth = (node.RootHeight + node.RootDepth) * 0.6;
            node.CornerWidth = node.RootWidth * 0.9 - node.Gap - node.LineWidth / 2;
            node.CornerHeight = (node.RootHeight + node.RootDepth) * 0.5 - node.Gap - node.LineWidth / 2;

            node.Width = node.Base.Width + node.RootWidth + 2 * node.Gap;
            node.Ascender = node.Height;
            node.Descender = node.Base.Descender;
            node.LeftSpace = node.LineWidth;
            node.RightSpace = node.LineWidth;
        }