Re: Changing font size
Re: Changing font size
- Subject: Re: Changing font size
- From: John Timmer <email@hidden>
- Date: Thu, 11 Dec 2003 09:53:57 -0500
Sorry, I guess I haven't explained myself well -
I can handle all the archiving/unarchiving, and I realize that I can do this
by archiving multiple NSFonts, but I want the user to be able to simply
change a single font preference and have that update all the fonts of
different sizes, so that isn't going to work out.
So, what I'd like to do is simply store a single NSFont. After unarchiving,
I'd like to create several NSFont instances by keeping all attributes the
same as the archived version except the size - ie, I'd like to start with an
NSFont, and simply change its size.
Unfortunately, the only way I can see of doing this is fairly complicated,
so I'm assuming that I'm missing something.
>
> I'd like to have a single base font that's used to draw strings at
>
> different
>
> sizes, depending on context. As such, it seems simplest to save a
>
> single
>
> font in user defaults, and resize that according to where I need it.
>
>
>
> The problem is that there seems to be no straightforward way to go
>
> about
>
> doing this.
>
>
The usual method to do things like this is to archive the object into
>
an NSData (using NSArchiver or NSKeyedArchiver), then store that in
>
user defaults. When you want to retrieve it, get the NSData back from
>
user defaults and unarchive the object (using NSUnarchiver or
>
NSKeyedUnarchiver as appropriate).
>
>
This, of course, requires the object to support coding, so before doing
>
it with any given object you need to make sure that it has adopted the
>
NSCoding protocol. NSFont supports NSCoding, so this technique will
>
work just fine.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.