Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added +[NSFont tui_fontWithName:size:fallbackNames:]

  • Loading branch information...
commit a9a0919a153bf612580342c376c8c5a0a43ffb08 1 parent 608c042
@joshaber joshaber authored
View
8 TwUI.xcodeproj/project.pbxproj
@@ -95,6 +95,8 @@
886EBA8313D64393006DE018 /* TUIControl+Private.m in Sources */ = {isa = PBXBuildFile; fileRef = 886EBA7E13D64393006DE018 /* TUIControl+Private.m */; };
886EBA8413D64393006DE018 /* TUIControl+Private.m in Sources */ = {isa = PBXBuildFile; fileRef = 886EBA7E13D64393006DE018 /* TUIControl+Private.m */; };
886EBA8513D64393006DE018 /* TUIControl+Private.m in Sources */ = {isa = PBXBuildFile; fileRef = 886EBA7E13D64393006DE018 /* TUIControl+Private.m */; };
+ 887C227B15C1C7BB006EC31D /* NSFont+TUIExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 887C227915C1C7BB006EC31D /* NSFont+TUIExtensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 887C227C15C1C7BB006EC31D /* NSFont+TUIExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 887C227A15C1C7BB006EC31D /* NSFont+TUIExtensions.m */; };
887F272C13F9969800D75DE6 /* TUITableViewSectionHeader.h in Headers */ = {isa = PBXBuildFile; fileRef = 887F272A13F9969800D75DE6 /* TUITableViewSectionHeader.h */; settings = {ATTRIBUTES = (Public, ); }; };
887F272D13F9969800D75DE6 /* TUITableViewSectionHeader.h in Headers */ = {isa = PBXBuildFile; fileRef = 887F272A13F9969800D75DE6 /* TUITableViewSectionHeader.h */; };
887F272E13F9969800D75DE6 /* TUITableViewSectionHeader.h in Headers */ = {isa = PBXBuildFile; fileRef = 887F272A13F9969800D75DE6 /* TUITableViewSectionHeader.h */; };
@@ -443,6 +445,8 @@
884E8F5A1538809C000F7A8D /* CAAnimation+TUIExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CAAnimation+TUIExtensions.m"; sourceTree = "<group>"; };
886EBA7D13D64393006DE018 /* TUIControl+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TUIControl+Private.h"; sourceTree = "<group>"; };
886EBA7E13D64393006DE018 /* TUIControl+Private.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "TUIControl+Private.m"; sourceTree = "<group>"; };
+ 887C227915C1C7BB006EC31D /* NSFont+TUIExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSFont+TUIExtensions.h"; sourceTree = "<group>"; };
+ 887C227A15C1C7BB006EC31D /* NSFont+TUIExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSFont+TUIExtensions.m"; sourceTree = "<group>"; };
887F272A13F9969800D75DE6 /* TUITableViewSectionHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TUITableViewSectionHeader.h; sourceTree = "<group>"; };
887F272B13F9969800D75DE6 /* TUITableViewSectionHeader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TUITableViewSectionHeader.m; sourceTree = "<group>"; };
88A4AFDC145A16C90071CF22 /* TUITextRenderer+Accessibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TUITextRenderer+Accessibility.h"; sourceTree = "<group>"; };
@@ -743,6 +747,8 @@
D040611215B6A7CC00F753ED /* NSTextView+TUIExtensions.m */,
D0C7656F15B6341800E7AC2C /* TUICAAction.h */,
D0C7657015B6341800E7AC2C /* TUICAAction.m */,
+ 887C227915C1C7BB006EC31D /* NSFont+TUIExtensions.h */,
+ 887C227A15C1C7BB006EC31D /* NSFont+TUIExtensions.m */,
);
name = Support;
path = lib/Support;
@@ -957,6 +963,7 @@
CBB74CAB13BE6E1900C85CB5 /* TUIImage+Drawing.h in Headers */,
88D81CFF1577EF0D009D453B /* TUIStyledView.h in Headers */,
CBB74CAD13BE6E1900C85CB5 /* TUIImage.h in Headers */,
+ 887C227B15C1C7BB006EC31D /* NSFont+TUIExtensions.h in Headers */,
CBB74CAF13BE6E1900C85CB5 /* TUIImageView.h in Headers */,
CBB74CB113BE6E1900C85CB5 /* TUIKit.h in Headers */,
CBB74CB313BE6E1900C85CB5 /* TUILabel.h in Headers */,
@@ -1397,6 +1404,7 @@
48A10E8415B7769A007F9EE3 /* TUILayoutManager.m in Sources */,
48A10E8915B778E8007F9EE3 /* TUIView+Layout.m in Sources */,
D07AA82915BDD79900F736C0 /* TUINSView+NSTextInputClient.m in Sources */,
+ 887C227C15C1C7BB006EC31D /* NSFont+TUIExtensions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
18 lib/Support/NSFont+TUIExtensions.h
@@ -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
View
23 lib/Support/NSFont+TUIExtensions.m
@@ -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
View
1  lib/UIKit/TUIKit.h
@@ -57,5 +57,6 @@
#import "TUIView+TUIBridgedView.h"
#import "TUIViewController.h"
#import "TUIViewNSViewContainer.h"
+#import "NSFont+TUIExtensions.h"
extern BOOL AtLeastLion; // set at launch
Please sign in to comment.
Something went wrong with that request. Please try again.