/// <summary> /// Registers the specified style with the command stream and returns its resulting index. /// </summary> private Int16 RegisterStyleWithCommandStream(TextLayoutCommandStream output, StringSegment name, out TextStyle style) { if (!registeredStyles.TryGetValue(name, out style)) throw new InvalidOperationException(UltravioletStrings.UnrecognizedStyle.Format(name)); return output.RegisterStyle(name, style); }
/// <summary> /// Pushes a style onto the style stack. /// </summary> /// <param name="style">The style to push onto the stack.</param> /// <param name="bold">A value indicating whether the current font face is bold.</param> /// <param name="italic">A value indicating whether the current font face is italic.</param> private void PushStyle(TextStyle style, ref Boolean bold, ref Boolean italic) { var instance = new TextStyleInstance(style, bold, italic); styleStack.Push(instance); if (style.Font != null) PushFont(style.Font); if (style.Bold.HasValue) bold = style.Bold.Value; if (style.Italic.HasValue) italic = style.Italic.Value; }
/// <summary> /// Initializes a new instance of the <see cref="TextStyleInstance"/> structure. /// </summary> /// <param name="style">The style that was applied.</param> /// <param name="bold">A value indicating whether the font was bold before the style was applied.</param> /// <param name="italic">A value indicating whether the font was italic before the style was applied.</param> public TextStyleInstance(TextStyle style, Boolean bold, Boolean italic) { this.style = style; this.bold = bold; this.italic = italic; }
/// <summary> /// Registers a style with the specified name. /// </summary> /// <param name="name">The name of the style to register.</param> /// <param name="style">The style to register.</param> public void RegisterStyle(String name, TextStyle style) { Contract.RequireNotEmpty(name, "name"); registeredStyles.Add(name, style); }
/// <summary> /// Registers a style with the command stream. /// </summary> /// <param name="name">The name of the style to register.</param> /// <param name="style">The style to register under the specified name.</param> /// <returns>The index of the specified style within the command stream's internal registry.</returns> public Int16 RegisterStyle(StringSegment name, TextStyle style) => (resources = resources ?? new TextLayoutCommandStreamResources()).RegisterStyle(name, style);