I needed to customize a Menu so that certain MenuItems are written with bold
font. When the regular font draws, it looks fine, but as soon as I use the
bold font, it looks squeezed together for some reason...for example two
lowercase 'L's in a row look like one fat bar.
I used MenuItems's ownerdraw property to activate my custom drawing
function, and provided a DrawItem and MeasureItem delegate
Here's how I setup my fonts:
static Font boldFont = new Font(FontFamily.GenericSansSerif, 8,
FontStyle.Bold);
static Font regularFont = new Font(FontFamily.GenericSansSerif, 8,
FontStyle.Regular);
here's how I draw it:
private void menuitem_DrawItem(object sender, DrawItemEventArgs e) {
MenuItem item = sender as MenuItem;
Font = (needsBold) ? boldFont : regularFont;
e.Graphics.DrawString(item.Text, font, Brushes.Black, e.Bounds.X,
e.Bounds.Y);
}
So why is that bold font squished? I can provide a screen shot if you like,
but I'm sure you'll see the same results if you copy that code.
the MeasureItem function does the same thing as above except of course
instead of doing the DrawString it calls MeasureString and sets the
ItemHeight/ItemWidth properties