public void DrawString(YSpriteFont font, string text, Vector2 position, float font_size, 
     Vector2? area = null, Color? color = null, FontJustification justification = FontJustification.Left)
 {
     position.X = (int)position.X;
     position.Y = (int)position.Y + font.Line0VerticalOffset;
     Color c = (color.HasValue) ? color.Value : new Color(1,1,1,1f);
     Vector2 a = (area.HasValue ? area.Value : Vector2.Zero);
     InternalBeginDrawString(font.Texture);
     font.DrawInto(this, text, position, c, a, justification, font_size);
     InternalEndDrawString();
 }
Exemplo n.º 2
0
 public void Draw(YSpriteBatch spritebatch, YSpriteFont font, Rectangle area, string text, float font_size, FontJustification justification, Color color)
 {
     if (text != null && text != string.Empty)
     {
         // if (m_InternalCaption != text)
         {
             m_InternalCaption = text;
             m_InternalCaptionWithLineBreaks = font.BreakStringIntoLines(m_InternalCaption, area.Width, font_size);
         }
         spritebatch.DrawString(font, m_InternalCaptionWithLineBreaks, new Vector2(area.X, area.Y), font_size, new Vector2(area.Width, area.Height), color: color, justification: justification);
     }
 }
Exemplo n.º 3
0
        private static YSpriteFont InternalReadSpriteFont(GraphicsDevice device, BinaryFileReader reader, List<Encoder> encoders)
        {
            Texture2D texture = (Texture2D)InternalReadObject(device, reader, encoders);
            List<Rectangle> glyphBounds = (List<Rectangle>)InternalReadObject(device, reader, encoders);
            List<Rectangle> cropping = (List<Rectangle>)InternalReadObject(device, reader, encoders);
            List<char> characters = (List<char>)InternalReadObject(device, reader, encoders);
            int lineSpacing = reader.ReadInt();
            float spacing = reader.ReadFloat();
            List<Vector3> kerning = (List<Vector3>)InternalReadObject(device, reader, encoders);
            char? defaultChar = null;
            int default_char = (int)reader.ReadCharUTF8();
            if (default_char != 0)
                defaultChar = (char)default_char;

            YSpriteFont ysf = new YSpriteFont(texture, glyphBounds, cropping, characters, lineSpacing, spacing, kerning, defaultChar);
            return ysf;
        }
Exemplo n.º 4
0
 public void AddFont(string name, YSpriteFont font)
 {
     Fonts.Add(name, font);
 }