Re: Change text size in NSTables
Re: Change text size in NSTables
- Subject: Re: Change text size in NSTables
- From: Sanjay Samani <email@hidden>
- Date: Fri, 7 Apr 2006 16:40:39 +0100
Jonathan,
I think you need to add a -changeFont: method to your window
controller, as described here
file:///Developer/ADC Reference Library/documentation/Cocoa/
Conceptual/FontHandling/Tasks/RespondingToFontChanges.html
Basically the Font panel will send this message to the window
controller. in your -setSelectedFont method you then update the
cells for each column in your table view using the new Font.
If you are not using the font panel and are instead doing this
programmatically, then using NSFont's +fontWithName:size: gets the
appropriate font, which you can then pass to your setSelectedFont:
method (or use wherever you want). You can adjust the font traits of
an NSAttributedString but not of an NSFont. I think the idea is that
fonts are cached by the system, so you just keep asking for whatever
one you want. So to use a different font for a table, you just get
the appropriate font from the NSFont +fontWithName:size: and set the
table view data cell accordingly and adjust the row size accordingly.
I had an app I wrote 4 years ago that did this, so its a bit vague,
but I seem to have copied and pasted the code out of the link above
and it worked fine when using the Font Panel. Basically what I've
got in my window controller class is:
- (void)changeFont:(id)sender {
NSFont *oldFont = [[[myTableView
tableColumnWithIdentifier:@"columnId"] dataCell] font];
NSFont *newFont = [sender convertFont:oldFont];
[self setSelectedFont:newFont];
}
// Set Fonts for Table View
- (void) setSelectedFont:(NSFont *)font {
[[[myTableView tableColumnWithIdentifier:@"columnId"] dataCell]
setFont:font];
}
The sender in changeFont is the [NSFontManager defaultManager]
The reason I had setSelectedFont separately is that I stored the last
selected font in the user defaults and set it for all my table view
on application startup.
Sanjay
Hi, Nick--
I actually did look in the Ref. Library first. Not that I
understood it ;)
But it seemed to direct me to how to change to a different font,
and to the
row height, but not to just change the size of the font being used.
Sorry, I know I'm probably a bit overwhelmed by the
documentation... So
maybe I just missed where it tells me that?
Jonathan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden