TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | Apache 2 |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
Copyright © 2009 Zynga Game Networks.
All .ttf files in this project are from http://www.webpagepublicity.com/free-fonts.html
This project provides 4 classes and 2 categories which are used to render text in custom fonts.
ZFont is the equivalent of UIFont but for arbitrary fonts.
Note that UIFont reports a larger ascender for some fonts (including Helvetica) than ZFont does. I do not know why this occurs. ZFont uses CoreGraphics to determine this information.
FontManager is used to cache CGFontRef objects so you can look them up by name, the same way that UIFont caches its internal font objects by name.
Call -[FontManager loadFont:]
once for each font you care about, generally as part
of your application startup. You then look up the ZFont objects later
with -[FontManager zFontWithName:]
. If you don't call -loadFont:
, it will be called
automatically for you when you call -zFontWithName:
.
This category is modeled after NSString (UIStringDrawing) and provides the basic mechanism for drawing text in a given CGFontRef. It differs in three key areas from UIStringDrawing:
Usage should be the same as the corresponding methods from UIStringDrawing.
ZAttributedString is an implementation of an attributed string, patterned after NSAttributedString from desktop Cocoa. The primary difference is ZMutableAttributedString does not offer a -mutableString method.
This category mimics NSString (FontLabelStringDrawing) but provides drawing primitives for ZAttributedString instead. They should all work like their FontLabelStringDrawing counterparts.
This is a subclass of UILabel that draws text using a ZFont instead
of a UIFont. It uses FontLabelStringDrawing internally to do the heavy lifting.
Wrapping, tail truncation, and -sizeToFit
work, as do the standard
textAlignment
/textColor
properties. A new zAttributedText
property
has been added that allows for attributed string rendering.
The following properties are ignored: