Re: Monospaced Simulated Braille
Re: Monospaced Simulated Braille
- Subject: Re: Monospaced Simulated Braille
- From: Douglas Davidson <email@hidden>
- Date: Tue, 12 Aug 2008 12:45:50 -0700
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 (email@hidden)
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:
This email sent to email@hidden