Skip to content
Browse files

Merge pull request #25 from github/remove-tuifont

Kill TUIFont
  • Loading branch information...
2 parents 01e83bd + 47d13b0 commit 45309bd582cd41f7168f01cd6abb3d5c92c0db42 @joshaber joshaber committed Jul 25, 2012
View
4 ExampleProject/ConcordeExample/ExampleView.h
@@ -22,8 +22,8 @@
TUITableView *_tableView;
ExampleTabBar *_tabBar;
- TUIFont *exampleFont1;
- TUIFont *exampleFont2;
+ NSFont *exampleFont1;
+ NSFont *exampleFont2;
}
@end
View
4 ExampleProject/ConcordeExample/ExampleView.m
@@ -28,8 +28,8 @@ - (id)initWithFrame:(CGRect)frame
self.backgroundColor = [TUIColor colorWithWhite:0.9 alpha:1.0];
// if you're using a font a lot, it's best to allocate it once and re-use it
- exampleFont1 = [TUIFont fontWithName:@"HelveticaNeue" size:15];
- exampleFont2 = [TUIFont fontWithName:@"HelveticaNeue-Bold" size:15];
+ exampleFont1 = [NSFont fontWithName:@"HelveticaNeue" size:15];
+ exampleFont2 = [NSFont fontWithName:@"HelveticaNeue-Bold" size:15];
CGRect b = self.bounds;
b.origin.y += TAB_HEIGHT;
View
12 TwUI.xcodeproj/project.pbxproj
@@ -32,7 +32,6 @@
5EE983C713BE7834005F430D /* TUIControl+TargetAction.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4B13BE6E1900C85CB5 /* TUIControl+TargetAction.m */; };
5EE983C813BE7834005F430D /* TUIControl.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4D13BE6E1900C85CB5 /* TUIControl.m */; };
5EE983C913BE7834005F430D /* TUIFastIndexPath.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4F13BE6E1900C85CB5 /* TUIFastIndexPath.m */; };
- 5EE983CA13BE7834005F430D /* TUIFont.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5113BE6E1900C85CB5 /* TUIFont.m */; };
5EE983CB13BE7834005F430D /* TUIGeometry.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5313BE6E1900C85CB5 /* TUIGeometry.m */; };
5EE983CC13BE7834005F430D /* TUIImage+Drawing.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5513BE6E1900C85CB5 /* TUIImage+Drawing.m */; };
5EE983CD13BE7834005F430D /* TUIImage.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5713BE6E1900C85CB5 /* TUIImage.m */; };
@@ -147,7 +146,6 @@
CB5E322913BE70CA004B7899 /* TUIControl+TargetAction.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4B13BE6E1900C85CB5 /* TUIControl+TargetAction.m */; };
CB5E322B13BE70CA004B7899 /* TUIControl.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4D13BE6E1900C85CB5 /* TUIControl.m */; };
CB5E322D13BE70CA004B7899 /* TUIFastIndexPath.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4F13BE6E1900C85CB5 /* TUIFastIndexPath.m */; };
- CB5E322F13BE70CA004B7899 /* TUIFont.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5113BE6E1900C85CB5 /* TUIFont.m */; };
CB5E323113BE70CA004B7899 /* TUIGeometry.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5313BE6E1900C85CB5 /* TUIGeometry.m */; };
CB5E323313BE70CA004B7899 /* TUIImage+Drawing.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5513BE6E1900C85CB5 /* TUIImage+Drawing.m */; };
CB5E323513BE70CA004B7899 /* TUIImage.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5713BE6E1900C85CB5 /* TUIImage.m */; };
@@ -205,8 +203,6 @@
CBB74CA413BE6E1900C85CB5 /* TUIControl.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4D13BE6E1900C85CB5 /* TUIControl.m */; };
CBB74CA513BE6E1900C85CB5 /* TUIFastIndexPath.h in Headers */ = {isa = PBXBuildFile; fileRef = CBB74C4E13BE6E1900C85CB5 /* TUIFastIndexPath.h */; settings = {ATTRIBUTES = (Public, ); }; };
CBB74CA613BE6E1900C85CB5 /* TUIFastIndexPath.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4F13BE6E1900C85CB5 /* TUIFastIndexPath.m */; };
- CBB74CA713BE6E1900C85CB5 /* TUIFont.h in Headers */ = {isa = PBXBuildFile; fileRef = CBB74C5013BE6E1900C85CB5 /* TUIFont.h */; settings = {ATTRIBUTES = (Public, ); }; };
- CBB74CA813BE6E1900C85CB5 /* TUIFont.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5113BE6E1900C85CB5 /* TUIFont.m */; };
CBB74CA913BE6E1900C85CB5 /* TUIGeometry.h in Headers */ = {isa = PBXBuildFile; fileRef = CBB74C5213BE6E1900C85CB5 /* TUIGeometry.h */; settings = {ATTRIBUTES = (Public, ); }; };
CBB74CAA13BE6E1900C85CB5 /* TUIGeometry.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5313BE6E1900C85CB5 /* TUIGeometry.m */; };
CBB74CAB13BE6E1900C85CB5 /* TUIImage+Drawing.h in Headers */ = {isa = PBXBuildFile; fileRef = CBB74C5413BE6E1900C85CB5 /* TUIImage+Drawing.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -501,8 +497,6 @@
CBB74C4D13BE6E1900C85CB5 /* TUIControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TUIControl.m; sourceTree = "<group>"; };
CBB74C4E13BE6E1900C85CB5 /* TUIFastIndexPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TUIFastIndexPath.h; sourceTree = "<group>"; };
CBB74C4F13BE6E1900C85CB5 /* TUIFastIndexPath.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TUIFastIndexPath.m; sourceTree = "<group>"; };
- CBB74C5013BE6E1900C85CB5 /* TUIFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TUIFont.h; sourceTree = "<group>"; };
- CBB74C5113BE6E1900C85CB5 /* TUIFont.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TUIFont.m; sourceTree = "<group>"; };
CBB74C5213BE6E1900C85CB5 /* TUIGeometry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TUIGeometry.h; sourceTree = "<group>"; };
CBB74C5313BE6E1900C85CB5 /* TUIGeometry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TUIGeometry.m; sourceTree = "<group>"; };
CBB74C5413BE6E1900C85CB5 /* TUIImage+Drawing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TUIImage+Drawing.h"; sourceTree = "<group>"; };
@@ -796,8 +790,6 @@
CBB74C4D13BE6E1900C85CB5 /* TUIControl.m */,
CBB74C4E13BE6E1900C85CB5 /* TUIFastIndexPath.h */,
CBB74C4F13BE6E1900C85CB5 /* TUIFastIndexPath.m */,
- CBB74C5013BE6E1900C85CB5 /* TUIFont.h */,
- CBB74C5113BE6E1900C85CB5 /* TUIFont.m */,
CBB74C5213BE6E1900C85CB5 /* TUIGeometry.h */,
CBB74C5313BE6E1900C85CB5 /* TUIGeometry.m */,
D0C7650415B6156A00E7AC2C /* TUIHostView.h */,
@@ -968,7 +960,6 @@
CBB74CA013BE6E1900C85CB5 /* TUIColor.h in Headers */,
CBB74CA313BE6E1900C85CB5 /* TUIControl.h in Headers */,
CBB74CA513BE6E1900C85CB5 /* TUIFastIndexPath.h in Headers */,
- CBB74CA713BE6E1900C85CB5 /* TUIFont.h in Headers */,
CBB74CA913BE6E1900C85CB5 /* TUIGeometry.h in Headers */,
CBB74CAB13BE6E1900C85CB5 /* TUIImage+Drawing.h in Headers */,
88D81CFF1577EF0D009D453B /* TUIStyledView.h in Headers */,
@@ -1282,7 +1273,6 @@
5EE983C713BE7834005F430D /* TUIControl+TargetAction.m in Sources */,
5EE983C813BE7834005F430D /* TUIControl.m in Sources */,
5EE983C913BE7834005F430D /* TUIFastIndexPath.m in Sources */,
- 5EE983CA13BE7834005F430D /* TUIFont.m in Sources */,
5EE983CB13BE7834005F430D /* TUIGeometry.m in Sources */,
5EE983CC13BE7834005F430D /* TUIImage+Drawing.m in Sources */,
5EE983CD13BE7834005F430D /* TUIImage.m in Sources */,
@@ -1357,7 +1347,6 @@
CBB74CA213BE6E1900C85CB5 /* TUIControl+TargetAction.m in Sources */,
CBB74CA413BE6E1900C85CB5 /* TUIControl.m in Sources */,
CBB74CA613BE6E1900C85CB5 /* TUIFastIndexPath.m in Sources */,
- CBB74CA813BE6E1900C85CB5 /* TUIFont.m in Sources */,
CBB74CAA13BE6E1900C85CB5 /* TUIGeometry.m in Sources */,
CBB74CAC13BE6E1900C85CB5 /* TUIImage+Drawing.m in Sources */,
CBB74CAE13BE6E1900C85CB5 /* TUIImage.m in Sources */,
@@ -1445,7 +1434,6 @@
CB5E322913BE70CA004B7899 /* TUIControl+TargetAction.m in Sources */,
CB5E322B13BE70CA004B7899 /* TUIControl.m in Sources */,
CB5E322D13BE70CA004B7899 /* TUIFastIndexPath.m in Sources */,
- CB5E322F13BE70CA004B7899 /* TUIFont.m in Sources */,
CB5E323113BE70CA004B7899 /* TUIGeometry.m in Sources */,
CB5E323313BE70CA004B7899 /* TUIImage+Drawing.m in Sources */,
CB5E323513BE70CA004B7899 /* TUIImage.m in Sources */,
View
5 lib/UIKit/TUIAttributedString.h
@@ -20,7 +20,6 @@ extern NSString * const TUIAttributedStringBackgroundColorAttributeName;
extern NSString * const TUIAttributedStringBackgroundFillStyleName;
extern NSString * const TUIAttributedStringPreDrawBlockName;
-@class TUIFont;
@class TUIColor;
typedef void (^TUIAttributedStringPreDrawBlock)(NSAttributedString *attributedString, NSRange substringRange, CGRect rects[], CFIndex rectCount);
@@ -61,7 +60,7 @@ typedef enum {
@interface NSMutableAttributedString (TUIAdditions)
// write-only properties, reading will return nil
-@property (nonatomic, retain) TUIFont *font;
+@property (nonatomic, retain) NSFont *font;
@property (nonatomic, retain) TUIColor *color;
@property (nonatomic, retain) TUIColor *backgroundColor;
@property (nonatomic, assign) TUIBackgroundFillStyle backgroundFillStyle;
@@ -74,7 +73,7 @@ typedef enum {
- (void)setAlignment:(TUITextAlignment)alignment lineBreakMode:(TUILineBreakMode)lineBreakMode;
- (NSRange)_stringRange;
-- (void)setFont:(TUIFont *)font inRange:(NSRange)range;
+- (void)setFont:(NSFont *)font inRange:(NSRange)range;
- (void)setColor:(TUIColor *)color inRange:(NSRange)range;
- (void)setBackgroundColor:(TUIColor *)color inRange:(NSRange)range;
- (void)setBackgroundFillStyle:(TUIBackgroundFillStyle)fillStyle inRange:(NSRange)range;
View
10 lib/UIKit/TUIAttributedString.m
@@ -15,7 +15,6 @@
*/
#import "TUIAttributedString.h"
-#import "TUIFont.h"
#import "TUIColor.h"
NSString * const TUIAttributedStringBackgroundColorAttributeName = @"TUIAttributedStringBackgroundColorAttributeName";
@@ -38,9 +37,10 @@ - (NSRange)_stringRange
return NSMakeRange(0, [self length]);
}
-- (void)setFont:(TUIFont *)font inRange:(NSRange)range
+- (void)setFont:(NSFont *)font inRange:(NSRange)range
{
- [self addAttribute:(NSString *)kCTFontAttributeName value:(id)[font ctFont] range:range];
+ // NSFont and CTFont are toll-free bridged.
+ [self addAttribute:(NSString *)kCTFontAttributeName value:font range:range];
}
- (void)setColor:(TUIColor *)color inRange:(NSRange)range
@@ -58,7 +58,7 @@ - (void)setKerning:(CGFloat)k inRange:(NSRange)range
[self addAttribute:(NSString *)kCTKernAttributeName value:[NSNumber numberWithFloat:k] range:range];
}
-- (void)setFont:(TUIFont *)font
+- (void)setFont:(NSFont *)font
{
[self setFont:font inRange:[self _stringRange]];
}
@@ -199,7 +199,7 @@ - (void)setAlignment:(TUITextAlignment)alignment
[self setAlignment:alignment lineBreakMode:TUILineBreakModeWordWrap];
}
-- (TUIFont *)font
+- (NSFont *)font
{
return nil;
}
View
44 lib/UIKit/TUIFont.h
@@ -1,44 +0,0 @@
-/*
- Copyright 2011 Twitter, Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this work except in compliance with the License.
- You may obtain a copy of the License in the LICENSE file, or at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#import <Foundation/Foundation.h>
-
-/*
- Your best bet is to build commonly used fonts at launch, cache for the lifetime of the app
- */
-
-@interface TUIFont : NSObject
-{
- CTFontRef _ctFont;
-}
-
-+ (TUIFont *)fontWithName:(NSString *)fontName size:(CGFloat)fontSize;
-
-+ (TUIFont *)systemFontOfSize:(CGFloat)fontSize;
-+ (TUIFont *)boldSystemFontOfSize:(CGFloat)fontSize;
-
-@property(nonatomic,readonly,strong) NSString *familyName;
-@property(nonatomic,readonly,strong) NSString *fontName;
-@property(nonatomic,readonly) CGFloat pointSize;
-@property(nonatomic,readonly) CGFloat ascender;
-@property(nonatomic,readonly) CGFloat descender;
-@property(nonatomic,readonly) CGFloat leading;
-@property(nonatomic,readonly) CGFloat capHeight;
-@property(nonatomic,readonly) CGFloat xHeight;
-
-@property (nonatomic, readonly) CTFontRef ctFont;
-
-@end
View
148 lib/UIKit/TUIFont.m
@@ -1,148 +0,0 @@
-/*
- Copyright 2011 Twitter, Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this work except in compliance with the License.
- You may obtain a copy of the License in the LICENSE file, or at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#import "TUIFont.h"
-
-@implementation TUIFont
-
-- (id)initWithCTFont:(CTFontRef)f
-{
- if((self = [super init]))
- {
- _ctFont = f;
- CFRetain(_ctFont);
- }
- return self;
-}
-
-- (void)dealloc
-{
- if(_ctFont)
- CFRelease(_ctFont);
-}
-
-static NSRange MakeNSRangeFromEndpoints(NSUInteger first, NSUInteger last) {
- return NSMakeRange(first, last - first + 1);
-}
-
-static NSFontDescriptor *arialUniDescFallback = nil;
-static NSDictionary *CachedFontDescriptors = nil;
-
-+ (void)initialize
-{
- if(self == [TUIFont class]) {
-
- // fallback stuff prevents massive stalls
- NSRange range = MakeNSRangeFromEndpoints(0x2100, 0x214F);
- NSCharacterSet *letterlikeSymbolsSet = [NSCharacterSet characterSetWithRange:range];
- arialUniDescFallback = [NSFontDescriptor fontDescriptorWithFontAttributes:
- [NSDictionary dictionaryWithObjectsAndKeys:
- @"ArialUnicodeMS", NSFontNameAttribute,
- letterlikeSymbolsSet, NSFontCharacterSetAttribute,
- nil]];
- NSString *normalFontName;
- NSString *lightFontName;
- NSString *mediumFontName;
- NSString *boldFontName;
- normalFontName = @"HelveticaNeue";
- lightFontName = @"HelveticaNeue-Light";
- mediumFontName = @"HelveticaNeue-Medium";
- boldFontName = @"HelveticaNeue-Bold";
-
- NSFontDescriptor *D_HelveticaNeue = [NSFontDescriptor fontDescriptorWithFontAttributes:
- [NSDictionary dictionaryWithObjectsAndKeys:
- normalFontName, NSFontNameAttribute,
- [NSArray arrayWithObject:arialUniDescFallback], NSFontCascadeListAttribute,
- nil]];
- NSFontDescriptor *D_HelveticaNeue_Light = [NSFontDescriptor fontDescriptorWithFontAttributes:
- [NSDictionary dictionaryWithObjectsAndKeys:
- lightFontName, NSFontNameAttribute,
- [NSArray arrayWithObject:arialUniDescFallback], NSFontCascadeListAttribute,
- nil]];
- NSFontDescriptor *D_HelveticaNeue_Medium = [NSFontDescriptor fontDescriptorWithFontAttributes:
- [NSDictionary dictionaryWithObjectsAndKeys:
- mediumFontName, NSFontNameAttribute,
- [NSArray arrayWithObject:arialUniDescFallback], NSFontCascadeListAttribute,
- nil]];
- NSFontDescriptor *D_HelveticaNeue_Bold = [NSFontDescriptor fontDescriptorWithFontAttributes:
- [NSDictionary dictionaryWithObjectsAndKeys:
- boldFontName, NSFontNameAttribute,
- [NSArray arrayWithObject:arialUniDescFallback], NSFontCascadeListAttribute,
- nil]];
-
- CachedFontDescriptors = [NSDictionary dictionaryWithObjectsAndKeys:
- D_HelveticaNeue, @"HelveticaNeue",
- D_HelveticaNeue_Light, @"HelveticaNeue-Light",
- D_HelveticaNeue_Medium, @"HelveticaNeue-Medium",
- D_HelveticaNeue_Bold, @"HelveticaNeue-Bold",
- nil];
- }
-}
-
-+ (TUIFont *)fontWithName:(NSString *)fontName size:(CGFloat)fontSize
-{
- NSFontDescriptor *desc = [CachedFontDescriptors objectForKey:fontName];
- if(!desc) {
- desc = [NSFontDescriptor fontDescriptorWithFontAttributes:
- [NSDictionary dictionaryWithObjectsAndKeys:
- fontName, NSFontNameAttribute,
- [NSArray arrayWithObject:arialUniDescFallback], NSFontCascadeListAttribute, // oh thank you jesus
- nil]];
-
- }
- CTFontRef font = CTFontCreateWithFontDescriptor((__bridge CTFontDescriptorRef)desc, fontSize, NULL);
- TUIFont *uiFont = [[TUIFont alloc] initWithCTFont:font];
- CFRelease(font);
-
- return uiFont;
-}
-
-+ (TUIFont *)systemFontOfSize:(CGFloat)fontSize
-{
- CTFontRef f = CTFontCreateUIFontForLanguage(kCTFontSystemFontType, fontSize, NULL);
- TUIFont *uifont = [[TUIFont alloc] initWithCTFont:f];
- CFRelease(f);
- return uifont;
-}
-
-+ (TUIFont *)boldSystemFontOfSize:(CGFloat)fontSize
-{
- CTFontRef f = CTFontCreateUIFontForLanguage(kCTFontEmphasizedSystemFontType, fontSize, NULL);
- TUIFont *uifont = [[TUIFont alloc] initWithCTFont:f];
- CFRelease(f);
- return uifont;
-}
-
-- (NSString *)familyName { return (__bridge_transfer NSString *)CTFontCopyFamilyName(_ctFont); }
-- (NSString *)fontName { return (__bridge_transfer NSString *)CTFontCopyPostScriptName(_ctFont); }
-- (CGFloat)pointSize { return CTFontGetSize(_ctFont); }
-- (CGFloat)ascender { return CTFontGetAscent(_ctFont); }
-- (CGFloat)descender { return CTFontGetDescent(_ctFont); }
-- (CGFloat)leading { return CTFontGetLeading(_ctFont); }
-- (CGFloat)capHeight { return CTFontGetCapHeight(_ctFont); }
-- (CGFloat)xHeight { return CTFontGetXHeight(_ctFont); }
-
-- (TUIFont *)fontWithSize:(CGFloat)fontSize
-{
- return nil;
-}
-
-- (CTFontRef)ctFont
-{
- return _ctFont;
-}
-
-@end
View
1 lib/UIKit/TUIKit.h
@@ -29,7 +29,6 @@
#import "TUICGAdditions.h"
#import "TUIColor.h"
#import "TUIFastIndexPath.h"
-#import "TUIFont.h"
#import "TUIHostView.h"
#import "TUIImage.h"
#import "TUIImageView.h"
View
4 lib/UIKit/TUILabel.h
@@ -30,7 +30,7 @@
} _textLabelFlags;
NSString *_text;
- TUIFont *_font;
+ NSFont *_font;
TUIColor *_textColor;
TUITextAlignment _alignment;
TUILineBreakMode _lineBreakMode;
@@ -41,7 +41,7 @@
@property(nonatomic,getter=isSelectable) BOOL selectable;
@property(nonatomic, readonly) TUITextRenderer *renderer;
-@property(nonatomic,strong) TUIFont *font;
+@property(nonatomic,strong) NSFont *font;
@property(nonatomic,strong) TUIColor *textColor;
@property(nonatomic,assign) TUITextAlignment alignment;
@property(nonatomic, assign) TUILineBreakMode lineBreakMode;
View
3 lib/UIKit/TUILabel.m
@@ -16,7 +16,6 @@
#import "TUILabel.h"
#import "TUIColor.h"
-#import "TUIFont.h"
#import "TUINSView.h"
#import "TUIStringDrawing.h"
#import "TUITextRenderer.h"
@@ -130,7 +129,7 @@ - (void)setText:(NSString *)text
self.attributedString = nil;
}
-- (void)setFont:(TUIFont *)font
+- (void)setFont:(NSFont *)font
{
if(font == _font) return;
View
12 lib/UIKit/TUIStringDrawing.h
@@ -17,7 +17,7 @@
#import <Foundation/Foundation.h>
#import "TUIAttributedString.h"
-@class TUIFont;
+@class NSFont;
@class TUIColor;
@interface NSAttributedString (TUIStringDrawing)
@@ -33,15 +33,15 @@
@interface NSString (TUIStringDrawing)
-- (CGSize)ab_sizeWithFont:(TUIFont *)font;
-- (CGSize)ab_sizeWithFont:(TUIFont *)font constrainedToSize:(CGSize)size;
+- (CGSize)ab_sizeWithFont:(NSFont *)font;
+- (CGSize)ab_sizeWithFont:(NSFont *)font constrainedToSize:(CGSize)size;
#if TARGET_OS_MAC
// for ABRowView
-//- (CGSize)drawInRect:(CGRect)rect withFont:(TUIFont *)font lineBreakMode:(TUILineBreakMode)lineBreakMode alignment:(TUITextAlignment)alignment;
+//- (CGSize)drawInRect:(CGRect)rect withFont:(NSFont *)font lineBreakMode:(TUILineBreakMode)lineBreakMode alignment:(TUITextAlignment)alignment;
#endif
-- (CGSize)ab_drawInRect:(CGRect)rect color:(TUIColor *)color font:(TUIFont *)font;
-- (CGSize)ab_drawInRect:(CGRect)rect withFont:(TUIFont *)font lineBreakMode:(TUILineBreakMode)lineBreakMode alignment:(TUITextAlignment)alignment;
+- (CGSize)ab_drawInRect:(CGRect)rect color:(TUIColor *)color font:(NSFont *)font;
+- (CGSize)ab_drawInRect:(CGRect)rect withFont:(NSFont *)font lineBreakMode:(TUILineBreakMode)lineBreakMode alignment:(TUITextAlignment)alignment;
@end
View
11 lib/UIKit/TUIStringDrawing.m
@@ -17,7 +17,6 @@
#import "TUIAttributedString.h"
#import "TUICGAdditions.h"
#import "TUIColor.h"
-#import "TUIFont.h"
#import "TUIStringDrawing.h"
#import "TUITextRenderer.h"
@@ -69,36 +68,36 @@ @implementation NSString (TUIStringDrawing)
#if TARGET_OS_MAC
-- (CGSize)ab_sizeWithFont:(TUIFont *)font
+- (CGSize)ab_sizeWithFont:(NSFont *)font
{
TUIAttributedString *s = [TUIAttributedString stringWithString:self];
s.font = font;
return [s ab_size];
}
-- (CGSize)ab_sizeWithFont:(TUIFont *)font constrainedToSize:(CGSize)size
+- (CGSize)ab_sizeWithFont:(NSFont *)font constrainedToSize:(CGSize)size
{
TUIAttributedString *s = [TUIAttributedString stringWithString:self];
s.font = font;
return [s ab_sizeConstrainedToSize:size];
}
-//- (CGSize)drawInRect:(CGRect)rect withFont:(TUIFont *)font lineBreakMode:(TUILineBreakMode)lineBreakMode alignment:(TUITextAlignment)alignment
+//- (CGSize)drawInRect:(CGRect)rect withFont:(NSFont *)font lineBreakMode:(TUILineBreakMode)lineBreakMode alignment:(TUITextAlignment)alignment
//{
// return [self ab_drawInRect:rect withFont:font lineBreakMode:lineBreakMode alignment:alignment];
//}
#endif
-- (CGSize)ab_drawInRect:(CGRect)rect color:(TUIColor *)color font:(TUIFont *)font
+- (CGSize)ab_drawInRect:(CGRect)rect color:(TUIColor *)color font:(NSFont *)font
{
TUIAttributedString *s = [TUIAttributedString stringWithString:self];
s.color = color;
s.font = font;
return [s ab_drawInRect:rect];
}
-- (CGSize)ab_drawInRect:(CGRect)rect withFont:(TUIFont *)font lineBreakMode:(TUILineBreakMode)lineBreakMode alignment:(TUITextAlignment)alignment
+- (CGSize)ab_drawInRect:(CGRect)rect withFont:(NSFont *)font lineBreakMode:(TUILineBreakMode)lineBreakMode alignment:(TUITextAlignment)alignment
{
TUIAttributedString *s = [TUIAttributedString stringWithString:self];
[s addAttribute:(NSString *)kCTForegroundColorFromContextAttributeName
View
2 lib/UIKit/TUITextRenderer.h
@@ -17,8 +17,8 @@
#import "TUIResponder.h"
#import "CoreText+Additions.h"
+@class NSFont;
@class TUIColor;
-@class TUIFont;
@class TUIView;
@protocol ABActiveTextRange;
View
1 lib/UIKit/TUITextRenderer.m
@@ -19,7 +19,6 @@
#import "TUIAttributedString.h"
#import "TUICGAdditions.h"
#import "TUIColor.h"
-#import "TUIFont.h"
#import "TUIStringDrawing.h"
#import "TUITextRenderer+Event.h"
#import "TUIView.h"
View
6 lib/UIKit/TUITextView.h
@@ -19,7 +19,7 @@
#import "TUIAttributedString.h"
@class TUITextEditor;
-@class TUIFont;
+@class NSFont;
@class TUIColor;
@protocol TUITextViewDelegate;
@@ -32,7 +32,7 @@
NSString *placeholder;
TUITextRenderer *placeholderRenderer;
- TUIFont *font;
+ NSFont *font;
TUIColor *textColor;
TUITextAlignment textAlignment;
BOOL editable;
@@ -67,7 +67,7 @@
@property (nonatomic, copy) NSString *text;
@property (nonatomic, copy) NSString *placeholder;
-@property (nonatomic, strong) TUIFont *font;
+@property (nonatomic, strong) NSFont *font;
@property (nonatomic, strong) TUIColor *textColor;
@property (nonatomic, assign) TUITextAlignment textAlignment;
@property (nonatomic, assign) TUIEdgeInsets contentInset;
View
11 lib/UIKit/TUITextView.m
@@ -17,7 +17,6 @@
#import "TUITextView.h"
#import "TUICGAdditions.h"
#import "TUIColor.h"
-#import "TUIFont.h"
#import "TUINSView.h"
#import "TUINSWindow.h"
#import "TUITextViewEditor.h"
@@ -90,12 +89,12 @@ - (void)dealloc {
- (void)_updateDefaultAttributes
{
renderer.defaultAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
- (id)[self.font ctFont], kCTFontAttributeName,
+ self.font, kCTFontAttributeName,
[self.textColor CGColor], kCTForegroundColorAttributeName,
ABNSParagraphStyleForTextAlignment(textAlignment), NSParagraphStyleAttributeName,
nil];
renderer.markedAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSFont fontWithName:self.font.fontName size:self.font.pointSize], kCTFontAttributeName, // NSFont and CTFont are toll-free bridged. *BUT* for reasons beyond my understanding, advanced input methods like Japanese and simplified Pinyin break unless this is an NSFont. So there we go.
+ self.font, kCTFontAttributeName,
[self.textColor CGColor], kCTForegroundColorAttributeName,
ABNSParagraphStyleForTextAlignment(textAlignment), NSParagraphStyleAttributeName,
nil];
@@ -122,7 +121,7 @@ - (id)initWithFrame:(CGRect)frame
self.autocorrectedResults = [NSMutableDictionary dictionary];
- self.font = [TUIFont fontWithName:@"HelveticaNeue" size:12];
+ self.font = [NSFont fontWithName:@"HelveticaNeue" size:12];
self.textColor = [TUIColor blackColor];
[self _updateDefaultAttributes];
@@ -166,7 +165,7 @@ - (TUIResponder *)initialFirstResponder
return renderer.initialFirstResponder;
}
-- (void)setFont:(TUIFont *)f
+- (void)setFont:(NSFont *)f
{
font = f;
[self _updateDefaultAttributes];
@@ -323,7 +322,7 @@ - (CGRect)_cursorRect
// Ugh. So this seems to be a decent approximation for the height of the cursor. It doesn't always match the native cursor but what ev.
CGRect r = CGRectIntegral([renderer firstRectForCharacterRange:ABCFRangeFromNSRange(selection)]);
r.size.width = 2.0f;
- CGRect fontBoundingBox = CTFontGetBoundingBox(self.font.ctFont);
+ CGRect fontBoundingBox = CTFontGetBoundingBox((__bridge CTFontRef)self.font);
r.size.height = round(fontBoundingBox.origin.y + fontBoundingBox.size.height);
r.origin.y += floor(self.font.leading);
//NSLog(@"ascent: %f, descent: %f, leading: %f, cap height: %f, x-height: %f, bounding: %@", self.font.ascender, self.font.descender, self.font.leading, self.font.capHeight, self.font.xHeight, NSStringFromRect(CTFontGetBoundingBox(self.font.ctFont)));
View
3 lib/UIKit/TUITooltipWindow.m
@@ -17,7 +17,6 @@
#import "TUITooltipWindow.h"
#import "TUIAttributedString.h"
#import "TUICGAdditions.h"
-#import "TUIFont.h"
#import "TUIStringDrawing.h"
#define TOOLTIP_HEIGHT 18
@@ -140,7 +139,7 @@ + (void)updateTooltip:(NSString *)s delay:(NSTimeInterval)delay
}
CurrentTooltipString = [TUIAttributedString stringWithString:s];
- CurrentTooltipString.font = [TUIFont fontWithName:@"HelveticaNeue" size:11];
+ CurrentTooltipString.font = [NSFont fontWithName:@"HelveticaNeue" size:11];
CurrentTooltipString.kerning = 0.2;
[CurrentTooltipString setAlignment:TUITextAlignmentCenter lineBreakMode:TUILineBreakModeClip];
} else {

0 comments on commit 45309bd

Please sign in to comment.
Something went wrong with that request. Please try again.