/// 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); }
/// 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); }
public void Flush() { if (RootAtom != null) { RootAtom.Flush(); RootAtom = null; } if (AttachedMetaRenderer != null) { AttachedMetaRenderer.Flush(); AttachedMetaRenderer = null; } ObjPool <TexFormula> .Release(this); }
public void Flush() { if (Box != null) { Box.Flush(); Box = null; } partOfPreviousLine = 0; if (metaRules != null) { //metaRules.Flush(); metaRules = null; } ObjPool <TexRenderer> .Release(this); }
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); }
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); }
protected override void OnEnable() { base.OnEnable(); m_meta = new TexMetaRenderer(); }