github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

zynga / FontLabel

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 147
    • 9
  • Source
  • Commits
  • Network (9)
  • Issues (3)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

A project that includes a module for drawing arbitrary .ttf fonts for iPhone. — Read more

  cancel

http://zynga.com/

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Add missing #import <CoreGraphics/CoreGraphics.h> 
kballard (author)
Mon Oct 05 16:07:05 -0700 2009
commit  fa02fe6d597cfd9e175a26460116858799f23428
tree    b21aa0489d9b8aee65d466bc4403f01d1b210133
parent  337f379e787f1f1975301d83674bd53cb399ad77
FontLabel /
name age
history
message
directory FontLabel/ Mon Oct 05 16:07:05 -0700 2009 Add missing #import <CoreGraphics/CoreGraphics.h> [kballard]
file LICENSE Thu Apr 30 14:11:42 -0700 2009 added source files and resources [zynga]
file README Mon Oct 05 01:38:49 -0700 2009 Implement support for highlighted/highlightedTe... [kballard]
README
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
-----

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
-----------

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.

### Usage:

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:`.

NSString (FontLabelStringDrawing)
---------------------------------

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:

* Wrapping of sized/drawn strings properly character-wraps really long words that cannot fit
  on a single line by themselves even when the lineBreakMode is UILineBreakModeWordWrap.
  UIStringDrawing appears to behave incorrectly under the same circumstances.
* Only some line break modes are supported at the moment.
  Notably, Clip and Head/Middle truncation are not supported.
* UIFont reports a larger ascender for the system font (Helvetica) than ZFont.
  I cannot figure out why this is. This means UIStringDrawing/UILabel will size any text
  rendered in Helvetica with a taller bounding box than FontLabelStringDrawing.

Usage should be the same as the corresponding methods from UIStringDrawing.

ZAttributedString/ZMutableAttributedString
------------------------------------------

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.

ZAttributedString (ZAttributedStringDrawing)
--------------------------------------------

This category mimics NSString (FontLabelStringDrawing) but provides drawing primitives
for ZAttributedString instead. They should all work like their FontLabelStringDrawing
counterparts.

FontLabel
---------

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:

* enabled
* font (use zFont instead)
* shadowColor
* shadowOffset

## TODO
- support more properties from UILabel
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server