コード例 #1
0
ファイル: DrawingContext.cs プロジェクト: Synedh/the_m_wand
        /// Convert Atom into Boxes
        public static List <TexRenderer> ToRenderers(List <TexFormula> formulas, DrawingParams param)
        {
            // Init default parameters
            var list = param.formulas;

            TexContext.Resolution = param.fontSize;
            TexContext.Style.Reset(param.fontStyle);
            TexContext.Font.Reset(param.fontIndex);
            TexContext.Kerning.Reset(0);
            TexContext.Environment.Reset(TexEnvironment.Display);
            TexContext.Color.Reset(param.color);
            for (int i = 0; i < list.Count; i++)
            {
                list[i].Flush();
            }
            list.Clear();

            TexMetaRenderer lastMeta = null;

            for (int i = 0; i < formulas.Count; i++)
            {
                if (lastMeta != null || (formulas[i].AttachedMetaRenderer != null && formulas[i].AttachedMetaRenderer.enabled))
                {
                    var meta = formulas[i].AttachedMetaRenderer ?? (formulas[i].AttachedMetaRenderer = lastMeta);
                    meta.ApplyBeforeBoxing(param);
                    lastMeta = meta;
                }
                list.Add(formulas[i].GetRenderer());
            }
            return(list);
        }
コード例 #2
0
        /// Convert Atom into Boxes
        public static List <TexRenderer> ToRenderers(List <TexFormula> formulas, DrawingParams param)
        {
            // Init default parameters
            var list = param.formulas;

            TexUtility.RenderTextureSize   = param.fontSize;
            TexUtility.RenderFontStyle     = param.fontStyle;
            TexUtility.RenderFont          = param.fontIndex;
            TexUtility.AdditionalGlueSpace = 0;
            for (int i = 0; i < list.Count; i++)
            {
                list[i].Flush();
            }
            list.Clear();

            TexMetaRenderer lastMeta = null;

            for (int i = 0; i < formulas.Count; i++)
            {
                var scale = param.scale;
                if (lastMeta != null || (formulas[i].AttachedMetaRenderer != null && formulas[i].AttachedMetaRenderer.enabled))
                {
                    var meta = formulas[i].AttachedMetaRenderer ?? (formulas[i].AttachedMetaRenderer = lastMeta);
                    meta.ApplyBeforeBoxing(param);
                    if (meta.size != 0)
                    {
                        scale = meta.size;
                    }
                    lastMeta = meta;
                }
                list.Add(formulas[i].GetRenderer(TexStyle.Display, scale));
            }
            return(list);
        }
コード例 #3
0
ファイル: TexFormula.cs プロジェクト: step4/rac-quiz
 public void Flush()
 {
     if (RootAtom != null)
     {
         RootAtom.Flush();
         RootAtom = null;
     }
     if (AttachedMetaRenderer != null)
     {
         AttachedMetaRenderer.Flush();
         AttachedMetaRenderer = null;
     }
     ObjPool <TexFormula> .Release(this);
 }
コード例 #4
0
 public void Flush()
 {
     if (Box != null)
     {
         Box.Flush();
         Box = null;
     }
     partOfPreviousLine = 0;
     if (metaRules != null)
     {
         //metaRules.Flush();
         metaRules = null;
     }
     ObjPool <TexRenderer> .Release(this);
 }
コード例 #5
0
        public static TexRenderer Get(Box box, float scale, TexMetaRenderer meta)
        {
            var renderer = ObjPool <TexRenderer> .Get();

            renderer.Box       = box;
            renderer.Scale     = scale;
            renderer.metaRules = meta;
            // There's an additional step if meta 'line' are declared
            if (renderer.usingMetaRules && renderer.metaRules.line != 0 && box.totalHeight > 0)
            {
                if (!(box is HorizontalBox))
                {
                    renderer.Box = box = HorizontalBox.Get(box);
                }
                box.height = renderer.metaRules.line;
                box.depth  = 0;
            }
            return(renderer);
        }
コード例 #6
0
        public static TexRenderer Get(HorizontalBox box, TexMetaRenderer meta, int isPartOfPrev = 0)
        {
            var renderer = ObjPool <TexRenderer> .Get();

            renderer.Box = box;
            //renderer.Scale = scale;
            renderer.metaRules          = meta;
            renderer.partOfPreviousLine = isPartOfPrev;

            // must horizontal box to avoid headache
            if (!(box is HorizontalBox))
            {
                renderer.Box = box = HorizontalBox.Get(box);
            }

            // There's an additional step if meta 'line' are declared
            if (renderer.usingMetaRules && renderer.metaRules.line != 0 && box.totalHeight > 0)
            {
                box.height = renderer.metaRules.line;
                box.depth  = TexUtility.spaceLine;
            }
            return(renderer);
        }
コード例 #7
0
ファイル: TEXSupTabAligner.cs プロジェクト: step4/rac-quiz
 protected override void OnEnable()
 {
     base.OnEnable();
     m_meta = new TexMetaRenderer();
 }