This gives me a nice two-digit string display:

private void button1_Click(object sender, EventArgs e) { CreateTextIcon("89"); } public void CreateTextIcon(string str) { Font fontToUse = new Font("Microsoft Sans Serif", 16, FontStyle.Regular, GraphicsUnit.Pixel); Brush brushToUse = new SolidBrush(Color.White); Bitmap bitmapText = new Bitmap(16, 16); Graphics g = System.Drawing.Graphics.FromImage(bitmapText); IntPtr hIcon; g.Clear(Color.Transparent); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; g.DrawString(str, fontToUse, brushToUse, -4, -2); hIcon = (bitmapText.GetHicon()); notifyIcon1.Icon = System.Drawing.Icon.FromHandle(hIcon);
What I changed:
Use a larger font size, but move the x and y offset further left and up (-4, -2).
Set TextRenderingHint to the Graphics object to disable anti-aliasing.
It seems impossible to draw more than two numbers or characters. The icons are in square format. Any text longer than two characters means a significant reduction in text height.
The sample in which you select the keyboard layout (ENG) is not really a notification icon in the tray area, but its own shell toolbar.
The best I could achieve was to display 8.55:

private void button1_Click(object sender, EventArgs e) { CreateTextIcon("8'55"); } public void CreateTextIcon(string str) { Font fontToUse = new Font("Trebuchet MS", 10, FontStyle.Regular, GraphicsUnit.Pixel); Brush brushToUse = new SolidBrush(Color.White); Bitmap bitmapText = new Bitmap(16, 16); Graphics g = System.Drawing.Graphics.FromImage(bitmapText); IntPtr hIcon; g.Clear(Color.Transparent); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; g.DrawString(str, fontToUse, brushToUse, -2, 0); hIcon = (bitmapText.GetHicon()); notifyIcon1.Icon = System.Drawing.Icon.FromHandle(hIcon);
with the following changes:
- Use Trebuchet MS, which is a very narrow font.
- Use a single quotation mark instead of a dot because it has less space on the sides.
- Use a font size of 10 and adapt the offsets accordingly.
Nineberry
source share