public override Box CreateBox() { if (BaseAtom == null) { return(StrutBox.Empty); } else { if (UnderLink) { var baseBox = BaseAtom.CreateBox(); var box = HorizontalBox.Get(baseBox); float factor = TexContext.Scale / 2; float thick = TEXConfiguration.main.LineThickness * factor; box.Add(StrutBox.Get(-box.width, 0, 0, 0)); box.Add(StrikeBox.Get(baseBox.height, baseBox.width, baseBox.depth, 0, thick, StrikeBox.StrikeMode.underline, 0, 0)); return(AttrLinkBox.Get(box, MetaKey, Margin)); } else { return(AttrLinkBox.Get(BaseAtom.CreateBox(), MetaKey, Margin)); } } }
public override Box CreateBox(TexStyle style) { if (BaseAtom == null) { return(StrutBox.Empty); } else { Box box; if (UnderLink) { var baseBox = BaseAtom.CreateBox(style); float margin = TEXConfiguration.main.NegateMargin * TexUtility.SizeFactor(style) / 2; float thick = TEXConfiguration.main.LineThickness * TexUtility.SizeFactor(style) / 2; box = HorizontalBox.Get(baseBox); box.Add(StrutBox.Get(-box.width, 0, 0, 0)); box.Add(StrikeBox.Get(baseBox.height, baseBox.width, baseBox.depth, margin, thick, StrikeBox.StrikeMode.underline, 0, 0)); return(AttrLinkBox.Get(box, MetaKey)); } else { return(AttrLinkBox.Get(BaseAtom.CreateBox(style), MetaKey)); } } }
public override Box CreateBox() { // This SizeBox doesn't need start..end block, since the size metric are calculated directly if (BaseAtom == null) { return(StrutBox.Empty); } else { var nan = float.IsNaN(Size); TexContext.Size.Push(nan ? 1f : Size); if (nan) { TexContext.Environment.Push(TexEnvironment.Display); } var box = BaseAtom.CreateBox(); box.shift += Offset; TexContext.Size.Pop(); if (nan) { TexContext.Environment.Pop(); } return(box); } }
public override Box CreateBox() { var box = baseAtom.CreateBox(); box.shift -= offset; return(HorizontalBox.Get(box)); }
public override Box CreateBox() { var box = BaseAtom.CreateBox(); // Centre box relative to horizontal axis. var totalHeight = box.height + box.depth; var axis = TEXConfiguration.main.AxisHeight * TexContext.Scale; box.shift = -(totalHeight / 2) - axis; return(HorizontalBox.Get(box)); }
public override Box CreateBox(TexStyle style) { var box = BaseAtom.CreateBox(style); // Centre box relative to horizontal axis. var totalHeight = box.height + box.depth; var axis = TEXConfiguration.main.AxisHeight * TexUtility.SizeFactor(style); box.shift = -(totalHeight / 2) - axis; return(HorizontalBox.Get(box)); }
public override Box CreateBox(TexStyle style) { // Create box for base atom, in cramped style. var baseBox = BaseAtom == null ? StrutBox.Empty : BaseAtom.CreateBox(TexUtility.GetCrampedStyle(style)); // Create result box. var defaultLineThickness = TEXConfiguration.main.LineThickness * TexUtility.SizeFactor(style); var resultBox = OverBar.Get(baseBox, 3 * defaultLineThickness, defaultLineThickness); // Adjust height and depth of result box. resultBox.height = baseBox.height + 5 * defaultLineThickness; resultBox.depth = baseBox.depth; return(resultBox); }
public override Box CreateBox() { // Create box for base atom, in cramped style. TexContext.Environment.Push(TexUtility.GetCrampedStyle()); var baseBox = BaseAtom == null ? StrutBox.Empty : BaseAtom.CreateBox(); TexContext.Environment.Pop(); // Create result box. var defaultLineThickness = TEXConfiguration.main.LineThickness * TexContext.Scale; var resultBox = OverBar.Get(baseBox, 3 * defaultLineThickness, defaultLineThickness); // Adjust height and depth of result box. resultBox.height = baseBox.height + 5 * defaultLineThickness; resultBox.depth = baseBox.depth; return(resultBox); }
public override Box CreateBox() { if (BaseAtom == null) return StrutBox.Empty; var factor = TexContext.Scale / 2; var margin = useMargin ? TEXConfiguration.main.NegateMargin * factor : 0; var thick = TEXConfiguration.main.LineThickness * factor; var baseBox = BaseAtom.CreateBox(); var result = HorizontalBox.Get(); var negateBox = StrikeBox.Get(baseBox.height, baseBox.width, baseBox.depth, margin, thick, (StrikeBox.StrikeMode)mode, offsetM, offsetP); negateBox.shift = baseBox.shift; result.Add(negateBox); result.Add(StrutBox.Get(-baseBox.width, 0, 0, 0)); result.Add(baseBox); return result; }
public override Box CreateBox() { var defaultLineThickness = TEXConfiguration.main.LineThickness * TexContext.Scale; // Create box for base atom. var baseBox = BaseAtom == null ? StrutBox.Empty : BaseAtom.CreateBox(); // Create result box. var resultBox = VerticalBox.Get(); resultBox.Add(baseBox); resultBox.Add(StrutBox.Get(0, 3 * defaultLineThickness, 0, 0)); resultBox.Add(HorizontalRule.Get(defaultLineThickness, baseBox.width, 0)); resultBox.depth = baseBox.depth + 5 * defaultLineThickness; resultBox.height = baseBox.height; return(resultBox); }
public override Box CreateBox(TexEnvironment environment) { if (IsTextSymbol) { ((CharSymbol)Atom).IsTextSymbol = true; } var resultBox = Atom.CreateBox(environment); //TODO: Разобраться с надстрочными знаками! if (Atom.Type == TexAtomType.Accent) { resultBox.Width = 0; } if (IsTextSymbol) { ((CharSymbol)Atom).IsTextSymbol = false; } return(resultBox); }
public override Box CreateBox(TexStyle style) { // This SizeBox doesn't need start..end block, since we can do the change on RenderSizeFactor instead if (BaseAtom == null) { return(StrutBox.Empty); } else { var oldSize = TexUtility.RenderSizeFactor; var nan = float.IsNaN(Size); var size = nan ? 1f : Size; TexUtility.RenderSizeFactor = size; var box = BaseAtom.CreateBox(nan ? TexStyle.Display : style); box.shift += Offset; TexUtility.RenderSizeFactor = oldSize; return(box); } }
public override Box CreateBox(TexStyle style) { if (BaseAtom == null) { return(StrutBox.Empty); } var factor = TexUtility.SizeFactor(style) / 2; var margin = useMargin ? TEXConfiguration.main.NegateMargin * factor : 0; var thick = TEXConfiguration.main.LineThickness * factor; var baseBox = BaseAtom.CreateBox(style); var result = HorizontalBox.Get(); var negateBox = StrikeBox.Get(baseBox.height, baseBox.width, baseBox.depth, margin, thick, (StrikeBox.StrikeMode)mode, offsetM, offsetP); negateBox.shift = baseBox.shift; result.Add(negateBox); result.Add(StrutBox.Get(-baseBox.width, 0, 0, 0)); result.Add(baseBox); return(result); }
public override Box CreateBox() { float lineHeight = lineThickness * TexContext.Scale; // Create boxes for numerator and demoninator atoms, and make them of equal width. TexContext.Environment.Push(TexUtility.GetNumeratorStyle()); var numeratorBox = numerator == null ? StrutBox.Empty : numerator.CreateBox(); TexContext.Environment.Pop(); TexContext.Environment.Push(TexUtility.GetDenominatorStyle()); var denominatorBox = denominator == null ? StrutBox.Empty : denominator.CreateBox(); TexContext.Environment.Pop(); float maxWidth = (numeratorBox.width < denominatorBox.width ? denominatorBox.width : numeratorBox.width) + TEXConfiguration.main.FractionMargin * TexContext.Scale; numeratorBox = HorizontalBox.Get(numeratorBox, maxWidth, numeratorAlignment); denominatorBox = HorizontalBox.Get(denominatorBox, maxWidth, denominatorAlignment); // Calculate preliminary shift-up and shift-down amounts. float shiftUp, shiftDown; var styleFactor = TexContext.Scale; if (TexContext.Environment.value >= TexEnvironment.Text) { styleFactor *= TEXConfiguration.main.FractionNarrowFactor; } shiftUp = TEXConfiguration.main.NumeratorShift * styleFactor; shiftDown = TEXConfiguration.main.DenominatorShift * styleFactor; // Create result box. var resultBox = VerticalBox.Get(); // add box for numerator. resultBox.Add(numeratorBox); // Calculate clearance and adjust shift amounts. //var axis = TEXConfiguration.main.AxisHeight * TexContext.Scale; // Calculate clearance amount. float clearance = lineHeight > 0 ? TEXConfiguration.main.FractionGap : TEXConfiguration.main.FractionGapNoLine; // Adjust shift amounts. var kern1 = shiftUp - numeratorBox.depth; var kern2 = shiftDown - denominatorBox.height; var delta1 = clearance - kern1; var delta2 = clearance - kern2; if (delta1 > 0) { shiftUp += delta1; kern1 += delta1; } if (delta2 > 0) { shiftDown += delta2; kern2 += delta2; } if (lineHeight > 0) { // Draw fraction line. resultBox.Add(StrutBox.Get(0, kern1, 0, 0)); resultBox.Add(HorizontalRule.Get(lineHeight, numeratorBox.width, 0)); resultBox.Add(StrutBox.Get(0, kern2, 0, 0)); } else { // Do not draw fraction line. var kern = kern1 + kern2; resultBox.Add(StrutBox.Get(0, kern, 0, 0)); } // add box for denominator. resultBox.Add(denominatorBox); // Adjust height and depth of result box. resultBox.height = shiftUp + numeratorBox.height; resultBox.depth = shiftDown + lineHeight + denominatorBox.depth; TexUtility.CentreBox(resultBox); return(resultBox); }
public override Box CreateBox(TexEnvironment environment) => Atom.CreateBox(environment);