Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SpriteFont"/> class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="faceRegular">The <see cref="SpriteFontFace"/> that represents the font's regular style.</param>
        /// <param name="faceBold">The <see cref="SpriteFontFace"/> that represents the font's bold style.</param>
        /// <param name="faceItalic">The <see cref="SpriteFontFace"/> that represents the font's italic style.</param>
        /// <param name="faceBoldItalic">The <see cref="SpriteFontFace"/> that represents the font's bold/italic style.</param>
        public SpriteFont(UltravioletContext uv, SpriteFontFace faceRegular, SpriteFontFace faceBold, SpriteFontFace faceItalic, SpriteFontFace faceBoldItalic)
            : base(uv)
        {
            uv.ValidateResource(faceRegular);
            uv.ValidateResource(faceBold);
            uv.ValidateResource(faceItalic);
            uv.ValidateResource(faceBoldItalic);

            if (faceRegular == null && faceBold == null && faceItalic == null && faceBoldItalic == null)
                throw new ArgumentException(UltravioletStrings.InvalidFontFaces);

            this.faceRegular = faceRegular;
            this.faceBold = faceBold;
            this.faceItalic = faceItalic;
            this.faceBoldItalic = faceBoldItalic;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SpriteFont"/> class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="faceRegular">The <see cref="SpriteFontFace"/> that represents the font's regular style.</param>
        /// <param name="faceBold">The <see cref="SpriteFontFace"/> that represents the font's bold style.</param>
        /// <param name="faceItalic">The <see cref="SpriteFontFace"/> that represents the font's italic style.</param>
        /// <param name="faceBoldItalic">The <see cref="SpriteFontFace"/> that represents the font's bold/italic style.</param>
        public SpriteFont(UltravioletContext uv, SpriteFontFace faceRegular, SpriteFontFace faceBold, SpriteFontFace faceItalic, SpriteFontFace faceBoldItalic)
            : base(uv)
        {
            uv.ValidateResource(faceRegular);
            uv.ValidateResource(faceBold);
            uv.ValidateResource(faceItalic);
            uv.ValidateResource(faceBoldItalic);

            if (faceRegular == null && faceBold == null && faceItalic == null && faceBoldItalic == null)
            {
                throw new ArgumentException(UltravioletStrings.InvalidFontFaces);
            }

            this.faceRegular    = faceRegular;
            this.faceBold       = faceBold;
            this.faceItalic     = faceItalic;
            this.faceBoldItalic = faceBoldItalic;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpriteFont"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="face">The <see cref="SpriteFontFace"/> that constitutes the font.</param>
 public SpriteFont(UltravioletContext uv, SpriteFontFace face)
     : this(uv, face, face, face, face)
 {
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpriteFont"/> class.
 /// </summary>
 /// <param name="uv">The Ultraviolet context.</param>
 /// <param name="face">The <see cref="SpriteFontFace"/> that constitutes the font.</param>
 public SpriteFont(UltravioletContext uv, SpriteFontFace face)
     : this(uv, face, face, face, face)
 {
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Draws a string of text.
        /// </summary>
        /// <param name="fontFace">The <see cref="SpriteFontFace"/> with which to draw the text.</param>
        /// <param name="text">The text to draw.</param>
        /// <param name="position">The text's position.</param>
        /// <param name="color">The text's color.</param>
        /// <param name="rotation">The text's rotation in radians.</param>
        /// <param name="origin">The text's point of origin relative to its top-left corner.</param>
        /// <param name="scale">The text's scale factor.</param>
        /// <param name="effects">The text's rendering effects.</param>
        /// <param name="layerDepth">The text's layer depth.</param>
        public void DrawString(SpriteFontFace fontFace, StringSegment text, Vector2 position, Color color, Single rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, Single layerDepth)
        {
            if (SpriteBatch == null)
                throw new InvalidOperationException(PresentationStrings.DrawingContextDoesNotHaveSpriteBatch);

            SpriteBatch.DrawString(fontFace, text, position, color * Opacity, rotation, origin, scale, effects, layerDepth);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Draws a string of text.
        /// </summary>
        /// <param name="fontFace">The <see cref="SpriteFontFace"/> with which to draw the text.</param>
        /// <param name="text">The text to draw.</param>
        /// <param name="position">The text's position.</param>
        /// <param name="color">The text's color.</param>
        public void DrawString(SpriteFontFace fontFace, StringSegment text, Vector2 position, Color color)
        {
            if (SpriteBatch == null)
                throw new InvalidOperationException(PresentationStrings.DrawingContextDoesNotHaveSpriteBatch);

            SpriteBatch.DrawString(fontFace, text, position, color * Opacity);
        }