Пример #1
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;
        }