Making a font bold at runtime
-
Hi, I am trying to make a font bold at runtime but I can not work it out. I am currently changing the color of the font using: lblPageStatus.ForeColor = System.Drawing.Color.Red How can I do the same to make it bold? Thanks Shawn
u have to need creating a new font, then use that. Dont forget The Bold property of any Font is ReadOnly
Dim newFont as new Font (previousFont.Name, FontStyle.Bold ) lblPageStatus.Font=newFont
-
u have to need creating a new font, then use that. Dont forget The Bold property of any Font is ReadOnly
Dim newFont as new Font (previousFont.Name, FontStyle.Bold ) lblPageStatus.Font=newFont
-
Thanks for the reply. I will give that a go. It does seem a little odd that you have to create a new font to change the bold property, when you can just set a color without having to create a new font. Oh well. Thanks again! Shawn
It's not odd if you understand the difference between selecting a font and drawing one. When you change the type to Bold, you're actually changing the shape of the Font. If the Font includes a bold version, then you're actually selecting a new font just by changing the style. For instance, a font can include a normal version of the character outlines, italics version, bold version, italics and bold version, underline, ... Now, if you selected a bold version of a font and the font file don't have a bold version, it can be calculated, or approximated. In either case, a new set of outline coordinates are used to draw the font. This is why properties like Bold are ReadOnly. Now, changing the color doesn't change the coordinates of the outlines that are drawn, so you can change the color all you want without regenerating the coordinates again. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome