Skip to content

UIFont category that allows loading local TrueType font files. This does NOT require defining fonts in the Info.plist file of the project. It is also specifically useful for Cydia Substrate extensions, where modifying the Info.plist is not viable.

License

Notifications You must be signed in to change notification settings

terry-au/UIFont-TTF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

UIFont-TTF

UIFont category that allows loading local TrueType Font files. This does NOT require defining fonts in the Info.plist file of the project. It is also specifically useful for Cydia Substrate extensions, where modifying the Info.plist is not viable.

Example Usage

From a Path:

    NSString *pathToFont = [[NSBundle mainBundle] pathForResource:@"segoeui" ofType:@"ttf"];
    UIFont *smallFontFromPath = [UIFont fontWithTTFAtPath:pathToFont size:18.0f];

From a Local File URL:

    NSString *pathToFont = [[NSBundle mainBundle] pathForResource:@"segoeui" ofType:@"ttf"];
    
    NSURL *URLToFont = [NSURL fileURLWithPath:pathToFont];
    UIFont *smallFontFromURL = [UIFont fontWithTTFAtURL:[NSURL fileURLWithPath:pathToFont] size:18.0f];

Notes:

  • This category requires ARC, as non-ARC code uses different casting semantics. ARC (and UIFont-TTF) makes use of __bridge casts.
  • Errors are generated by means of NSAssert. If NS_BLOCK_ASSERTIONS has been defined errors will not throw exceptions but instead fail silently. In this event, the font returned will be obtained from systemFontOfSize, taking into account the provided size.

About

UIFont category that allows loading local TrueType font files. This does NOT require defining fonts in the Info.plist file of the project. It is also specifically useful for Cydia Substrate extensions, where modifying the Info.plist is not viable.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published