public Font2D(string path) { Path = path; FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); BinaryReader r = new BinaryReader(fs); for (int c = 0; c < 255; c++) { VGlyph g = new VGlyph { W = r.ReadInt16(), H = r.ReadInt16() }; byte[] img = new byte[g.W * g.H * 4]; for (int y = 0; y < g.H; y++) { for (int x = 0; x < g.W; x++) { int loc = (y * g.W * 4) + (x * 4); img [loc++] = r.ReadByte( ); img [loc++] = r.ReadByte( ); img [loc++] = r.ReadByte( ); img [loc] = r.ReadByte( ); } } g.Img = new Texture2D(g.W, g.H, img, true); Glypth.Add(g); } fs.Close( ); fs = null; }
public int Width(string t) { int sw = 0; foreach (char c in t) { VGlyph v = Glypth[c]; sw += ( int )(v.W / 1.3f); } return(sw); }
public static void Draw(Font2D font, string text, int x, int y, Vector4 col) { int dx = x; Pen2D.BlendMod = PenBlend.Alpha; foreach (char c in text) { VGlyph cg = font.Glypth[c]; Pen2D.Rect(dx, y, cg.W, cg.H, cg.Img, col); dx += ( int )(cg.W / 1.3f); } }