public FFTFont( IList<byte> bytes, IList<byte> widthBytes ) { GlyphWidths = new FFTFontWidths( this ); Glyphs = new Glyph[2200]; for( int i = 0; i < 2200; i++ ) { Glyphs[i] = new Glyph( i, widthBytes[i], bytes.Sub( i * 35, (i + 1) * 35 - 1 ) ); } #if DEBUG using ( System.Drawing.Bitmap b = new System.Drawing.Bitmap( 550, 560 ) ) { for ( int i = 0; i < 2200; i++ ) { DrawGlyphOnBitmap( b, Glyphs[i], new System.Drawing.Point( 10 * ( i % 55 ), 14 * ( i / 55 ) ) ); } b.Save( "font.png", System.Drawing.Imaging.ImageFormat.Png ); } #endif }
private void DrawGlyphOnBitmap( System.Drawing.Bitmap b, Glyph g, System.Drawing.Point loc ) { for ( int i = 0; i < g.Pixels.Length; i++ ) { b.SetPixel( loc.X + i % 10, loc.Y + i / 10, colors[(int)g.Pixels[i]] ); } }
private static Glyph DetermineFirstCharacter( IList<Glyph> glyphs, IList<byte> matchBytes, int width ) { Glyph newGlyph = new Glyph( 0, (byte)width, matchBytes ); foreach (Glyph g in glyphs) { if (g.Width > width) continue; for (int x = 0; x < g.Width; x++) { for (int y = 0; y < FFTFont.CharacterHeight; y++) { if (g.Pixels[y * FFTFont.CharacterWidth + x] != newGlyph.Pixels[y * FFTFont.CharacterWidth + x]) { goto mainloop; } } } // All pixels matched return g; mainloop: continue; } return null; }