Beispiel #1
0
        public static Texture2D DrawFontToTexture(IFont font)
        {
            var text = TextureRenderSurface.CreateCustomSize(BitsyUnityUtils.TEXTUREFONT_DIM, BitsyUnityUtils.TEXTUREFONT_DIM);

            text.FillSurface(BitsyGame.Color.Black);

            for (int i = 0; i < 256; i++)
            {
                var gfx = font.GetCharGfx((char)i);
                int x   = (i % BitsyUnityUtils.TEXTUREFONT_FONTTILE_EDGE_CNT) * BitsyUnityUtils.TEXTUREFONT_FONTTILE_DIM;
                int y   = (i / BitsyUnityUtils.TEXTUREFONT_FONTTILE_EDGE_CNT) * BitsyUnityUtils.TEXTUREFONT_FONTTILE_DIM;
                gfx.Draw(0, x + 1, y, BitsyGame.Color.White, text);
            }

            return(text.Texture);
        }