コード例 #1
0
        public int BakeFontBitmap(float pixelHeight, char firstCodepoint,
                                  BakedChar[] characters, FontBitmap bitmap)
        {
            float scale = GetScaleForPixelHeight(pixelHeight);

            return(BakeFontBitmap(scale, scale, firstCodepoint, characters, bitmap));
        }
コード例 #2
0
 public void MakeGlyphBitmapSubpixel(uint glyphIndex,
                                     float xScale, float yScale, float xShift, float yShift,
                                     FontBitmap bitmap)
 {
     if (bitmap.Buffer == null)
     {
         throw new ArgumentNullException("bitmap.Buffer");
     }
     stb_truetype.stbtt_MakeGlyphBitmapSubpixel(ref _info,
                                                bitmap.StartPointer, bitmap.Width, bitmap.Height, bitmap.Stride,
                                                xScale, yScale, xShift, yShift, glyphIndex);
 }
コード例 #3
0
        public FontBitmap GetResizedBitmap(int width, int height)
        {
            var bitmap = new FontBitmap(width, height);
            int w = Math.Min(width, Width), h = Math.Min(height, Height);

            for (int y = 0; y < h; y++)
            {
                for (int x = 0; x < w; x++)
                {
                    bitmap[x, y] = this[x, y];
                }
            }
            return(bitmap);
        }
コード例 #4
0
        public int BakeFontBitmap(float xScale, float yScale, char firstCodepoint,
                                  BakedChar[] characters, FontBitmap bitmap)
        {
            if (!bitmap.IsValid)
            {
                throw new ArgumentException("bitmap");
            }
            if (characters == null)
            {
                throw new ArgumentNullException("characters");
            }

            return(stb_truetype.stbtt_BakeFontBitmap(ref _info, xScale, yScale,
                                                     bitmap.StartPointer, bitmap.Width, bitmap.Height, bitmap.Stride,
                                                     (int)firstCodepoint, characters.Length,
                                                     new FakePtr <BakedChar>()
            {
                Array = characters
            }));
        }
コード例 #5
0
        // generates square textures ... minimalHeight can be used to crop if desired
        public FontBitmap BakeFontBitmap(float pixelHeight, char firstCodepoint,
                                         BakedChar[] characters, out int minimalHeight)
        {
            int size = 16;

            if (characters.Length == 0)
            {
                minimalHeight = 0; return(new FontBitmap(0, 0));
            }

            while (true)
            {
                var bitmap = new FontBitmap(size, size);
                int result = BakeFontBitmap(pixelHeight, firstCodepoint, characters, bitmap);
                if (result > 0)
                {
                    minimalHeight = result; return(bitmap);
                }

                size *= 2;
            }
        }
コード例 #6
0
 public void MakeGlyphBitmap(int glyphIndex, float xScale, float yScale, FontBitmap bitmap)
 {
     MakeGlyphBitmapSubpixel(glyphIndex, xScale, yScale, 0, 0, bitmap);
 }