Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 public OrderedBidiRun(DrawableTextRun run, sbyte level)
 {
     Run   = run;
     Level = level;
 }