Permalink
Browse files

Remove TUIFont class

  • Loading branch information...
1 parent f71c6f6 commit e8d75b01722337eb0798b0789c39326a7a371a6c @jspahrsummers jspahrsummers committed Jul 25, 2012
Showing with 0 additions and 205 deletions.
  1. +0 −12 TwUI.xcodeproj/project.pbxproj
  2. +0 −44 lib/UIKit/TUIFont.h
  3. +0 −148 lib/UIKit/TUIFont.m
  4. +0 −1 lib/UIKit/TUIKit.h
@@ -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
@@ -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
@@ -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
@@ -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"

0 comments on commit e8d75b0

Please sign in to comment.