• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Monospaced Simulated Braille
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Re: Monospaced Simulated Braille (From: "James Jennings" <email@hidden>)

  • Prev by Date: Re: Should I retain a variable returned from this accessor?
  • Next by Date: Re: NSTextField Bug? Can't be!
  • Previous by thread: Re: Monospaced Simulated Braille
  • Next by thread: Re: Problem with friend function and gcc 4.2 with
  • Index(es):
    • Date
    • Thread