/// 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); }
/// 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); }
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 }
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 }
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; } }
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; } }
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 }