Exemplo n.º 1
0
        /// <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 shaperOptions = new TextShaperOptions(glyphTypeface, fontRenderingEmSize, (sbyte)flowDirection, cultureInfo);

            var shapedBuffer = textShaper.ShapeText(textRun.Text, shaperOptions);

            return(new ShapedTextCharacters(shapedBuffer, textRun.Properties));
        }
Exemplo n.º 2
0
        private static IReadOnlyList <ShapedTextCharacters> ShapeTogether(
            IReadOnlyList <ShapeableTextCharacters> textRuns, ReadOnlySlice <char> text, TextShaperOptions options)
        {
            var shapedRuns = new List <ShapedTextCharacters>(textRuns.Count);

            var shapedBuffer = TextShaper.Current.ShapeText(text, options);

            for (var i = 0; i < textRuns.Count; i++)
            {
                var currentRun = textRuns[i];

                var splitResult = shapedBuffer.Split(currentRun.Text.Length);

                shapedRuns.Add(new ShapedTextCharacters(splitResult.First, currentRun.Properties));

                shapedBuffer = splitResult.Second !;
            }

            return(shapedRuns);
        }
Exemplo n.º 3
0
 /// <inheritdoc cref="ITextShaperImpl.ShapeText"/>
 public ShapedBuffer ShapeText(ReadOnlySlice <char> text, TextShaperOptions options)
 {
     return(_platformImpl.ShapeText(text, options));
 }