Ejemplo 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;
        }
Ejemplo 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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
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);
            }
        }