Beispiel #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            const float  ptSize       = 80;
            const string text         = "𝑑";
            const int    windowWidth  = 350;
            const int    windowHeight = 300;
            var          t            = new OpenFontReader().Read(GetType().Assembly.GetManifestResourceStream(Array.Find(GetType().Assembly.GetManifestResourceNames(), n => n.EndsWith(".otf"))));
            var          g            = t.Lookup(char.ConvertToUtf32(text, 0));

            Size = new Size(windowWidth, windowHeight);
            Text = "Typography -> SkiaSharp";

            var view = new SKControl();

            view.PaintSurface += (_, E) =>
            {
                var tx = new SkiaTx();
                var c  = E.Surface.Canvas;
                c.Scale(1, -1);
                c.Translate(0, -Height / 4);

                tx.Read(g._ownerCffFont, g._cff1GlyphData, t.CalculateScaleToPixelFromPointSize(ptSize));
                c.DrawPath(tx.Path, new SKPaint {
                    Color = SKColors.Black, Style = SKPaintStyle.Stroke
                });
            };
            view.Dock = DockStyle.Fill;
            Controls.Add(view);

            var gdi = new Form {
                Text = "Typography -> Gdi+", Size = new Size(windowWidth, windowHeight)
            };

            gdi.Paint += (_, E) =>
            {
                var tx = new GdiTx();
                var G  = E.Graphics;
                G.ScaleTransform(1, -1);
                G.TranslateTransform(0, -Height / 4);

                tx.Read(g._ownerCffFont, g._cff1GlyphData, t.CalculateScaleToPixelFromPointSize(ptSize));
                G.DrawPath(Pens.Black, tx.Path);
            };
            gdi.Show();
        }