コード例 #1
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);
        }
コード例 #2
0
ファイル: SpriteFont.cs プロジェクト: Gaopest/fightclub
        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);
        }