mono / libgdiplus

C-based implementation of the GDI+ API
http://www.mono-project.com/
MIT License
329 stars 171 forks source link

Draw DrawString In Linux ,FontStyle.Italic Not Support #665

Open li-zhixin opened 3 years ago

li-zhixin commented 3 years ago

Windows runs fine, but linux has different results.

image

Core Code As Follow:

            var bitMap = new Bitmap(200, 200);
            using var graphics = Graphics.FromImage(bitMap);
            graphics.CompositingQuality = CompositingQuality.AssumeLinear;
            graphics.SmoothingMode = SmoothingMode.AntiAlias;
            graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
            graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
            graphics.DrawImage(Image.FromFile("./StaticFiles/Devil.png"), new Rectangle(0, 0, 200, 200));
            graphics.DrawString("登录", new Font("新宋体", 20, FontStyle.Italic), new SolidBrush(Color.Black), 0, 50f);
            var stream = new MemoryStream();
            bitMap.Save(stream, ImageFormat.Png);
            stream.Position = 0;
            return new FileStreamResult(stream, "image/png");

Is there a problem with my usage? Or is it a bug? Demo Project Here: WebApplication1.zip