[RESOLVED] Extracting font information
Quick question, is there a more efficient way to determine the properties of a font (I'm basically talking about, bold, italic and underlined states) without having lots of if ...then statements ?
Basically what I'm getting at is that if I want to alter the bold state of a font how can I do it and leave the other applied states intact.
Re: Extracting font information
If you're talking about changing the Font of a control then you can't just change individual properties. You have to create a new Font object and assign that to the control's Font property. Pretty much the only way to determine whether a particular style is applied to a Font is with an If and a bitwise And.
Re: Extracting font information
Thanks for the help :thumb:
Thats the way I'm doing it at the moment it just looks very untidy, I was hoping for some flashy method that would allow me to just toggle the attribute flag that I wanted to change ;)
Re: [RESOLVED] Extracting font information
You would be able to toggle the particular style you're interested in using a bitwise exclusive or, but you'd still have to create a new Font object. You would toggle the the Bold property like this:
VB Code:
Dim newFont As New Font(oldFont, oldFont.Style Xor FontStyle.Bold)
I've never done this myself and I just typed that straight in, so I can't guarantee it but it looks sound to me.
Re: [RESOLVED] Extracting font information
Won't a bitwise XOR make the value end up plain if that style is applied already? 1 Xor 1 = 0 right? isn't Xor only = 1 if the two are opposite?
Bill
EDIT - :blush: Oh, that's what you wanted to do.
Re: [RESOLVED] Extracting font information
Looks good to me, I'll try it out tonight when I get home.
Re: [RESOLVED] Extracting font information
Just tried it and it works a treat, thanks again for your help JMC.