Created
February 15, 2012 18:28
-
-
Save ccgus/1838008 to your computer and use it in GitHub Desktop.
font stuff.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)changeFont:(id)sender { | |
// by default, the bold menu is hooked up to NSFontManagers' - (void)addFontTrait:(id)sender; Start there to debug. | |
// isEditable , inputContext | |
for (TSGraphic *graphic in [[[self document] currentLayer] selectedGraphics]) { | |
if (![graphic isKindOfClass:[TSTextArea class]]) { | |
continue; | |
} | |
TSTextArea *ta = (id)graphic; | |
NSTextStorage *contentsCopy = [[[ta contents] mutableCopy] autorelease]; | |
if (![contentsCopy length]) { | |
continue; | |
} | |
[ta fontWillChange]; | |
NSFont *oldFont = [contentsCopy attribute:NSFontAttributeName atIndex:0 effectiveRange:nil]; | |
NSFont *newFont = [sender convertFont:oldFont]; | |
[contentsCopy addAttribute:NSFontAttributeName value:newFont range:NSMakeRange(0, [contentsCopy length])]; | |
[ta setContents:contentsCopy]; | |
[ta didChange]; | |
[ta fontDidChange]; | |
[[NSFontManager sharedFontManager] setSelectedFont:newFont isMultiple:NO]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment