コード例 #1
0
        public override Box CreateBox()
        {
            float factor = TexContext.Scale;

            return(StrutBox.Get((width + TexContext.Kerning.value) * factor,
                                height * factor, depth * factor, 0, policy));
        }
コード例 #2
0
        public override Box CreateBox(TexStyle style)
        {
            if (BaseAtom == null)
            {
                return(StrutBox.Empty);
            }
            else
            {
                Box box;
                if (UnderLink)
                {
                    var   baseBox = BaseAtom.CreateBox(style);
                    float margin  = TEXConfiguration.main.NegateMargin * TexUtility.SizeFactor(style) / 2;
                    float thick   = TEXConfiguration.main.LineThickness * TexUtility.SizeFactor(style) / 2;

                    box = HorizontalBox.Get(baseBox);
                    box.Add(StrutBox.Get(-box.width, 0, 0, 0));
                    box.Add(StrikeBox.Get(baseBox.height, baseBox.width, baseBox.depth,
                                          margin, thick, StrikeBox.StrikeMode.underline, 0, 0));
                    return(AttrLinkBox.Get(box, MetaKey));
                }
                else
                {
                    return(AttrLinkBox.Get(BaseAtom.CreateBox(style), MetaKey));
                }
            }
        }
コード例 #3
0
        public override Box CreateBox()
        {
            if (BaseAtom == null)
            {
                return(StrutBox.Empty);
            }
            else
            {
                if (UnderLink)
                {
                    var baseBox = BaseAtom.CreateBox();
                    var box     = HorizontalBox.Get(baseBox);

                    float factor = TexContext.Scale / 2;
                    float thick  = TEXConfiguration.main.LineThickness * factor;

                    box.Add(StrutBox.Get(-box.width, 0, 0, 0));
                    box.Add(StrikeBox.Get(baseBox.height, baseBox.width, baseBox.depth,
                                          0, thick, StrikeBox.StrikeMode.underline, 0, 0));

                    return(AttrLinkBox.Get(box, MetaKey, Margin));
                }
                else
                {
                    return(AttrLinkBox.Get(BaseAtom.CreateBox(), MetaKey, Margin));
                }
            }
        }
コード例 #4
0
        public static VerticalBox Get(Box box, float kern, float thickness)
        {
            var atom = VerticalBox.Get();

            atom.Add(HorizontalRule.Get(thickness, box.width, box.shift));
            kern += thickness;
            atom.Add(StrutBox.Get(0, kern / 2, 0, 0));
            atom.Add(box);
            atom.Add(StrutBox.Get(0, kern / 2, 0, 0));
            return(atom);
        }
コード例 #5
0
ファイル: NegateAtom.cs プロジェクト: step4/rac-quiz
        public override Box CreateBox()
        {
            if (BaseAtom == null)
                return StrutBox.Empty;
            var factor = TexContext.Scale / 2;
            var margin = useMargin ? TEXConfiguration.main.NegateMargin * factor : 0;
            var thick = TEXConfiguration.main.LineThickness * factor;
            var baseBox = BaseAtom.CreateBox();
            var result = HorizontalBox.Get();

            var negateBox = StrikeBox.Get(baseBox.height, baseBox.width, baseBox.depth,
                                margin, thick, (StrikeBox.StrikeMode)mode, offsetM, offsetP);
            negateBox.shift = baseBox.shift;
            result.Add(negateBox);
            result.Add(StrutBox.Get(-baseBox.width, 0, 0, 0));
            result.Add(baseBox);
            return result;
        }
コード例 #6
0
ファイル: UnderlinedAtom.cs プロジェクト: Synedh/the_m_wand
        public override Box CreateBox()
        {
            var defaultLineThickness = TEXConfiguration.main.LineThickness * TexContext.Scale;

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

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

            resultBox.Add(baseBox);
            resultBox.Add(StrutBox.Get(0, 3 * defaultLineThickness, 0, 0));
            resultBox.Add(HorizontalRule.Get(defaultLineThickness, baseBox.width, 0));

            resultBox.depth  = baseBox.depth + 5 * defaultLineThickness;
            resultBox.height = baseBox.height;

            return(resultBox);
        }
