|
-
Nov 17th, 2005, 04:47 PM
#1
Thread Starter
Hyperactive Member
[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.
-
Nov 17th, 2005, 07:50 PM
#2
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.
-
Nov 18th, 2005, 02:52 AM
#3
Thread Starter
Hyperactive Member
Re: Extracting font information
Thanks for the help
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
-
Nov 18th, 2005, 03:01 AM
#4
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.
-
Nov 18th, 2005, 03:29 AM
#5
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 - Oh, that's what you wanted to do.
Last edited by conipto; Nov 18th, 2005 at 03:35 AM.
-
Nov 18th, 2005, 07:50 AM
#6
Thread Starter
Hyperactive Member
Re: [RESOLVED] Extracting font information
Looks good to me, I'll try it out tonight when I get home.
-
Nov 18th, 2005, 12:01 PM
#7
Thread Starter
Hyperactive Member
Re: [RESOLVED] Extracting font information
Just tried it and it works a treat, thanks again for your help JMC.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|