473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Bold font looks screwy

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
Nov 16 '05 #1
0 1081

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bryan | last post by:
Hello, in ASP.NET 1.x I rememebr that the header of a datagrid was not output as a <th> tag. Now in 2.0 using the new gridview, it is out put as a table header, which makes everything bold. What...
4
by: anthony | last post by:
hi, why can't i set the font of a button to bold at run time (it's read only), i can only set at design time. it can be done in vb6. thx
3
by: Rich | last post by:
Could someone share how to toggle the font property of a label from regular to bold and back to regular? I have tried label.Font.Bold = True but get the error message that this property is...
2
by: Adam Honek | last post by:
Okay, Assinging the font and its style (bold, italic etc.) using the font dialog is easy such as: FontDialog1.ShowDialog() txtEmailBody.SelectionFont = FontDialog1.Font But how does one...
4
by: paraidy | last post by:
Hi, i'm using a richtextbox named r1, and i want to write in Bold and italic, i tryed this for bold and it work Dim f As New Font("Verdana", 30, FontStyle.Bold) r1.Font = f r1.Text = "Hello" ...
1
by: Henry Jones | last post by:
I found some code to change the font on a button to bold: private void btnBold_Click(object sender, System.EventArgs e) { btnCalculate.Font = new Font(btnCalculate.Font, ...
5
by: fidtz | last post by:
Sorry for asking here, but I don't know enough dotnet or Windows programming yet to be very good at googling for answers. OTOH, this is the first question I haven't be able to resolve myself, the...
2
by: =?Utf-8?B?UmljaA==?= | last post by:
I have code to bold text in a datagridviewcell: Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim cs As DataGridViewCellStyle, fnt...
7
by: RickMerrill | last post by:
it appears that <ttwill not do <b> although it will do <u>. IS there any way to do bold with a fixed width?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.