I am trying to render some kind of a picture using GDI+ with dynamically loaded fonts. Here is a minimal example (.NET 8.0):
private void Form1_Load(object sender, EventArgs e)
{
PrivateFontCollection collection = new();
collection.AddFontFile("Unbounded-Medium.ttf");
Bitmap bitmap = new(1000, 1000);
using (Graphics g = Graphics.FromImage(bitmap))
{
g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
Font font = new(collection.Families[0], 100, FontStyle.Bold, GraphicsUnit.Point);
g.DrawString("Bbbb", font, Brushes.Red, new PointF(10, 10));
}
pictureBox1.Image = new Bitmap(bitmap, 1000, 1000);
}
Everything works fine on multiple Win 10 machines:
But on a Win 7 machines the same code produces the following output:
For some reason, some letters are being rendered... questionably. Other letters look normal though. Using trial-and-error approach I've found out that this kind of rendering happens:
- Only on Win 7 machines
- Only for font sizes above 70
- Only for certain fonts (Unbounded-Medium in my case)
- Only while using GDI+
I tried:
- Changing
g.TextRenderingHint - Adding
StringFormat.GenericTypographicparameter to theDrawStringmethod - Enabling ClearType on the OS level
Why does this happen? Is this a Win 7 GDI+ bug? Is it possible to fix this issue without updating OS?