コード例 #7
0
ファイル: NegateAtom.cs プロジェクト: cubemaster21/CALA-Unity
        public override Box CreateBox(TexStyle style)
        {
            if (BaseAtom == null)
            {
                return(StrutBox.Empty);
            }
            var factor  = TexUtility.SizeFactor(style) / 2;
            var margin  = useMargin ? TEXConfiguration.main.NegateMargin * factor : 0;
            var thick   = TEXConfiguration.main.LineThickness * factor;
            var baseBox = BaseAtom.CreateBox(style);
            var result  = HorizontalBox.Get();

            var negateBox = StrikeBox.Get(baseBox.height, baseBox.width, baseBox.depth,
                                          margin, thick, (StrikeBox.StrikeMode)mode, offsetM, offsetP);

            negateBox.shift = baseBox.shift;
            result.Add(negateBox);
            result.Add(StrutBox.Get(-baseBox.width, 0, 0, 0));
            result.Add(baseBox);
            return(result);
        }
コード例 #8
0
ファイル: SpaceAtom.cs プロジェクト: cubemaster21/CALA-Unity
        public override Box CreateBox(TexStyle style)
        {
            float factor = TexUtility.SizeFactor(style);

            return(StrutBox.Get((width + TexUtility.AdditionalGlueSpace) * factor, height * factor, depth * factor, 0, policy));
        }
コード例 #9
0
        public override Box CreateBox()
        {
            float lineHeight = lineThickness * TexContext.Scale;

            // Create boxes for numerator and demoninator atoms, and make them of equal width.
            TexContext.Environment.Push(TexUtility.GetNumeratorStyle());
            var numeratorBox = numerator == null ? StrutBox.Empty : numerator.CreateBox();

            TexContext.Environment.Pop();

            TexContext.Environment.Push(TexUtility.GetDenominatorStyle());
            var denominatorBox = denominator == null ? StrutBox.Empty : denominator.CreateBox();

            TexContext.Environment.Pop();

            float maxWidth = (numeratorBox.width < denominatorBox.width ? denominatorBox.width : numeratorBox.width) + TEXConfiguration.main.FractionMargin * TexContext.Scale;

            numeratorBox   = HorizontalBox.Get(numeratorBox, maxWidth, numeratorAlignment);
            denominatorBox = HorizontalBox.Get(denominatorBox, maxWidth, denominatorAlignment);

            // Calculate preliminary shift-up and shift-down amounts.
            float shiftUp, shiftDown;
            var   styleFactor = TexContext.Scale;

            if (TexContext.Environment.value >= TexEnvironment.Text)
            {
                styleFactor *= TEXConfiguration.main.FractionNarrowFactor;
            }

            shiftUp   = TEXConfiguration.main.NumeratorShift * styleFactor;
            shiftDown = TEXConfiguration.main.DenominatorShift * styleFactor;

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

            // add box for numerator.
            resultBox.Add(numeratorBox);

            // Calculate clearance and adjust shift amounts.
            //var axis = TEXConfiguration.main.AxisHeight * TexContext.Scale;

            // Calculate clearance amount.
            float clearance = lineHeight > 0 ? TEXConfiguration.main.FractionGap : TEXConfiguration.main.FractionGapNoLine;

            // Adjust shift amounts.
            var kern1  = shiftUp - numeratorBox.depth;
            var kern2  = shiftDown - denominatorBox.height;
            var delta1 = clearance - kern1;
            var delta2 = clearance - kern2;

            if (delta1 > 0)
            {
                shiftUp += delta1;
                kern1   += delta1;
            }
            if (delta2 > 0)
            {
                shiftDown += delta2;
                kern2     += delta2;
            }

            if (lineHeight > 0)
            {
                // Draw fraction line.

                resultBox.Add(StrutBox.Get(0, kern1, 0, 0));
                resultBox.Add(HorizontalRule.Get(lineHeight, numeratorBox.width, 0));
                resultBox.Add(StrutBox.Get(0, kern2, 0, 0));
            }
            else
            {
                // Do not draw fraction line.

                var kern = kern1 + kern2;
                resultBox.Add(StrutBox.Get(0, kern, 0, 0));
            }

            // add box for denominator.
            resultBox.Add(denominatorBox);

            // Adjust height and depth of result box.
            resultBox.height = shiftUp + numeratorBox.height;
            resultBox.depth  = shiftDown + lineHeight + denominatorBox.depth;

            TexUtility.CentreBox(resultBox);
            return(resultBox);
        }