Example #1
0
        // Unicode character (where it didn't inside our library)
        public static CharBox Get(int font, char ch)
        {
            var C = TEXPreference.main.GetChar(font, ch);

            if (C == null)
            {
                var f = TEXPreference.main.fonts[font];

                if (f.type == TexAssetType.Font)
                {
                    // unicode
                    var box = ObjPool <CharBox> .Get();

                    box.i = font;
                    var scl = TexContext.Scale;
                    var c   = box.c = ((TexFont)f).GenerateFont(ch,
                                                                (int)(TexContext.Resolution * scl) + 1, TexContext.Style.value);
                    float r = scl / c.size;
                    box.Set(-c.minY * r, c.maxY * r, -c.minX * r, c.maxX * r, c.advance * r);
                    return(box);
                }
                else
                {
                    // a sprite. simply no way to fix this!
                    throw new InvalidOperationException("Illegal Character! '" + ch + "' doesn't exist in " + TEXPreference.main.fonts[font].name);
                }
            }
            else
            {
                return(Get(C));
            }
        }
Example #2
0
        public static UnderOverAtom Get(Atom baseAtom, Atom underOver, float underOverSpace,
                                        bool underOverScriptSize, bool over)
        {
            var atom = ObjPool <UnderOverAtom> .Get();

            atom.BaseAtom = baseAtom;

            if (over)
            {
                atom.UnderAtom          = null;
                atom.UnderSpace         = 0;
                atom.UnderScriptSmaller = false;
                atom.OverAtom           = underOver;
                atom.OverSpace          = underOverSpace;
                atom.OverScriptSmaller  = underOverScriptSize;
            }
            else
            {
                atom.UnderAtom          = underOver;
                atom.UnderSpace         = underOverSpace;
                atom.UnderScriptSmaller = underOverScriptSize;
                atom.OverSpace          = 0;
                atom.OverAtom           = null;
                atom.OverScriptSmaller  = false;
            }
            return(atom);
        }
Example #3
0
        public static HorizontalBox Get(Box box)
        {
            var Box = ObjPool <HorizontalBox> .Get();

            Box.Add(box);
            return(Box);
        }
Example #4
0
        public static TexFormula Get(TexFormula formula)
        {
            var formulas = ObjPool <TexFormula> .Get();

            formulas.Add(formula);
            return(formulas);
        }
Example #5
0
        public static AttrColorAtom Get(string colorStr, int mix, out AttrColorAtom endBlock)
        {
            var atom = ObjPool <AttrColorAtom> .Get();

            endBlock = ObjPool <AttrColorAtom> .Get();

            atom.EndAtom = endBlock;
            atom.mix     = mix;
            endBlock.mix = mix;
            if (colorStr == null)
            {
                atom.color = Color.white;
            }
            else if (colorStr.Length == 1)
            {
                atom.color = ModifiedTerminalColor(colorStr[0]);
            }
            else if (!ColorUtility.TryParseHtmlString(colorStr, out atom.color))
            {
                if (!ColorUtility.TryParseHtmlString("#" + colorStr, out atom.color))
                {
                    atom.color = Color.white;
                }
            }
            endBlock.color = atom.color;
            return(atom);
        }
Example #6
0
        public static AttrTransformationAtom Get(string transformStr, int pivotMode, out AttrTransformationAtom endBlock)
        {
            var atom = ObjPool <AttrTransformationAtom> .Get();

            endBlock = ObjPool <AttrTransformationAtom> .Get();

            atom.EndAtom   = endBlock;
            atom.pivotMode = pivotMode;
            var dualIndicator = transformStr.IndexOf('|');

            atom.dualMatrix = dualIndicator >= 0;
            atom.matrix     = ParseTransformation(transformStr);
            if (atom.dualMatrix)
            {
                atom.matrix       = ParseTransformation(transformStr.Substring(0, dualIndicator));
                atom.secondMatrix = ParseTransformation(transformStr.Substring(dualIndicator + 1));
            }
            else
            {
                atom.matrix = ParseTransformation(transformStr);
            }

            endBlock.matrix    = atom.matrix;
            endBlock.pivotMode = atom.pivotMode;
            return(atom);
        }
Example #7
0
        public static StrikeBox Get(float Height, float Width, float Depth)
        {
            var box = ObjPool <StrikeBox> .Get();

            box.Set(Width, Height, Depth, 0);
            return(box);
        }
Example #8
0
        public static StrutBox Get(float Width, float Height, float Depth, float Shift, StrutPolicy Policy)
        {
            var box = ObjPool <StrutBox> .Get();

            box.Set(Width, Height, Depth, Shift);
            box.policy = Policy;
            return(box);
        }
Example #9
0
        public static HorizontalRule Get(float Height, float Width, float Shift)
        {
            var box = ObjPool <HorizontalRule> .Get();

            box.Set(Width, Height, 0, Shift);
            box.useXDepth = false;
            return(box);
        }
Example #10
0
        public static HorizontalRule Get(float Height, float Width, float Shift, float Depth, bool UseXDepth)
        {
            var box = ObjPool <HorizontalRule> .Get();

            box.Set(Width, Height, Depth, Shift);
            box.useXDepth = UseXDepth;
            return(box);
        }
Example #11
0
        public static AccentedAtom Get(Atom baseAtom, Atom accent)
        {
            var atom = ObjPool <AccentedAtom> .Get();

            atom.BaseAtom   = baseAtom ?? SpaceAtom.Get(0, 0, 0);
            atom.AccentAtom = accent as SymbolAtom;
            return(atom);
        }
