On Aug 8, 2008, at 2:11 PM, James Jennings wrote:
Override the character spacing of a font, or
Override the definition of white space, or
Override the word break algorithm.
Overriding the spacing of a font is something that has been
demonstrated at least once at WWDC, in the context of
NSFontDescriptor. To put it briefly, you create an NSFontDescriptor
from a given font and add NSFontFixedAdvanceAttribute to override the
font's glyph advancements and make it monospace, then create a font
from that. We showed a code snippet for this; I'll reproduce it below.
Overriding the word break and double-click algorithms is something
that can be done at the NSTextStorage and/or NSTypesetter levels, but
it's rather difficult, and I suspect that what you really want is a
monospace variant of the font instead.
Douglas Davidson
From WWDC slides (somewhat schematic; modify as necessary):
NSFontDescriptor *descriptor = [font fontDescriptor];
NSDictionary *newAttributes;
CGFloat maxAdvance = [font maximumAdvancement].width;
NSNumber *number = [NSNumber numberWithDouble:maxAdvance];
newAttributes = [NSDictionary dictionaryWithObject:number
forKey:NSFontFixedAdvanceAttribute];
descriptor = [descriptor
fontDescriptorByAddingAttributes:newAttributes];
font = [NSFont fontWithDescriptor:descriptor size:0.0];
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]