Bold font is not displayed correctly

When I try to display a Chinese string like 试 标记 好 不好 Graphics.DrawString draws it

enter image description here

even if i changed Font Linking to SimSun. On the other hand, TextRenderer works, but it cannot display readable lines when bold fonts are used. There seems to be no correct way to highlight bold lines.

enter image description here

The problem is described in more detail here . Am I doing something wrong or does Windows not support professional looking localizable apps with some bold lines in the UI?

The code to reproduce the problem is from a Windows Forms application with two PictureBoxes:

    const string combined = "测试标记好不好This is a aber long";

    private void cFontSize_ValueChanged(object sender, EventArgs e)
    {
        Bitmap bmp = new Bitmap(750, 140);
        Font f = new Font("Arial", (float)cFontSize.Value, IsBold ? FontStyle.Bold : FontStyle.Regular);

        using (var g = Graphics.FromImage(bmp))
        {
            g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;

            // Rendering with a Background Color solves the issue but 
            // this would produce boxes of white or black color in the displayed image which looks even worse
            TextRenderer.DrawText(g, combined, f, new Point(0, 0), FontColor);
        }
        cPictureBox.Image = bmp;

        Bitmap bmp2 = new Bitmap(750, 140);

        using (var g = Graphics.FromImage(bmp2))
        {
            g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
            g.DrawString(combined, f, FontBrush, 0, 0);
        }

        cPicture2.Image = bmp2;
    }

      

Update 1:

When I add as a Font Link reference to HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ FontLink \ SystemLink

Arial Bold
   SIMSUNB.TTC,SimSun Bold
   MSGOTHIC.TTC,MS UI Gothic

      

then the Graphics.DrawString looks ok now. Now TextRender is having problems. After restarting the application, both exits now appear sane in font, although the TextRenderer still has the problem that bold fonts become unreadable due to anti-aliasing with black. I will restart the machine to check any caching effects.

+3


source to share





All Articles