コード例 #1
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
            canvas2d.StrokeColor = PixelFarm.Drawing.Color.Blue;
            canvas2d.ClearColorBuffer();
            if (!resInit)
            {
                // msdf_bmp = LoadTexture(@"..\msdf_75.png");
                //msdf_bmp = LoadTexture(@"d:\\WImageTest\\a001_x1_66.png");
                msdf_bmp = LoadTexture(totalImg);
                //msdf_bmp = LoadTexture(@"d:\\WImageTest\\a001_x1.png");
                //msdf_bmp = LoadTexture(@"d:\\WImageTest\\msdf_65.png");

                resInit = true;
            }

            painter.Clear(PixelFarm.Drawing.Color.White);
            //var f = painter.CurrentFont;

            //painter.DrawString("hello!", 0, 20);
            //canvas2d.DrawImageWithSubPixelRenderingMsdf(msdf_bmp, 200, 500, 15f);

            Typography.Rendering.TextureFontGlyphData glyphData;

            byte[] codepoint = System.Text.Encoding.UTF8.GetBytes("AB");
            fontAtlas.GetRectByCodePoint(codepoint[0], out glyphData);
            PixelFarm.Drawing.Rectangle r = ConvToRect(glyphData.Rect);
            //canvas2d.DrawSubImageWithMsdf(msdf_bmp, ref r, 100, 500);
            canvas2d.DrawSubImageWithMsdf(msdf_bmp, ref r, 100, 500);

            fontAtlas.GetRectByCodePoint(codepoint[1], out glyphData);
            PixelFarm.Drawing.Rectangle r2 = ConvToRect(glyphData.Rect);
            canvas2d.DrawSubImageWithMsdf(msdf_bmp, ref r2, 100 + r.Width - 10, 500);

            //full image
            canvas2d.DrawImage(msdf_bmp, 100, 300);
            miniGLControl.SwapBuffers();
        }