Coder Social home page Coder Social logo

vladimirivanovich / fontlabel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lilyball/fontlabel

0.0 2.0 0.0 64 KB

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

Home Page: http://zynga.com/

License: Apache License 2.0

fontlabel's Introduction

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 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 the system font (Helvetica) than ZFont does.
I suspect this is hard-coded behavior in UIFont.

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. I have not seen
  this behavior on any other fonts. I suspect it is a hard-coded edge case in UIFont.

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

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.

The following properties are ignored:

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

## TODO
- add support for markup
- support more properties from UILabel

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.