コード例 #1
0
        void Issue119(PaintEventArgs e)
        {
            Text = "Issue 119 Demo";
            const float z = 80;
            var         m = GetType().Assembly;
            var         t = new OpenFontReader().Read
                                (m.GetManifestResourceStream
                                    (Array.Find(m.GetManifestResourceNames(), n => n.EndsWith("otf"))));

            t.UpdateAllCffGlyphBounds();
            var c = t.CalculateScaleToPixelFromPointSize(z);
            var b = new B(t);
            var r = new SampleWinForms.GlyphTranslatorToGdiPath();
            var g = t.GetGlyphByName("radical.v4");
            var o = g.Bounds;
            var k = R.FromLTRB(o.XMin * c, o.YMin * c, o.XMax * c, o.YMax * c);

            b.BuildFromGlyph(g, z);
            b.ReadShapes(r);
            e.Graphics.ScaleTransform(1, -1);
            e.Graphics.TranslateTransform(0, -Height / 2.5f);
            e.Graphics.FillRectangle(Pens.Red.Brush, k.X, k.Y, k.Width, k.Height);
            e.Graphics.DrawRectangle(Pens.Blue, k.X, k.Y, t.GetHAdvanceWidthFromGlyphIndex(g.GlyphIndex) * c, k.Height);
            e.Graphics.FillPath(Pens.Black.Brush, r.ResultGraphicsPath);
            e.Graphics.ResetTransform();
            e.Graphics.DrawString("Blue = GetHAdvanceWidthFromGlyphIndex,\nRed = Glyph.Bounds of radical.v4", Font, Pens.Black.Brush, 0, 0);
        }