private static double GetBaselineOffset(TextLine textLine, DrawableTextRun textRun) { var baseline = textRun.Baseline; var baselineAlignment = textRun.Properties?.BaselineAlignment; switch (baselineAlignment) { case BaselineAlignment.Top: return(0); case BaselineAlignment.Center: return(textLine.Height / 2 - textRun.Size.Height / 2); case BaselineAlignment.Bottom: return(textLine.Height - textRun.Size.Height); case BaselineAlignment.Baseline: case BaselineAlignment.TextTop: case BaselineAlignment.TextBottom: case BaselineAlignment.Subscript: case BaselineAlignment.Superscript: return(textLine.Baseline - baseline); default: throw new ArgumentOutOfRangeException(nameof(baselineAlignment), baselineAlignment, null); } }
private static sbyte GetRunBidiLevel(DrawableTextRun run, FlowDirection flowDirection) { if (run is ShapedTextCharacters shapedTextCharacters) { return(shapedTextCharacters.BidiLevel); } var defaultLevel = flowDirection == FlowDirection.LeftToRight ? 0 : 1; return((sbyte)defaultLevel); }
public OrderedBidiRun(DrawableTextRun run, sbyte level) { Run = run; Level = level; }