Beispiel #1
0
        protected void createTextureForChar(Char letter)
        {
            int  width, height, xOffset, yOffset;
            uint index;

            if (letter == ' ')
            {
                index = _font.FindGlyphIndex('-');
            }
            else
            {
                index = _font.FindGlyphIndex(letter);
            }
            byte[] data = _font.GetGlyphBitmap(index, _scale, _scale, out width, out height, out xOffset, out yOffset);

            Color[]   colorData = new Color[width * height];
            Texture2D texture   = new Texture2D(_graphicsDeviceManager.GraphicsDevice, width, height);

            if (letter != ' ')
            {
                for (int i = 0; i < colorData.Length; i++)
                {
                    colorData[i] = new Color(data[i], data[i], data[i], data[i]);
                }
            }
            texture.SetData(colorData);
            _textureForChar[letter] = texture;
            _offsetForChar[letter]  = new Vector2(xOffset, yOffset);
        }