Ejemplo n.º 1
0
        public int DrawGlyph(int x, int y, float size, Glyph g, TrueTypeFont f)
        {
            var scale = size / f.UnitsPerEm;

            var gr = panel1.CreateGraphics();

            gr.SmoothingMode = SmoothingMode.AntiAlias;

            gr.TranslateTransform(x, y + ((f.YMax - f.YMin) * scale));
            gr.ScaleTransform(scale, -scale);

            var triangles = TrianglateGlyph(g);

            var debugColors = new [] { Brushes.Red, Brushes.Blue };

            var cgg = new CGLFGlyph();

            cgg.YMin = g.YMin;
            cgg.YMax = g.YMax;
            cgg.XMin = g.XMin;
            cgg.XMax = g.XMax;

            for (var i = 0; i < triangles.Count; i++)
            {
                var triangle = triangles[i];
                cgg.Triangles.Add(triangle);

                gr.FillPolygon(checkBox1.Checked ? debugColors[i % 2] : Brushes.Black, triangle.ToArray());
            }

            Cglf.AddGlyph(cgg);

            return((int)(g.XMax * scale));
        }
Ejemplo n.º 2
0
 public void AddGlyph(CGLFGlyph g)
 {
     Glyphs.Add(g);
 }