Ejemplo n.º 1
0
 public SpriteFontSimple(GraphicsDevice gdevice, Font font)
 {
     _font   = font;
     _device = gdevice;
     //if (_font.maxcharheight <= 16)
     {
         _tex.Add(new Texture2D(gdevice, 512, 512));
         packer = new SimpleRectanglePacker(512, 512);
     }
     //else
     //{
     //    _tex.Add(new Texture2D(gdevice, 1024, 1024));
     //    packer = new SimpleRectanglePacker(1024, 1024);
     //}
 }
Ejemplo n.º 2
0
 public SpriteFontDoubleColor(GraphicsDevice gdevice, Font font, Color fillcolor, Color bordercolor)
 {
     _font        = font;
     _device      = gdevice;
     _fillcolor   = fillcolor;
     _bordercolor = bordercolor;
     //if (_font.maxcharheight <= 16)
     {
         _tex.Add(new Texture2D(gdevice, 512, 512));
         packer = new SimpleRectanglePacker(512, 512);
     }
     //else
     //{
     //    _tex.Add( new Texture2D(gdevice, 1024, 1024));
     //    packer = new SimpleRectanglePacker(1024, 1024);
     //}
 }
Ejemplo n.º 3
0
        void FillChar(char c)
        {
            if (charposs.ContainsKey(c))
            {
                return;
            }
            UInt32[] data;
            var      size =
                _font.GetCharData(c, out data);
            Point     p;
            var       b = packer.TryPack(size.Width, size.Height, out p);
            Texture2D tex;

            if (b)
            {
                charposs[c] = new charpos(
                    new Rectangle(p.X, p.Y, size.Width, size.Height)
                    , _tex.Count - 1
                    );
            }
            else
            {
                //if (_font.maxcharheight <= 16)
                {
                    _tex.Add(new Texture2D(_device, 512, 512));
                    packer = new SimpleRectanglePacker(512, 512);
                }
                //else
                //{
                //    _tex.Add(new Texture2D(_device, 1024, 1024));
                //    packer = new SimpleRectanglePacker(1024, 1024);
                //}
                packer.TryPack(size.Width, size.Height, out p);
                charposs[c] = new charpos(
                    new Rectangle(p.X, p.Y, size.Width, size.Height)
                    , _tex.Count - 1
                    );
            }
            tex = _tex[_tex.Count - 1];
            tex.SetData <UInt32>(0, charposs[c].src, data, 0, data.Length);
        }