Exemplo n.º 1
0
 public CharBox(TexEnvironment environment, CharInfo charInfo)
     : base(environment)
 {
     this.Character = charInfo;
     this.Width     = charInfo.Metrics.Width;
     this.Height    = charInfo.Metrics.Height;
     this.Depth     = charInfo.Metrics.Depth;
     this.Italic    = charInfo.Metrics.Italic;
 }
Exemplo n.º 2
0
        protected override Box CreateBoxCore(TexEnvironment environment)
        {
            // TODO
            var resultBox = (Box)null; // DelimiterFactory.CreateBox(this.DelimeterAtom, this.Size, environment);

            resultBox.Shift = -(resultBox.Height + resultBox.Depth) / 2 -
                              environment.MathFont.GetAxisHeight(environment.Style);
            return(resultBox);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HorizontalRule"/>.
 /// </summary>
 public UpDiagonalRule(TexEnvironment environment, double thickness, double width, double height, double shift)
 {
     LineThickness   = thickness;
     this.Width      = width;
     this.Height     = height;
     this.Shift      = shift;
     this.Foreground = environment.Foreground;
     this.Background = environment.Background;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RoundedRectangleBox"/>.
 /// </summary>
 /// <param name="environment"></param>
 /// <param name="height"></param>
 /// <param name="width"></param>
 /// <param name="shift"></param>
 public RoundedRectangleBox(TexEnvironment environment, double height, double width, double shift, double xrad = 3, double yrad = 3)
 {
     this.Width      = width;
     this.Height     = height;
     this.Shift      = shift;
     x_radius        = xrad;
     y_radius        = yrad;
     this.Foreground = environment.Foreground;
     this.Background = environment.Background;   //Not strictly necessary
 }
Exemplo n.º 5
0
        protected override Box CreateBoxCore(TexEnvironment environment)
        {
            var columnCount = MatrixCells.Max(row => row.Count);

            var cells = MatrixCells.Select(row => CreateRowCellBoxes(environment, row).ToList()).ToList();

            var(rowHeights, columnWidths) = CalculateDimensions(cells, columnCount);
            var matrixCellGaps = CalculateCellGaps(cells, columnCount, rowHeights, columnWidths);

            return(ApplyCellPaddings(environment, cells, columnCount, matrixCellGaps));
        }
Exemplo n.º 6
0
        public Box CreateBox(TexEnvironment environment)
        {
            var box = this.CreateBoxCore(environment);

            if (box.Source == null)
            {
                box.Source = this.Source;
            }

            return(box);
        }
Exemplo n.º 7
0
        private Box Enclosure_underbar(TexEnvironment environment, Box morphbox)
        {
            var defaultLineThickness = environment.MathFont.GetDefaultLineThickness(environment.Style);

            var resultBox = new UnderBar(environment, morphbox, 3 * defaultLineThickness, defaultLineThickness)
            {
                Height = morphbox.Height + 5 * defaultLineThickness,
                Depth  = morphbox.Depth
            };

            return(resultBox);
        }
Exemplo n.º 8
0
        protected override Box CreateBoxCore(TexEnvironment environment)
        {
            var box = this.Atom.CreateBox(environment);

            // Centre box relative to horizontal axis.
            var totalHeight = box.Height + box.Depth;
            var axis        = environment.MathFont.GetAxisHeight(environment.Style);

            box.Shift = -(totalHeight / 2) - axis;

            return(new HorizontalBox(box));
        }
Exemplo n.º 9
0
        public override Box CreateBox(TexEnvironment environment)
        {
            var box = Atom.CreateBox(environment);

            // Centre box relative to horizontal axis.
            var total_height = box.Height + box.Depth;
            var axis         = environment.TexFont.GetAxisHeight(environment.Style);

            box.Shift = -(total_height / 2) - axis;

            return(new HorizontalBox(box));
        }
Exemplo n.º 10
0
 protected override Box CreateBoxCore(TexEnvironment environment)
 {
     if (this.isHardSpace)
     {
         return(new StrutBox(environment.MathFont.GetSpace(environment.Style), 0, 0, 0));
     }
     else
     {
         return(new StrutBox(this.width * this.GetConversionFactor(this.widthUnit, environment), this.height * this.GetConversionFactor(
                                 this.heightUnit, environment), this.depth * this.GetConversionFactor(this.depthUnit, environment), 0));
     }
 }
Exemplo n.º 11
0
        private Box Enclosure_overbar(TexEnvironment environment, Box morphbox)
        {
            // Create result box.
            var defaultLineThickness = environment.MathFont.GetDefaultLineThickness(environment.Style);
            var resultBox            = new OverBar(environment, morphbox, 3 * defaultLineThickness, defaultLineThickness)
            {
                // Adjust height and depth of result box.
                Height = morphbox.Height + 5 * defaultLineThickness,
                Depth  = morphbox.Depth
            };

            return(resultBox);
        }
Exemplo n.º 12
0
        protected override Box CreateBoxCore(TexEnvironment environment)
        {
            // Create box for base atom.
            var baseBox = this.BaseAtom == null ? StrutBox.Empty : this.BaseAtom.CreateBox(environment);

            // Create boxes for over and under atoms.
            Box overBox = null, underBox = null;
            var maxWidth = baseBox.Width;

            if (this.OverAtom != null)
            {
                overBox  = this.OverAtom.CreateBox(this.OverScriptSmaller ? environment.GetSubscriptStyle() : environment);
                maxWidth = Math.Max(maxWidth, overBox.Width);
            }

            if (this.UnderAtom != null)
            {
                underBox = this.UnderAtom.CreateBox(this.UnderScriptSmaller ? environment.GetSubscriptStyle() : environment);
                maxWidth = Math.Max(maxWidth, underBox.Width);
            }

            // Create result box.
            var resultBox = new VerticalBox();

            environment.LastFontId = baseBox.GetLastFontId();

            // Create and add box for over atom.
            if (this.OverAtom != null)
            {
                resultBox.Add(ChangeWidth(overBox, maxWidth));
                resultBox.Add(new SpaceAtom(null, this.OverSpaceUnit, 0, this.OverSpace, 0).CreateBox(environment));
            }

            // Add box for base atom.
            resultBox.Add(ChangeWidth(baseBox, maxWidth));

            double totalHeight = resultBox.Height + resultBox.Depth - baseBox.Depth;

            // Create and add box for under atom.
            if (this.UnderAtom != null)
            {
                resultBox.Add(new SpaceAtom(null, this.OverSpaceUnit, 0, this.UnderSpace, 0).CreateBox(environment));
                resultBox.Add(ChangeWidth(underBox, maxWidth));
            }

            resultBox.Depth  = resultBox.Height + resultBox.Depth - totalHeight;
            resultBox.Height = totalHeight;

            return(resultBox);
        }
Exemplo n.º 13
0
        protected override Box CreateBoxCore(TexEnvironment environment)
        {
            var newEnvironment = environment.Clone();

            if (this.Background != null)
            {
                newEnvironment.Background = this.Background;
            }
            if (this.Foreground != null)
            {
                newEnvironment.Foreground = this.Foreground;
            }
            return(this.RowAtom.CreateBox(newEnvironment));
        }
Exemplo n.º 14
0
        protected override Box CreateBoxCore(TexEnvironment environment)
        {
            var texFont = environment.MathFont;
            var style   = environment.Style;

            // Create box for base atom.
            var baseBox = this.BaseAtom.CreateBox(environment);

            // Create result box.
            var resultBox = new HorizontalBox();
            var axis      = texFont.GetAxisHeight(style);
            var delta     = Math.Max(baseBox.Height - axis, baseBox.Depth + axis);
            var minHeight = Math.Max((delta / 500) * delimeterFactor, 2 * delta - delimeterShortfall);

            // Create and add box for left delimeter.
            if (this.LeftDelimeter != null && this.LeftDelimeter.Name != SymbolAtom.EmptyDelimiterName)
            {
                var leftDelimeterBox = DelimiterFactory.CreateBox(this.LeftDelimeter.Name, minHeight, environment);
                leftDelimeterBox.Source = this.LeftDelimeter.Source;
                CentreBox(leftDelimeterBox, axis);
                resultBox.Add(leftDelimeterBox);
            }

            // add glueElement between left delimeter and base Atom, unless base Atom is whitespace.
            if (!(this.BaseAtom is SpaceAtom))
            {
                resultBox.Add(Glue.CreateBox(TexAtomType.Opening, this.BaseAtom.GetLeftType(), environment));
            }

            // add box for base Atom.
            resultBox.Add(baseBox);

            // add glueElement between right delimeter and base Atom, unless base Atom is whitespace.
            if (!(this.BaseAtom is SpaceAtom))
            {
                resultBox.Add(Glue.CreateBox(this.BaseAtom.GetRightType(), TexAtomType.Closing, environment));
            }

            // Create and add box for right delimeter.
            if (this.RightDelimeter != null && this.RightDelimeter.Name != SymbolAtom.EmptyDelimiterName)
            {
                var rightDelimeterBox = DelimiterFactory.CreateBox(this.RightDelimeter.Name, minHeight, environment);
                rightDelimeterBox.Source = this.RightDelimeter.Source;
                CentreBox(rightDelimeterBox, axis);
                resultBox.Add(rightDelimeterBox);
            }

            return(resultBox);
        }
Exemplo n.º 15
0
        protected override Box CreateBoxCore(TexEnvironment environment)
        {
            var resultBox   = new HorizontalBox();
            var innermatrix = this.BaseAtom == null ? StrutBox.Empty : this.BaseAtom.CreateBox(environment);
            var heightdiff  = innermatrix.Depth - innermatrix.Height;

            var leftparen = DelimiterFactory.CreateBox("lbrace", innermatrix.TotalHeight + heightdiff, environment);

            leftparen.Shift   = -innermatrix.Height;
            innermatrix.Shift = heightdiff / 2;
            resultBox.Add(leftparen);
            resultBox.Add(innermatrix);

            return(resultBox);
        }
Exemplo n.º 16
0
        private Box Enclosure_verticalstrike(TexEnvironment environment, Box morphbox)
        {
            var texFont = environment.MathFont;
            var style   = environment.Style;
            var axis    = texFont.GetAxisHeight(style);
            var defaultLineThickness = texFont.GetDefaultLineThickness(style);

            var vrule = new VerticalRule(environment, defaultLineThickness, morphbox.Height + morphbox.Depth, -morphbox.Height);
            var resbx = new HorizontalBox();

            resbx.Add(morphbox);
            resbx.Add(new StrutBox(-morphbox.Width / 2, -morphbox.Height, 0, 0));
            resbx.Add(vrule);
            return(resbx);
        }
Exemplo n.º 17
0
        private Box Enclosure_bottom(TexEnvironment environment, Box morphbox)
        {
            var texFont = environment.MathFont;
            var style   = environment.Style;
            var axis    = texFont.GetAxisHeight(style);
            var defaultLineThickness = texFont.GetDefaultLineThickness(style);

            var hrule = new HorizontalRule(environment, defaultLineThickness, morphbox.Width, 0);
            var resbx = new HorizontalBox();

            resbx.Add(morphbox);
            resbx.Add(new StrutBox(-morphbox.Width, -morphbox.Height + hrule.Height, 0, 0));
            resbx.Add(hrule);
            return(resbx);
        }
Exemplo n.º 18
0
        private Box Enclosure_roundedbox(TexEnvironment environment, Box morphbox)
        {
            var texFont = environment.MathFont;
            var style   = environment.Style;
            var axis    = texFont.GetAxisHeight(style);
            var defaultLineThickness = texFont.GetDefaultLineThickness(style);

            var recbox    = new RoundedRectangleBox(environment, morphbox.Height + morphbox.Depth, morphbox.TotalWidth, 0, 4, 4);
            var resultbox = new HorizontalBox();

            resultbox.Add(morphbox);
            resultbox.Add(new StrutBox(-morphbox.Width, -morphbox.Height, 0, 0));
            resultbox.Add(recbox);
            return(resultbox);
        }
Exemplo n.º 19
0
        private Box Enclosure_downdiagonalstrike(TexEnvironment environment, Box morphbox)
        {
            var texFont = environment.MathFont;
            var style   = environment.Style;
            var axis    = texFont.GetAxisHeight(style);
            var defaultLineThickness = texFont.GetDefaultLineThickness(style);

            var ddrule = new DownDiagonalRule(environment, 1, -morphbox.TotalWidth, morphbox.TotalHeight, -morphbox.TotalHeight);
            var resbx  = new HorizontalBox();

            resbx.Add(morphbox);
            resbx.Add(new StrutBox(-morphbox.Width, -morphbox.Height, 0, 0));
            resbx.Add(ddrule);
            return(resbx);
        }
Exemplo n.º 20
0
        protected override Box CreateBoxCore(TexEnvironment environment)
        {
            // Create box for base atom, in cramped style.
            var baseBox = this.BaseAtom == null ? StrutBox.Empty : this.BaseAtom.CreateBox(environment.GetCrampedStyle());

            // Create result box.
            var defaultLineThickness = environment.MathFont.GetDefaultLineThickness(environment.Style);
            var resultBox            = new OverBar(environment, baseBox, 3 * defaultLineThickness, defaultLineThickness);

            // Adjust height and depth of result box.
            resultBox.Height = baseBox.Height + 5 * defaultLineThickness;
            resultBox.Depth  = baseBox.Depth;

            return(resultBox);
        }
Exemplo n.º 21
0
        private Box Enclosure_circle(TexEnvironment environment, Box morphbox)
        {
            var texFont = environment.MathFont;
            var style   = environment.Style;
            var axis    = texFont.GetAxisHeight(style);
            var defaultLineThickness = texFont.GetDefaultLineThickness(style);

            var orule = new OvalRule(environment, morphbox.Height - morphbox.Depth, morphbox.Width, 0);
            // Create result box.
            var resultBox = new HorizontalBox();

            resultBox.Add(morphbox);
            resultBox.Add(new StrutBox(-morphbox.Width, -morphbox.Height, 0, 0));
            resultBox.Add(orule);

            return(resultBox);
        }
Exemplo n.º 22
0
        protected override Box CreateBoxCore(TexEnvironment environment)
        {
            var texFont = environment.MathFont;
            var style   = environment.Style;
            var axis    = texFont.GetAxisHeight(style);
            var defaultLineThickness = texFont.GetDefaultLineThickness(style);

            var baseBox = this.BaseAtom == null ? StrutBox.Empty : this.BaseAtom.CreateBox(environment);

            var ddrule = new UpDiagonalRule(environment, 1.3, -baseBox.TotalWidth, baseBox.TotalHeight, 0);
            var resbx  = new HorizontalBox();

            resbx.Add(baseBox);
            resbx.Add(new StrutBox(-baseBox.Width, -baseBox.Height, 0, 0));
            resbx.Add(ddrule);
            return(resbx);
        }
Exemplo n.º 23
0
        public override Box CreateBox(TexEnvironment environment)
        {
            // Create box for base atom, in cramped style.
            var base_box = BaseAtom is null ? StrutBox.Empty : BaseAtom.CreateBox(environment.GetCrampedStyle());

            // Create result box.
            var default_line_thickness = environment.TexFont.GetDefaultLineThickness(environment.Style);
            var result_box             = new OverBar(base_box, 3 * default_line_thickness, default_line_thickness)
            {
                Height = base_box.Height + 5 * default_line_thickness,
                Depth  = base_box.Depth
            };

            // Adjust height and depth of result box.

            return(result_box);
        }
Exemplo n.º 24
0
        protected override Box CreateBoxCore(TexEnvironment environment)
        {
            var texFont = environment.MathFont;
            var style   = environment.Style;

            // Create box for base atom.
            var baseBox = this.BaseAtom == null ? StrutBox.Empty : this.BaseAtom.CreateBox(environment);

            if (this.SubscriptAtom == null && this.SuperscriptAtom == null)
            {
                if (baseBox is CharBox)
                {
                    // This situation should only happen when CreateBox called on a temporary ScriptsAtom created from
                    // BigOperatorAtom.CreateBox. The CharBox's Shift should then be fixed up.
                    baseBox.Shift = -(baseBox.Height + baseBox.Depth) / 2
                                    - environment.MathFont.GetAxisHeight(environment.Style);
                }

                return(baseBox);
            }

            // Create result box.
            var resultBox = new HorizontalBox(baseBox);

            // Get last font used or default Mu font.
            int lastFontId = baseBox.GetLastFontId();

            if (lastFontId == TexFontUtilities.NoFontId)
            {
                lastFontId = texFont.GetMuFontId();
            }

            var subscriptStyle   = environment.GetSubscriptStyle();
            var superscriptStyle = environment.GetSuperscriptStyle();

            // Set delta value and preliminary shift-up and shift-down amounts depending on type of base atom.
            var    delta = 0d;
            double shiftUp, shiftDown;

            if (this.BaseAtom is AccentedAtom accentedAtom && accentedAtom.BaseAtom != null)
            {
                var accentedBox = accentedAtom.BaseAtom.CreateBox(environment.GetCrampedStyle());
                shiftUp   = accentedBox.Height - texFont.GetSupDrop(superscriptStyle.Style);
                shiftDown = accentedBox.Depth + texFont.GetSubDrop(subscriptStyle.Style);
            }
Exemplo n.º 25
0
        protected override Box CreateBoxCore(TexEnvironment environment)
        {
            var texFont = environment.MathFont;
            var style   = environment.Style;
            var defaultRuleThickness = texFont.GetDefaultLineThickness(style);
            var basebox = this.BaseAtom == null ? StrutBox.Empty : this.BaseAtom.CreateBox(environment);

            var rectbox = new RectangleBox(environment, basebox.TotalHeight + 4 * defaultRuleThickness, basebox.TotalWidth + 4 * defaultRuleThickness, 0)
            {
                Shift = basebox.Depth + 2 * defaultRuleThickness
            };
            var resultbox = new HorizontalBox();

            resultbox.Add(basebox);
            resultbox.Add(new StrutBox(-rectbox.TotalWidth + 2 * defaultRuleThickness, -rectbox.TotalHeight, 0, 0));
            resultbox.Add(rectbox);
            return(resultbox);
        }
Exemplo n.º 26
0
        public override Box CreateBox(TexEnvironment environment)
        {
            if (IsTextSymbol)
            {
                ((CharSymbol)Atom).IsTextSymbol = true;
            }
            var resultBox = Atom.CreateBox(environment);

            //TODO: Разобраться с надстрочными знаками!
            if (Atom.Type == TexAtomType.Accent)
            {
                resultBox.Width = 0;
            }
            if (IsTextSymbol)
            {
                ((CharSymbol)Atom).IsTextSymbol = false;
            }
            return(resultBox);
        }
Exemplo n.º 27
0
        public override Box CreateBox(TexEnvironment environment)
        {
            var defaultLineThickness = environment.TexFont.GetDefaultLineThickness(environment.Style);

            // Create box for base atom.
            var baseBox = BaseAtom is null ? StrutBox.Empty : BaseAtom.CreateBox(environment);

            // Create result box.
            var resultBox = new VerticalBox();

            resultBox.Add(baseBox);
            resultBox.Add(new StrutBox(0, 3 * defaultLineThickness, 0, 0));
            resultBox.Add(new HorizontalRule(defaultLineThickness, baseBox.Width, 0));

            resultBox.Depth  = baseBox.Depth + 5 * defaultLineThickness;
            resultBox.Height = baseBox.Height;

            return(resultBox);
        }
Exemplo n.º 28
0
        private Box LongDivisionStyle_lefttop(TexEnvironment environment)
        {
            var texFont = environment.MathFont;
            var style   = environment.Style;
            var axis    = texFont.GetAxisHeight(style);
            var defaultLineThickness = texFont.GetDefaultLineThickness(style);

            var    dividend_divisor = new HorizontalBox();
            var    divisorbox       = this.DivisorAtom == null ? StrutBox.Empty : this.DivisorAtom.CreateBox(environment);
            var    leftsep          = SymbolAtom.GetAtom("rbrack", this.Source).CreateBox(environment);
            var    dividendbox      = this.DividendAtom == null ? StrutBox.Empty : this.DividendAtom.CreateBox(environment);
            double barwidth         = leftsep.TotalWidth + dividendbox.TotalWidth;
            var    separatorbar     = new HorizontalRule(environment, defaultLineThickness, barwidth, -dividendbox.TotalHeight - defaultLineThickness);


            dividend_divisor.Add(divisorbox);
            dividend_divisor.Add(leftsep);
            dividend_divisor.Add(dividendbox);
            dividend_divisor.Add(new StrutBox(-barwidth, dividendbox.TotalHeight, 0, 0));
            dividend_divisor.Add(separatorbar);

            var quotient_pad      = new HorizontalBox();
            var quotientbox       = this.QuotientAtom == null ? StrutBox.Empty : this.QuotientAtom.CreateBox(environment);
            var leftspace         = dividend_divisor.TotalWidth - quotientbox.TotalWidth;
            var quot_leftspacebox = new StrutBox(leftspace, quotientbox.TotalHeight, 0, 0);

            quotient_pad.Add(quot_leftspacebox);
            quotient_pad.Add(quotientbox);

            var otherbox = this.OtherAtom == null ? StrutBox.Empty : this.OtherAtom.CreateBox(environment);


            var resultBox = new VerticalBox();

            resultBox.Add(quotient_pad);
            resultBox.Add(dividend_divisor);
            resultBox.Add(otherbox);

            return(resultBox);
        }
Exemplo n.º 29
0
        protected override Box CreateBoxCore(TexEnvironment environment)
        {
            var resultBox   = new HorizontalBox();
            var innermatrix = this.BaseAtom == null ? StrutBox.Empty : this.BaseAtom.CreateBox(environment);
            var heightdiff  = innermatrix.Depth - innermatrix.Height;

            var leftparen = DelimiterFactory.CreateBox("Vert", innermatrix.TotalHeight, environment);

            leftparen.Shift = -innermatrix.Height + heightdiff;

            var rightparen = DelimiterFactory.CreateBox("Vert", innermatrix.TotalHeight, environment);

            rightparen.Shift = -innermatrix.Height + heightdiff;

            innermatrix.Shift = -(environment.MathFont.GetAxisHeight(environment.Style) - heightdiff) / 3;

            resultBox.Add(leftparen);
            resultBox.Add(innermatrix);
            resultBox.Add(rightparen);

            return(resultBox);
        }
Exemplo n.º 30
0
        protected override Box CreateBoxCore(TexEnvironment environment)
        {
            var resultBox  = new HorizontalBox();
            var leftmatrix = this.LeftBaseAtom == null ? StrutBox.Empty : this.LeftBaseAtom.CreateBox(environment);
            var heightdiff = leftmatrix.Depth - leftmatrix.Height;

            var vbarseparator = DelimiterFactory.CreateBox("vert", leftmatrix.TotalHeight, environment);

            vbarseparator.Shift = -leftmatrix.Height + heightdiff;

            var rightmatrix = this.RightBaseAtom == null ? StrutBox.Empty : this.RightBaseAtom.CreateBox(environment);
            var heightdiff1 = rightmatrix.Depth - rightmatrix.Height;//apparently, its the same as "heightdiff"

            leftmatrix.Shift  = -(environment.MathFont.GetAxisHeight(environment.Style) - heightdiff) / 3;
            rightmatrix.Shift = -(environment.MathFont.GetAxisHeight(environment.Style) - heightdiff1) / 3;

            resultBox.Add(leftmatrix);
            resultBox.Add(vbarseparator);

            resultBox.Add(rightmatrix);

            return(resultBox);
        }