/// <inheritdoc/>
        public override Size2 GetKerningInfo(ref StringSegment text1, Int32 ix1, ref StringSegment text2, Int32 ix2)
        {
            var source1 = new StringSegmentSource(text1);
            var source2 = new StringSegmentSource(text2);

            return(GetKerningInfo(ref source1, ix1, ref source2, ix2));
        }
        /// <summary>
        /// Creates a <see cref="StringSegment"/> structure that represents this string source.
        /// </summary>
        /// <returns>The <see cref="StringSegment"/> that was created.</returns>
        public StringSegment CreateStringSegment()
        {
            switch (ValueType)
            {
            case StringSourceUnionValueType.String:
                return(StringSource.CreateStringSegment());

            case StringSourceUnionValueType.StringBuilder:
                return(StringBuilderSource.CreateStringSegment());

            case StringSourceUnionValueType.StringSegment:
                return(StringSegmentSource.CreateStringSegment());

            case StringSourceUnionValueType.ShapedString:
            case StringSourceUnionValueType.ShapedStringBuilder:
            case StringSourceUnionValueType.ShapedStringSegment:
                throw new NotSupportedException();

            default:
                throw new InvalidOperationException();
            }
        }
        /// <summary>
        /// Creates a <see cref="StringSegment"/> structure with the same origin as this
        /// string source but a different character range. This method only differs from
        /// the <see cref="CreateStringSegmentFromSubstring(Int32, Int32)"/> method if this
        /// string source represents a substring of some other, larger string.
        /// </summary>
        /// <param name="start">The index of the first character in the created segment.</param>
        /// <param name="length">The number of characters in the created segment.</param>
        /// <returns>The <see cref="StringSegment"/> structure that was created.</returns>
        public StringSegment CreateStringSegmentFromSameOrigin(Int32 start, Int32 length)
        {
            switch (ValueType)
            {
            case StringSourceUnionValueType.String:
                return(StringSource.CreateStringSegmentFromSameOrigin(start, length));

            case StringSourceUnionValueType.StringBuilder:
                return(StringBuilderSource.CreateStringSegmentFromSameOrigin(start, length));

            case StringSourceUnionValueType.StringSegment:
                return(StringSegmentSource.CreateStringSegmentFromSameOrigin(start, length));

            case StringSourceUnionValueType.ShapedString:
            case StringSourceUnionValueType.ShapedStringBuilder:
            case StringSourceUnionValueType.ShapedStringSegment:
                throw new NotSupportedException();

            default:
                throw new InvalidOperationException();
            }
        }
        /// <inheritdoc/>
        public override Size2 GetHypotheticalKerningInfo(ref StringSegment text, Int32 ix, Int32 c2)
        {
            var source = new StringSegmentSource(text);

            return(GetHypotheticalKerningInfo(ref source, ix, c2));
        }
        /// <inheritdoc/>
        public override Size2 GetKerningInfo(ref StringSegment text, Int32 ix)
        {
            var source = new StringSegmentSource(text);

            return(GetKerningInfo(ref source, ix));
        }
        /// <inheritdoc/>
        public override Size2 MeasureGlyphWithoutKerning(ref StringSegment text, Int32 ix)
        {
            var source = new StringSegmentSource(text);

            return(MeasureGlyphWithoutKerning(ref source, ix));
        }
        /// <inheritdoc/>
        public override Size2 MeasureGlyphWithHypotheticalKerning(ref StringSegment text, Int32 ix, Int32 c2)
        {
            var source = new StringSegmentSource(text);

            return(MeasureGlyphWithHypotheticalKerning(ref source, ix, c2));
        }
        /// <inheritdoc/>
        public override Size2 MeasureString(ref StringSegment text, Int32 start, Int32 count)
        {
            var source = new StringSegmentSource(text);

            return(MeasureString(ref source, start, count));
        }
        /// <inheritdoc/>
        public override Size2 MeasureString(ref StringSegment text)
        {
            var source = new StringSegmentSource(text);

            return(MeasureString(ref source, 0, text.Length));
        }