This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement UI7Font and runtime patching
issue #21
- Loading branch information
1 parent
a73c26f
commit 89196cc
Showing
15 changed files
with
165 additions
and
49 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
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
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,53 @@ | ||
// | ||
// UI7Font.h | ||
// UI7Kit | ||
// | ||
// Created by Jeong YunWon on 13. 6. 22.. | ||
// Copyright (c) 2013 youknowone.org. All rights reserved. | ||
// | ||
|
||
#import <UI7Kit/UI7Utilities.h> | ||
|
||
UIKIT_EXTERN NSString *UI7FontAttributeNone; | ||
UIKIT_EXTERN NSString *UI7FontAttributeUltraLight; | ||
UIKIT_EXTERN NSString *UI7FontAttributeUltraLightItalic; | ||
UIKIT_EXTERN NSString *UI7FontAttributeLight; | ||
UIKIT_EXTERN NSString *UI7FontAttributeLightItalic; | ||
UIKIT_EXTERN NSString *UI7FontAttributeMedium; | ||
UIKIT_EXTERN NSString *UI7FontAttributeItalic; | ||
UIKIT_EXTERN NSString *UI7FontAttributeBold; | ||
UIKIT_EXTERN NSString *UI7FontAttributeBoldItalic; | ||
UIKIT_EXTERN NSString *UI7FontAttributeCondensedBold; | ||
UIKIT_EXTERN NSString *UI7FontAttributeCondensedBlack; | ||
|
||
@interface UI7Font : UIFont<UI7Patch> | ||
|
||
+ (UIFont *)systemFontOfSize:(CGFloat)fontSize; | ||
+ (UIFont *)boldSystemFontOfSize:(CGFloat)fontSize; | ||
+ (UIFont *)italicSystemFontOfSize:(CGFloat)fontSize; | ||
+ (UIFont *)systemFontOfSize:(CGFloat)fontSize attribute:(NSString *)attribute; | ||
|
||
@end | ||
|
||
//! @deprecated Use UI7FontAttributeLight | ||
UIKIT_EXTERN NSString *UI7FontWeightLight __deprecated; | ||
//! @deprecated Use UI7FontAttributeMedium | ||
UIKIT_EXTERN NSString *UI7FontWeightMedium __deprecated; | ||
//! @deprecated Use UI7FontAttributeBold | ||
UIKIT_EXTERN NSString *UI7FontWeightBold __deprecated; | ||
|
||
@interface UIFont (iOS7) | ||
|
||
+ (UIFont *)iOS7SystemFontOfSize:(CGFloat)fontSize attribute:(NSString *)attribute; | ||
|
||
/*! | ||
* @deprecated Use UI7Font::systemFontOfSize: | ||
*/ | ||
+ (UIFont *)iOS7SystemFontOfSize:(CGFloat)fontSize __deprecated; | ||
/*! | ||
* @deprecated Use UI7Font::systemFontOfSize:attribute: | ||
*/ | ||
+ (UIFont *)iOS7SystemFontOfSize:(CGFloat)fontSize weight:(NSString *)weight __deprecated; | ||
|
||
@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,70 @@ | ||
// | ||
// UI7Font.m | ||
// UI7Kit | ||
// | ||
// Created by Jeong YunWon on 13. 6. 22.. | ||
// Copyright (c) 2013 youknowone.org. All rights reserved. | ||
// | ||
|
||
#import "UI7Font.h" | ||
|
||
NSString *UI7FontAttributeNone = nil; | ||
NSString *UI7FontAttributeUltraLight = @"UltraLight"; | ||
NSString *UI7FontAttributeUltraLightItalic = @"UltraLightItalic"; | ||
NSString *UI7FontAttributeLight = @"Light"; | ||
NSString *UI7FontAttributeLightItalic = @"LightItalic"; | ||
NSString *UI7FontAttributeMedium = @"Medium"; | ||
NSString *UI7FontAttributeItalic = @"Italic"; | ||
NSString *UI7FontAttributeBold = @"Bold"; | ||
NSString *UI7FontAttributeBoldItalic = @"BoldItalic"; | ||
NSString *UI7FontAttributeCondensedBold = @"CondensedBold"; | ||
NSString *UI7FontAttributeCondensedBlack = @"CondensedBlack"; | ||
|
||
@implementation UI7Font | ||
|
||
+ (void)patch { | ||
Class target = [UI7Font class]; | ||
[self exportSelector:@selector(systemFontOfSize:) toClass:target]; | ||
[self exportSelector:@selector(boldSystemFontOfSize:) toClass:target]; | ||
[self exportSelector:@selector(italicSystemFontOfSize:) toClass:target]; | ||
} | ||
|
||
+ (UIFont *)systemFontOfSize:(CGFloat)fontSize { | ||
return [self iOS7SystemFontOfSize:fontSize attribute:UI7FontAttributeNone]; | ||
} | ||
|
||
+ (UIFont *)boldSystemFontOfSize:(CGFloat)fontSize { | ||
return [self iOS7SystemFontOfSize:fontSize attribute:UI7FontAttributeBold]; | ||
} | ||
|
||
+ (UIFont *)italicSystemFontOfSize:(CGFloat)fontSize { | ||
return [self iOS7SystemFontOfSize:fontSize attribute:UI7FontAttributeItalic]; | ||
} | ||
|
||
+ (UIFont *)systemFontOfSize:(CGFloat)fontSize attribute:(NSString *)attribute { | ||
return [self iOS7SystemFontOfSize:fontSize attribute:attribute]; | ||
} | ||
|
||
@end | ||
|
||
|
||
NSString *UI7FontWeightLight = @"Light"; | ||
NSString *UI7FontWeightMedium = @"Medium"; | ||
NSString *UI7FontWeightBold = @"Bold"; | ||
|
||
@implementation UIFont (iOS7) | ||
|
||
+ (UIFont *)iOS7SystemFontOfSize:(CGFloat)fontSize attribute:(NSString *)attribute { | ||
NSString *fontName = attribute ? [@"HelveticaNeue-%@" format:attribute] : @"Helvetica Neue"; | ||
return [UIFont fontWithName:fontName size:fontSize]; | ||
} | ||
|
||
+ (UIFont *)iOS7SystemFontOfSize:(CGFloat)fontSize { | ||
return [self iOS7SystemFontOfSize:fontSize attribute:nil]; | ||
} | ||
|
||
+ (UIFont *)iOS7SystemFontOfSize:(CGFloat)fontSize weight:(NSString *)weight { | ||
return [self iOS7SystemFontOfSize:fontSize attribute:weight]; | ||
} | ||
|
||
@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
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
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
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
Oops, something went wrong.