예제 #1
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);
        }
예제 #2
0
        /// 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);
        }
예제 #3
0
        public void Render(Mesh m, DrawingParams param)
        {
#if TEXDRAW_DEBUG
            Profiler.BeginSample("Rendering");
#endif

            m.Clear();
            Clear();

            if (parsingComplete)
            {
                // Color processing is happening only in rendering section.
                TexContext.Color.Reset(param.color);

                param.context = this;
                linkBoxKey.Clear();
                linkBoxRect.Clear();
                param.Render();
            }
            Push2Mesh(m);

#if TEXDRAW_DEBUG
            Profiler.EndSample();
#endif
        }
예제 #4
0
        public void BoxPacking(DrawingParams param)
        {
#if TEXDRAW_PROFILE
            Profiler.BeginSample("Boxing");
            param.formulas = ToRenderers(this.parsed, param);
            Profiler.EndSample();
#else
            param.formulas = ToRenderers(this.parsed, param);
#endif
        }
예제 #5
0
 public void ApplyBeforeBoxing(DrawingParams param)
 {
     if (!enabled)
     {
         return;
     }
     ApplyBeforeBoxing();
     // Return to param if not set
     if (style == -1)
     {
         TexContext.Style.value = param.fontStyle; //Only Bold or Italic
     }
     if (kerning == 0)
     {
         TexContext.Kerning.value = 0;
     }
 }
예제 #6
0
 public void ApplyBeforeBoxing(DrawingParams param)
 {
     if (!enabled)
     {
         return;
     }
     ApplyBeforeBoxing();
     // Return to param if not set
     if (style == -1)
     {
         TexUtility.RenderFontStyle = (FontStyle)param.fontStyle; //Only Bold or Italic
     }
     if (font == -2)
     {
         TexUtility.RenderFont = param.fontIndex;
     }
     if (kerning == 0)
     {
         TexUtility.AdditionalGlueSpace = 0;
     }
 }
예제 #7
0
        public void Render(Mesh m, DrawingParams param)
        {
#if TEXDRAW_PROFILE
            Profiler.BeginSample("Rendering");
#endif

            m.Clear();
            Clear();

            if (parsingComplete)
            {
                param.context = this;
                linkBoxKey.Clear();
                linkBoxRect.Clear();
                param.Render();
            }
            Push2Mesh(m);

#if TEXDRAW_PROFILE
            Profiler.EndSample();
#endif
        }