Share via

why draw string is not Fill?

mc 7,186 Reputation points
2026-05-10T11:59:43.54+00:00

I am using winform to draw string

g.DrawString(text, new Font("Microsoft Yahei", fontSize), brush, new PointF(0, 0));

20260510184056

and it is not fill but stroke why?

Developer technologies | Windows Forms
0 comments No comments

Answer accepted by question author

Jack Dang (WICLOUD CORPORATION) 18,810 Reputation points Microsoft External Staff Moderator
2026-05-11T03:34:49.6566667+00:00

Hi @mc ,

Thanks for reaching out.

Graphics.DrawString() is already drawing filled text with the brush you pass in, so this behavior comes from how the font is being rasterized rather than from it switching to an outline mode. With fonts like Microsoft YaHei, smaller sizes can look thin or slightly hollow depending on anti-aliasing, hinting, and the background color.

One thing worth trying is changing the text rendering hint, since that has a big effect on how solid the glyphs appear:

g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
g.DrawString(text, new Font("Microsoft YaHei", fontSize), brush, new PointF(0, 0));

You can also compare it with ClearTypeGridFit or SingleBitPerPixelGridFit to see which result looks best in your case. If this is for normal WinForms-style UI text, TextRenderer.DrawText() is another good option because it uses the text rendering path that WinForms controls rely on, and it may give you a result that looks more natural on screen.

If the appearance still feels too “stroked,” the most suitable fixes are to use a slightly larger font size, try a different font, or render at a higher resolution and scale down. So the main point is that the text is being filled correctly already, but the rendering settings and font choice can make it look less solid than expected.

Hope this helps! If my explanation and the information I provided were also helpful to you, I would greatly appreciate it if you could follow the instructions here so others with the same problem can benefit as well.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

Answer accepted by question author

AI answer

2026-05-10T11:59:58.74+00:00

Graphics.DrawString always fills glyphs with the specified Brush; it does not draw only the outline. The “stroke” look in the screenshot is caused by the font itself (hinting/anti‑aliasing and the way “Microsoft Yahei” is rendered at that small size on a dark background), not by DrawString using an outline mode.

To get a more solid look, use a larger font size or a different font, or draw the text at higher resolution and scale it down. If an actual outline (stroke) plus fill is needed, draw the text multiple times with different colors and slight offsets, or use GDI+/DirectWrite text rendering APIs that support outlining.

The DrawString call being used is correct and already uses fill rendering with the given brush.


References:

AI-generated content may be incorrect. Read our transparency notes for more information.

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.