/// <summary>
        /// Compute a shaped glyph run object from specified glyph-based info
        /// </summary>
        internal sealed override GlyphRun ComputeShapedGlyphRun(
            Point origin,
            char[]                   characterString,
            ushort[]                 clusterMap,
            ushort[]                 glyphIndices,
            IList <double> glyphAdvances,
            IList <Point> glyphOffsets,
            bool rightToLeft,
            bool sideways
            )
        {
            Invariant.Assert(_shapeTypeface != null);
            Invariant.Assert(glyphIndices != null);
            // Device fonts are only used through the LS non-glyphed code path. Only when a DigitCulture is set
            // will a potential device font be ignored and come through shaping.
            Invariant.Assert(_shapeTypeface.DeviceFont == null || _textItem.DigitCulture != null);

            bool[] caretStops = null;

            if (clusterMap != null &&
                (HasExtendedCharacter || NeedsCaretInfo)
                )
            {
                caretStops = new bool[clusterMap.Length + 1];

                // caret stops at cluster boundaries, the first and the last entries are always set
                caretStops[0] = true;
                caretStops[clusterMap.Length] = true;

                ushort lastGlyph = clusterMap[0];

                for (int i = 1; i < clusterMap.Length; i++)
                {
                    ushort glyph = clusterMap[i];

                    if (glyph != lastGlyph)
                    {
                        caretStops[i] = true;
                        lastGlyph     = glyph;
                    }
                }
            }

            return(GlyphRun.TryCreate(
                       _shapeTypeface.GlyphTypeface,
                       (rightToLeft ? 1 : 0),
                       sideways,
                       _emSize,
                       glyphIndices,
                       origin,
                       glyphAdvances,
                       glyphOffsets,
                       characterString,
                       null,
                       clusterMap,
                       caretStops,
                       XmlLanguage.GetLanguage(CultureMapper.GetSpecificCulture(_properties.CultureInfo).IetfLanguageTag),
                       _textFormattingMode
                       ));
        }