Esempio n. 1
0
 private float DrawChar(TextureFontCache font, int c, float x, float y, float maxX)
 {
     font.DrawChar(c, out var b, out var k, out var ax, out var h);
     x += k;
     if (x + b.Width > maxX)
     {
         return(maxX);
     }
     if (b.Bitmap != null)
     {
         //Non-space character
         DrawTextureInternal(b.Bitmap, x, y, b.Width, b.Height, b.X, b.Y, b.Width, b.Height, 0, 0, 0);
     }
     return(x + ax);
 }
Esempio n. 2
0
        public void DrawString(TextureFontCache font, string str, float x, float y, float maxWidth)
        {
            CheckPipeline();
            font.CacheString(str);
            var drawX = x;
            var maxX  = x + maxWidth;

            for (int i = 0; i < str.Length && drawX < maxX; ++i)
            {
                if (i < str.Length - 1 && Char.IsSurrogatePair(str[i], str[i + 1]))
                {
                    drawX = DrawChar(font, str[i] | str[i + 1] << 16, drawX, y, maxX);
                    i    += 1;
                }
                else
                {
                    drawX = DrawChar(font, str[i], drawX, y, maxX);
                }
            }
        }