forked from twitter-archive/twui
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added +[NSFont tui_fontWithName:size:fallbackNames:]
- Loading branch information
Showing
4 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// NSFont+TUIExtensions.h | ||
// TwUI | ||
// | ||
// Created by Josh Abernathy on 7/26/12. | ||
// | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
|
||
@interface NSFont (TUIExtensions) | ||
|
||
// Creates and returns a new font with the given size and fallback font names. | ||
// The fallback fonts all use the font size passed in. | ||
+ (NSFont *)tui_fontWithName:(NSString *)fontName size:(CGFloat)fontSize fallbackNames:(NSArray *)fallbackNames; | ||
|
||
@end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// NSFont+TUIExtensions.m | ||
// TwUI | ||
// | ||
// Created by Josh Abernathy on 7/26/12. | ||
// | ||
// | ||
|
||
#import "NSFont+TUIExtensions.h" | ||
|
||
|
||
@implementation NSFont (TUIExtensions) | ||
|
||
+ (NSFont *)tui_fontWithName:(NSString *)fontName size:(CGFloat)fontSize fallbackNames:(NSArray *)fallbackNames { | ||
NSMutableArray *fallbackDescriptors = [NSMutableArray arrayWithCapacity:fallbackNames.count]; | ||
for(NSString *fallbackName in fallbackNames) { | ||
[fallbackDescriptors addObject:[NSFontDescriptor fontDescriptorWithName:fallbackName size:fontSize]]; | ||
} | ||
|
||
return [NSFont fontWithDescriptor:[NSFontDescriptor fontDescriptorWithFontAttributes:@{ NSFontNameAttribute: fontName, NSFontCascadeListAttribute: fallbackDescriptors }] size:fontSize]; | ||
} | ||
|
||
@end |
This file contains 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