Example #12
0
        public static AttrStyleAtom Get(Atom baseAtom, FontStyle style)
        {
            var atom = ObjPool <AttrStyleAtom> .Get();

            atom.BaseAtom = baseAtom;
            atom.Style    = style;
            return(atom);
        }
Example #13
0
        public static AccentedAtom Get(Atom baseAtom, string accentName)
        {
            var atom = ObjPool <AccentedAtom> .Get();

            atom.BaseAtom   = baseAtom ?? SpaceAtom.Get(0, 0, 0);
            atom.AccentAtom = SymbolAtom.GetAtom(accentName);
            return(atom);
        }
Example #14
0
        public static UnicodeAtom Get(int FontIndex, char c)
        {
            var atom = ObjPool <UnicodeAtom> .Get();

            atom.fontIndex = FontIndex;
            atom.charIndex = c;
            return(atom);
        }
Example #15
0
        public static AttrStyleAtom Get(Atom baseAtom, string styleStr)
        {
            var atom = ObjPool <AttrStyleAtom> .Get();

            atom.BaseAtom = baseAtom;
            atom.Style    = ParseFontStyle(styleStr);
            return(atom);
        }
Example #16
0
        public static Radical Get(Atom baseAtom, Atom degreeAtom)
        {
            var atom = ObjPool <Radical> .Get();

            atom.Type       = CharTypeInternal.Inner;
            atom.BaseAtom   = baseAtom;
            atom.DegreeAtom = degreeAtom;
            return(atom);
        }
Example #17
0
        public static AttrTransformationBox Get(AttrTransformationAtom atom, AttrTransformationBox endBox)
        {
            var box = ObjPool <AttrTransformationBox> .Get();

            box.pivotMode    = atom.pivotMode;
            box.endBox       = endBox;
            box.attachedAtom = atom;
            return(box);
        }
Example #18
0
        public static AttrColorBox Get(int mixMode, Color color, AttrColorBox endBox)
        {
            var box = ObjPool <AttrColorBox> .Get();

            box.renderColor = color;
            box.mixMode     = mixMode;
            box.endBox      = endBox;
            return(box);
        }
Example #19
0
        public static HorizontalRule Get(float Height, float Width, float Shift)
        {
            var box = ObjPool <HorizontalRule> .Get();

            box.width  = Width;
            box.height = Height;
            box.shift  = Shift;
            return(box);
        }
Example #20
0
        public static AttrColorBox Get(int mixMode, Color color)
        {
            var box = ObjPool <AttrColorBox> .Get();

            box.color   = color;
            box.mixmode = mixMode;
            // leave the size zero
            return(box);
        }
Example #21
0
        public static AttrBorderAtom Get(Atom baseAtom, string param, bool margin)
        {
            var atom = ObjPool <AttrBorderAtom> .Get();

            atom.baseAtom = baseAtom;
            atom.margin   = margin;
            Parse(param, out atom.thickness, out atom.radius, out atom.color);
            return(atom);
        }
Example #22
0
        public static StrikeBox Get(float Height, float Width, float Depth)
        {
            var box = ObjPool <StrikeBox> .Get();

            box.width  = Width;
            box.height = Height;
            box.depth  = Depth;
            return(box);
        }
Example #23
0
        public static AttrBgAtom Get(Atom baseAtom, string color, bool margin)
        {
            var atom = ObjPool <AttrBgAtom> .Get();

            atom.baseAtom = baseAtom;
            atom.margin   = margin;
            atom.color    = color == null ? Color.clear : AttrColorAtom.ParseColor(color);
            return(atom);
        }
Example #24
0
        public static CharAtom Get(char character, int FontIndex)
        {
            var atom = ObjPool <CharAtom> .Get();

            atom.Character = character;
            atom.FontIndex = FontIndex;
            atom.FontStyle = TexUtility.RenderFontStyle;
            return(atom);
        }
Example #25
0
        public static HolderAtom Get(Atom baseAtom, Vector2 size, TexAlignment Alignment)
        {
            var atom = ObjPool <HolderAtom> .Get();

            atom.BaseAtom = baseAtom;
            atom.size     = size;
            atom.align    = Alignment;
            atom.Type     = CharTypeInternal.Inner;
            return(atom);
        }
Example #26
0
        public static HorizontalBox Get()
        {
            var Box = ObjPool <HorizontalBox> .Get();

            if (Box.children == null)
            {
                Box.children = new List <Box>(8);
            }
            return(Box);
        }
Example #27
0
        public static ScriptsAtom Get(Atom baseAtom, Atom subscriptAtom, Atom superscriptAtom)
        {
            var atom = ObjPool <ScriptsAtom> .Get();

            atom.BaseAtom        = baseAtom;
            atom.SubscriptAtom   = subscriptAtom;
            atom.SuperscriptAtom = superscriptAtom;
            atom.Type            = CharTypeInternal.Inner;
            return(atom);
        }
Example #28
0
        public static AttrColorBox Get(AttrColorAtom atom, AttrColorBox endBox)
        {
            var box = ObjPool <AttrColorBox> .Get();

            box.renderColor  = atom.color;
            box.mixMode      = atom.mix;
            box.endBox       = endBox;
            box.attachedAtom = atom;
            return(box);
        }
Example #29
0
        public static MatrixAtom Get()
        {
            var atom = ObjPool <MatrixAtom> .Get();

            atom.horizontalAlign = 1 + 8 + 64;
            atom.verticalAlign   = 1 + 8 + 64;
            atom.horizontalLine  = 0;
            atom.verticalLine    = 0;
            return(atom);
        }
Example #30
0
        public static VerticalBox Get()
        {
            var box = ObjPool <VerticalBox> .Get();

            if (box.children == null)
            {
                box.children = new List <Box>();
            }
            return(box);
        }