Beispiel #1
0
 public Text(string name, UltravioletFont spriteFont, string text)
 {
     _name         = name;
     _text         = text;
     _textRenderer = new TextRenderer();
     _settings     = new TextLayoutSettings(spriteFont, null, null, TextFlags.Standard);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TextStyle"/> class.
 /// </summary>
 /// <param name="font">The font which is applied by this style, if any.</param>
 /// <param name="bold">A value indicating whether this style makes the current font bold.</param>
 /// <param name="italic">A value indicating whether this style makes the current font italic.</param>
 /// <param name="color">The color which is applied by this style, if any.</param>
 /// <param name="glyphShaders">The glyph shaders which are applied by this style, if any.</param>
 public TextStyle(UltravioletFont font, Boolean?bold, Boolean?italic, Color?color, params GlyphShader[] glyphShaders)
 {
     this.Font         = font;
     this.Bold         = bold;
     this.Italic       = italic;
     this.Color        = color;
     this.GlyphShaders = new TextStyleGlyphShaderCollection(glyphShaders);
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
 /// <param name="fontStyle">The initial font style.</param>
 /// <param name="initialLayoutStyle">The name of the initial layout style, or <see langword="null"/> to use no initial layout style.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, TextLayoutOptions options, UltravioletFontStyle fontStyle, String initialLayoutStyle)
 {
     this.font               = font;
     this.width              = width;
     this.height             = height;
     this.flags              = (flags == 0) ? TextFlags.Standard : flags;
     this.style              = fontStyle;
     this.options            = options;
     this.initialLayoutStyle = initialLayoutStyle;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="TextTable{ViewModelType}"/> class.
        /// </summary>
        /// <param name="renderer">The <see cref="TextRenderer"/> used to lay out and render the table's text.</param>
        /// <param name="width">The table's width in pixels.</param>
        /// <param name="height">The table's height in pixels.</param>
        /// <param name="font">The table's default font.</param>
        public TextTable(TextRenderer renderer, Int32 width, Int32 height, UltravioletFont font)
        {
            Contract.Require(renderer, nameof(renderer));
            Contract.EnsureRange(width >= 0, nameof(width));
            Contract.EnsureRange(height >= 0, nameof(height));
            Contract.Require(font, nameof(font));

            this.renderer = renderer;
            this.width    = width;
            this.height   = height;
            this.font     = font;
            this.rows     = new TextTableRowCollection <ViewModelType>(this);
        }
        /// <summary>
        /// Registers a font with the command stream.
        /// </summary>
        /// <param name="name">The name that identifies the font.</param>
        /// <param name="font">The font to register.</param>
        /// <returns>The index of the font within the command stream's internal registry.</returns>
        public Int16 RegisterFont(StringSegment name, UltravioletFont font)
        {
            Contract.Require(font, nameof(font));

            if (fonts == null)
            {
                fonts = new List <UltravioletFont>();
            }

            if (fontsByName == null)
            {
                fontsByName = new Dictionary <StringSegment, Int16>();
            }

            return(RegisterResource(name, font, fonts, fontsByName));
        }
Beispiel #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
        /// </summary>
        /// <param name="font">The default font.</param>
        /// <param name="width">The width of the layout area.</param>
        /// <param name="height">The height of the layout area.</param>
        /// <param name="flags">A set of flags that specify how to render and align the text.</param>
        /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
        /// <param name="direction">A value indicating the direction in which the text should be laid out.</param>
        /// <param name="script">A value specifying which script is used to draw the text.</param>
        /// <param name="fontStyle">The initial font style.</param>
        /// <param name="initialLayoutStyle">The name of the initial layout style, or <see langword="null"/> to use no initial layout style.</param>
        /// <param name="language">The ISO 639 name of the text language.</param>
        public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, TextLayoutOptions options, TextDirection direction, TextScript script, UltravioletFontStyle fontStyle, String initialLayoutStyle, String language = "en")
        {
            if (direction == TextDirection.TopToBottom || direction == TextDirection.BottomToTop)
            {
                throw new NotSupportedException(UltravioletStrings.UnsupportedTextDirection);
            }

            this.Font               = font;
            this.Width              = width;
            this.Height             = height;
            this.Flags              = (flags == 0) ? TextFlags.Standard : flags;
            this.Style              = fontStyle;
            this.Direction          = direction;
            this.Script             = script;
            this.Options            = options;
            this.InitialLayoutStyle = initialLayoutStyle;
            this.Language           = language;
        }
        /// <summary>
        /// Creates a table from the layout information.
        /// </summary>
        /// <typeparam name="ViewModelType">The type of view model which is bound to this table.</typeparam>
        /// <param name="renderer">The <see cref="TextRenderer"/> used to lay out and render the table's text.</param>
        /// <param name="font">The table's default font.</param>
        /// <returns>The <see cref="TextTable{ViewModelType}"/> that was created.</returns>
        public TextTable <ViewModelType> Create <ViewModelType>(TextRenderer renderer, UltravioletFont font)
        {
            Contract.Require(renderer, nameof(renderer));
            Contract.Require(font, nameof(font));

            var table = new TextTable <ViewModelType>(renderer, description.Width ?? 0, description.Height ?? 0, font);

            if (description.Rows != null)
            {
                foreach (var rowDesc in description.Rows)
                {
                    var row = table.Rows.Add();
                    if (rowDesc.Cells != null)
                    {
                        foreach (var cellDesc in rowDesc.Cells)
                        {
                            var cell = row.Cells.Add();
                            cell.TextFlags = cellDesc.TextFlags;
                            cell.RawText   = cellDesc.Text;
                            cell.Format    = cellDesc.Format;
                            cell.Width     = cellDesc.Width;
                            cell.Height    = cellDesc.Height;

                            if (!String.IsNullOrEmpty(cellDesc.Binding))
                            {
                                cell.Bind(cellDesc.Binding);
                            }

                            cell.Refresh();
                        }
                    }
                }
            }

            return(table);
        }
Beispiel #8
0
 /// <summary>
 /// Registers a font with the command stream.
 /// </summary>
 /// <param name="name">The name of the font to register.</param>
 /// <param name="font">The font to register under the specified name.</param>
 /// <returns>The index of the specified font within the command stream's internal registry.</returns>
 public Int16 RegisterFont(StringSegment name, UltravioletFont font) =>
 (resources = resources ?? new TextLayoutCommandStreamResources()).RegisterFont(name, font);
Beispiel #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
 /// <param name="initialLayoutStyle">The name of the initial layout style, or <see langword="null"/> to use no initial layout style.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, TextLayoutOptions options, String initialLayoutStyle)
     : this(font, width, height, flags, options, UltravioletFontStyle.Regular, initialLayoutStyle)
 {
 }
Beispiel #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
 /// <param name="fontStyle">The initial font style.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, TextLayoutOptions options, UltravioletFontStyle fontStyle)
     : this(font, width, height, flags, options, fontStyle, null)
 {
 }
Beispiel #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="fontStyle">The initial font style.</param>
 /// <param name="initialLayoutStyle">The name of the initial layout style, or <see langword="null"/> to use no initial layout style.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, UltravioletFontStyle fontStyle, String initialLayoutStyle)
     : this(font, width, height, flags, TextLayoutOptions.None, fontStyle, initialLayoutStyle)
 {
 }
Beispiel #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags)
     : this(font, width, height, flags, TextLayoutOptions.None, UltravioletFontStyle.Regular)
 {
 }
Beispiel #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
 /// <param name="direction">A value indicating the direction in which the text should be laid out.</param>
 /// <param name="script">A value specifying which script is used to draw the text.</param>
 /// <param name="initialLayoutStyle">The name of the initial layout style, or <see langword="null"/> to use no initial layout style.</param>
 /// <param name="language">The ISO 639 name of the text language.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, TextLayoutOptions options, TextDirection direction, TextScript script, String initialLayoutStyle, String language = "en")
     : this(font, width, height, flags, options, direction, script, UltravioletFontStyle.Regular, initialLayoutStyle, language)
 {
 }
Beispiel #14
0
 public void PushFont(UltravioletFont font)
 {
     PushScopedStack(FontStack, font);
 }
Beispiel #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags)
     : this(font, width, height, flags, TextLayoutOptions.None, TextDirection.LeftToRight, TextScript.Unknown, UltravioletFontStyle.Regular, null)
 {
 }
Beispiel #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
 /// <param name="fontStyle">The initial font style.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, TextLayoutOptions options, UltravioletFontStyle fontStyle)
     : this(font, width, height, flags, options, TextDirection.LeftToRight, TextScript.Unknown, fontStyle, null)
 {
 }
Beispiel #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
 /// <param name="direction">A value indicating the direction in which the text should be laid out.</param>
 /// <param name="script">A value specifying which script is used to draw the text.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, TextLayoutOptions options, TextDirection direction, TextScript script)
     : this(font, width, height, flags, options, direction, script, UltravioletFontStyle.Regular, null)
 {
 }
Beispiel #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="fontStyle">The initial font style.</param>
 /// <param name="initialLayoutStyle">The name of the initial layout style, or <see langword="null"/> to use no initial layout style.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, UltravioletFontStyle fontStyle, String initialLayoutStyle)
     : this(font, width, height, flags, TextLayoutOptions.None, TextDirection.LeftToRight, TextScript.Unknown, fontStyle, initialLayoutStyle)
 {
 }