/// <summary>
        /// Creates a <see cref="ShapedStringSegment"/> structure with the same origin as this
        /// string source but a different character range. This method only differs from
        /// the <see cref="CreateShapedStringSegmentFromSubstring(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="ShapedStringSegment"/> structure that was created.</returns>
        public ShapedStringSegment CreateShapedStringSegmentFromSameOrigin(Int32 start, Int32 length)
        {
            switch (ValueType)
            {
            case StringSourceUnionValueType.String:
            case StringSourceUnionValueType.StringBuilder:
            case StringSourceUnionValueType.StringSegment:
                throw new NotSupportedException();

            case StringSourceUnionValueType.ShapedString:
                return(ShapedStringSource.CreateShapedStringSegmentFromSameOrigin(start, length));

            case StringSourceUnionValueType.ShapedStringBuilder:
                return(ShapedStringBuilderSource.CreateShapedStringSegmentFromSameOrigin(start, length));

            case StringSourceUnionValueType.ShapedStringSegment:
                return(ShapedStringSegmentSource.CreateShapedStringSegmentFromSameOrigin(start, length));

            default:
                throw new InvalidOperationException();
            }
        }
        /// <summary>
        /// Creates a <see cref="ShapedStringSegment"/> structure that represents this string source.
        /// </summary>
        /// <returns>The <see cref="ShapedStringSegment"/> that was created.</returns>
        public ShapedStringSegment CreateShapedStringSegment()
        {
            switch (ValueType)
            {
            case StringSourceUnionValueType.String:
            case StringSourceUnionValueType.StringBuilder:
            case StringSourceUnionValueType.StringSegment:
                throw new NotSupportedException();

            case StringSourceUnionValueType.ShapedString:
                return(ShapedStringSource.CreateShapedStringSegment());

            case StringSourceUnionValueType.ShapedStringBuilder:
                return(ShapedStringBuilderSource.CreateShapedStringSegment());

            case StringSourceUnionValueType.ShapedStringSegment:
                return(ShapedStringSegmentSource.CreateShapedStringSegment());

            default:
                throw new InvalidOperationException();
            }
        }