Small Font Troubles Resolved
Small Font Troubles Resolved
- Subject: Small Font Troubles Resolved
- From: Greg Scown <email@hidden>
- Date: Thu, 10 Jan 2002 09:36:21 +0800
I managed to resolve my small font troubles, and I'd like to share my
solution so that no one else spends as much time on this issue as I did
(and in case there are other things I should consider).
If you wish to display text on screen at below 9pt and have it look
nice, use printer fonts and call [NSLayoutManager setUsesScreenFonts:NO]
or the Layout Manager will substitute screen fonts by default. The
default display for text below 9pt is quite ugly. If you're using an
NSTextField to display small fonts, it appears that it uses printer
fonts and relies on the Layout Manager for substitution, so you may use
[[textField layoutManager] setUsesScreenFonts:NO] to get better small
font behavior in NSTextField.
For example, I built a small project with a single NSTextField and this
is my controller's awakeFromNib:
- (void)awakeFromNib {
NSLog(@"font: %@", [[textField font] description]);
[[textField layoutManager] setUsesScreenFonts:NO];
}
Here is the NSLog output (note that the "P" indicates a printer font):
2002-01-10 09:11:55.276 SmallFonts[5409] font: "CGS LucidaGrande 7.00
pt. P [] (0x00218450) fobj=0x00204450, spc=2.21"
My guess is that since point sizes smaller than 9 are difficult to read,
Apple chose this as the threshold for good-looking screen fonts. Given
that, it would be nice if NSTextField would set usesScreenFonts to YES
if the initial font is 9pt or above and NO if it is below 9pt.
This is not entirely a complete solution, as at 4pt and below the text
will not be antialiased (you can see this if you set the font for your
NSTextView to 4pt or below and compare it with its print preview). 4pt
is below what I need for my application, so I stopped here, but if
someone knows how to make app behavior match Preview, please share.
Cheers,
==> Greg