/// <summary> /// Creates a shaped symbol. /// </summary> /// <param name="textRun">The symbol run to shape.</param> /// <param name="flowDirection">The flow direction.</param> /// <returns> /// The shaped symbol. /// </returns> internal static ShapedTextCharacters CreateSymbol(TextRun textRun, FlowDirection flowDirection) { var textShaper = TextShaper.Current; var glyphTypeface = textRun.Properties !.Typeface.GlyphTypeface; var fontRenderingEmSize = textRun.Properties.FontRenderingEmSize; var cultureInfo = textRun.Properties.CultureInfo; var shapedBuffer = textShaper.ShapeText(textRun.Text, glyphTypeface, fontRenderingEmSize, cultureInfo, (sbyte)flowDirection); return(new ShapedTextCharacters(shapedBuffer, textRun.Properties)); }
public bool MoveNext() { Current = _textSource.GetTextRun(_pos); if (Current is null) { return(false); } if (Current.TextSourceLength == 0) { return(false); } _pos += Current.TextSourceLength; return(!(Current is TextEndOfLine)); }
private static bool TryGetLineBreak(TextRun textRun, out LineBreak lineBreak) { lineBreak = default; if (textRun.Text.IsEmpty) { return(false); } var lineBreakEnumerator = new LineBreakEnumerator(textRun.Text); while (lineBreakEnumerator.MoveNext()) { if (!lineBreakEnumerator.Current.Required) { continue; } lineBreak = lineBreakEnumerator.Current; if (lineBreak.PositionWrap >= textRun.Text.Length) { return(true); } //The line breaker isn't treating \n\r as a pair so we have to fix that here. if (textRun.Text[lineBreak.PositionMeasure] == '\n' && textRun.Text[lineBreak.PositionWrap] == '\r') { lineBreak = new LineBreak(lineBreak.PositionMeasure, lineBreak.PositionWrap + 1, lineBreak.Required); } return(true); } return(false); }
public TextRunDebuggerProxy(TextRun textRun) { _textRun = textRun; }