Esempio n. 1
0
        public VFont(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 VTex2D(g.W, g.H, img, true);
                Glypth.Add(g);
            }

            fs.Close();
            fs = null;
        }
Esempio n. 2
0
        public int Width(string t)
        {
            int sw = 0;

            foreach (char c in t)
            {
                VGlyph v = Glypth[(int)c];
                sw += v.W;
            }
            return(sw);
        }
Esempio n. 3
0
        public static void Draw(VFont font, string text, int x, int y, Vector4 col)
        {
            int dx = x;

            VPen.BlendMod = VBlend.Alpha;
            foreach (Char c in text)
            {
                VGlyph cg = font.Glypth[(int)c];
                VPen.Rect(dx, y, cg.W, cg.H, cg.Img, col);
                dx += (int)((float)cg.W / 1.3f);
            }
        }