I wrote a program to draw some string on an image. I use graphics.DrawString()
but as you can see in this post, it has some problems.
TextRenderer.DrawText()
solved that problem but the rendered text is jagged. I changed both graphics.TextRenderingHint
and resolution of graphics; TextRenderer
doesn't care at all.
There should be a solution as it is done here; but I don't know how to do it.
Asked
Active
Viewed 304 times
0

AmirSina Mashayekh
- 498
- 1
- 5
- 21
-
Reading second link, looks like you have to set font quality manually? Graphics object properties (GDI+) do not affect Textrenderer (GDI) - or that is how I understand linked information. – Arvo Sep 21 '20 at 09:11
-
@Arvo How should I set font quality? – AmirSina Mashayekh Sep 21 '20 at 09:17
-
I have no idea, this is just what I understood from linked discussion. – Arvo Sep 21 '20 at 09:22
1 Answers
0
private void panel1_Paint(object sender, PaintEventArgs e)
{
//GDI (i.e. TextRenderer)
String s = "The quick brown fox jumped over the lazy dog";
Point origin = new Point(11, 11);
Font font = SystemFonts.IconTitleFont;
e.Graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;
TextRenderer.DrawText(e.Graphics, s, font, origin, SystemColors.InfoText);
}
Full demo showing that it does work: https://mega.nz/file/E3xREYIR#kuDxyac_0jxlX7wuTVmZmJgClEicdaCj0YpnE83Wq9k

Ian Boyd
- 246,734
- 253
- 869
- 1,219
-
You're right. However effect of these properties are really low on this font (IranNastaliq). I couldn't detect the difference between different `TextRenderingHint` modes for `TextRenderer` at first. Only a few (maybe less than 10) pixels are different between all modes. Also, when I increase font size, the [overlapping problem](https://stackoverflow.com/q/63816737/10600811) appears again even using `TextRenderer`. – AmirSina Mashayekh Sep 24 '20 at 08:11