/// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutToken"/> structure.
 /// </summary>
 /// <param name="text">The token's text.</param>
 /// <param name="bounds">The token's bounds relative to its layout region.</param>
 /// <param name="fontFace">The token's font face.</param>
 /// <param name="icon">The token's icon.</param>
 /// <param name="glyphShader">The token's glyph shader.</param>
 /// <param name="color">The token's color.</param>
 internal TextLayoutToken(StringSegment text, Rectangle bounds, SpriteFontFace fontFace, TextIconInfo? icon, GlyphShader glyphShader, Color? color)
 {
     this.text = text;
     this.bounds = bounds;
     this.fontFace = fontFace;
     this.icon = icon;
     this.glyphShader = glyphShader;
     this.color = color;
 }
        /// <summary>
        /// Registers the specified icon with the command stream and returns its resulting index.
        /// </summary>
        private Int16 RegisterIconWithCommandStream(TextLayoutCommandStream output, StringSegment name, out TextIconInfo icon)
        {
            if (!registeredIcons.TryGetValue(name, out icon))
                throw new InvalidOperationException(UltravioletStrings.UnrecognizedIcon.Format(name));

            return output.RegisterIcon(name, icon);
        }
 /// <summary>
 /// Registers an icon with the command stream.
 /// </summary>
 /// <param name="name">The name of the icon to register.</param>
 /// <param name="icon">The icon to register under the specified name.</param>
 /// <returns>The index of the specified icon within the command stream's internal registry.</returns>
 public Int16 RegisterIcon(StringSegment name, TextIconInfo icon) =>
     (resources = resources ?? new TextLayoutCommandStreamResources()).RegisterIcon(name, icon);