private static IRtPureSpan CreatePureSpan(IRtSpanStyle styleProto, string initialText = "") { var span = AmFactory.Create <RtPureSpan>(); span.Style = styleProto.CloneTyped(); span.Text = initialText; return(span); }
public void CopyFrom(IRtSpanStyle other) { FontFamily = other.FontFamily; FontDecoration = other.FontDecoration; Size = other.Size; TextColor = other.TextColor; HighlightGroup = other.HighlightGroup; }
private static IRtParagraph CreatePara(IRtParagraphStyle paraStyleProto, IRtSpanStyle spanStyleProto) { var para = AmFactory.Create <RtParagraph>(); para.Style = paraStyleProto.CloneTyped(); para.Spans.Add(CreatePureSpan(spanStyleProto)); return(para); }
private static IRtPureSpan CreateSpan(string text, IRtSpanStyle style) { var span = AmFactory.Create <RtPureSpan>(); span.Text = text; span.Style = style; return(span); }
private static IRtEmbeddingSpan CreateEmbeddingSpan(IRtSpanStyle styleProto, string embeddingType, string initialSource = "") { var span = AmFactory.Create <RtEmbeddingSpan>(); span.Style = styleProto.CloneTyped(); span.EmbeddingType = embeddingType; span.SourceCode = initialSource; return(span); }
private bool EqualsNotNull([NotNull] IRtSpanStyle other) { return (FontFamily == other.FontFamily && FontDecoration == other.FontDecoration && Size == other.Size && TextColor == other.TextColor && HighlightGroup == other.HighlightGroup); }
public Size2 MeasureString(string str, IRtSpanStyle style) { var etoFontFamily = fontFamilyCache.GetFontFamily(style.FontFamily); Converters.ToEto(style.FontDecoration, out var etoStyle, out var etoDecoration); var etoFont = new Font(etoFontFamily, style.Size, etoStyle, etoDecoration); return(Converters.ToClarity(graphics.MeasureString(etoFont, str))); }
public RichTextHeadlessEditor(IRichText text) { this.text = text; defaultParaStyle = AmFactory.Create <RtParagraphStyle>(); defaultSpanStyle = AmFactory.Create <RtSpanStyle>(); inputSpanStyle = AmFactory.Create <RtSpanStyle>(); NormalizeText(text, defaultParaStyle, defaultSpanStyle); MoveCursor(0, false); }
public bool Equals(IRtSpanStyle other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(EqualsNotNull(other)); }
private bool TryParseAndRender(string text, IRtSpanStyle style, out byte[] pngBytes, out string error) { try { var formula = parser.Parse(text); pngBytes = formula.RenderToPng(1.6 * style.Size, 0, 0, "Arial"); error = null; return(true); } catch (Exception ex) { pngBytes = null; error = ex.Message; return(false); } }
private static void NormalizePara(IRtParagraph para, IRtSpanStyle prevSpanStyle) { if (para.LayoutTextLength == 0) { if (para.Spans.IsEmptyL()) { para.Spans.Add(CreatePureSpan(prevSpanStyle)); } else { for (var i = para.Spans.Count - 1; i >= 1; i--) { para.Spans.RemoveAt(i); } } } else { for (var i = para.Spans.Count - 1; i >= 0; i--) { if (para.Spans[i].IsEmpty) { para.Spans.RemoveAt(i); } } } for (var i = para.Spans.Count - 2; i >= 0; i--) { if (para.Spans[i] is IRtPureSpan span1 && para.Spans[i + 1] is IRtPureSpan span2 && span1.Style.Equals(span2.Style)) { span1.Text += span2.Text; para.Spans.RemoveAt(i + 1); } } }
private void FlushBullet(BuildingContext context, Vector2 firstSpanPoint, string bulletStr, IRtSpanStyle style) { var size = measurer.MeasureString(bulletStr, style); var otherCorner = firstSpanPoint - size.ToVector(); context.ExternalLayoutSpans.Add(new RichTextBoxLayoutSpan { Text = bulletStr, Bounds = new AaRectangle2(otherCorner, firstSpanPoint), Style = style }); }
protected RtPureSpan() { Text = ""; Style = AmFactory.Create <RtSpanStyle>(); }
public Size2 GetCharSize(char ch, IRtSpanStyle style) { return(charSizes.GetOrAdd(Tuples.Pair(ch, style), x => MeasureString(x.First.ToString(), x.Second))); }
public Size2 MeasureString(string str, IRtSpanStyle style) { throw new System.NotImplementedException(); }
public TextImageAtom(string text, IRtSpanStyle style, bool isBullet = false) { Text = text; Style = style; IsBullet = isBullet; }
public Size2 GetCharSize(char ch, IRtSpanStyle style) { throw new System.NotImplementedException(); }
private static void NormalizeText(IRichText text, IRtParagraphStyle defaultParaStyle, IRtSpanStyle defaultSpanStyle) { if (text.Paragraphs.IsEmptyL()) { text.Paragraphs.Add(CreatePara(defaultParaStyle, defaultSpanStyle)); } NormalizePara(text.Paragraphs[0], defaultSpanStyle); for (var i = 1; i < text.Paragraphs.Count; i++) { NormalizePara(text.Paragraphs[i], text.Paragraphs[i - 1].Spans.Last().Style); } }