• This repository has been archived on 05/Oct/2018
  • Stars
    star
    539
  • Rank 82,402 (Top 2 %)
  • Language
    Objective-C
  • License
    BSD 3-Clause "New...
  • Created over 14 years ago
  • Updated over 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An Objective-C wrapper around Core Text for creating multi-column text and loading custom fonts

Core Text Objective-C Wrapper

Introduction

One of the most promising and mysterious new frameworks introduced in iOS 3.2 is Core Text. Apple defines Core Text as a “text drawing engine”, which allows Mac (and now iPad) apps to render rich text on any graphics context. Strings drawn with Core Text feature lots of custom settings such as detailed font information, columns, variable line and paragraph heights and several different attributes, which designers and font aficionados surely understand much better than I do. Many new apps have been using this framework since the release of the iPad, particularly newspapers and ebook reader applications, rendering gorgeous text in custom fonts, many of them not available natively in iOS. This framework is also used in lifestyle and corporate applications, too, where using a custom font is sometimes required to match the specifications of brands and trademarks.

image

It is very important to understand that Core Text is really just a text drawing engine to be used on top of Quartz (Core Graphics), to render rich text on any graphics context. Core Text cannot be used to create a rich text editor, for example, so don’t expect to extend UITextView with it. But you can use it to draw any kind of rich text on screen, which can make you avoid using UIWebView instances for that.

Features

One of the most interesting capabilities of Core Text is being able to render text in several columns. However, Core Text is a C-based framework, and I think that understanding and using the concepts and structures required to render text in columns can be particularly tricky. To make the my life and that of my fellow developers easier, this project contains a small set of Objective-C classes that encapsulate the creation of framesetters, attributed strings and other constructions, and takes care of the creation of several columns, as well as the division of the text in several pages if required.

The API interface is very simple (on purpose) and I’m pretty sure you’ll be able to integrate it very easily in your own projects, particularly if you look at the sample project where the classes are used. I’ve also added a category for UIFont, that returns the associated CTFontRef pointer, in a similar fashion to UIImage, which is able to return a pointer to the underlying CGImageRef pointer. It also allows to create a CTFontRef from any font embedded in the application bundle. I am puzzled that the framework designers haven’t included this by default in UIKit.

What’s next

A future extension I’d like to add would be a couple of categories to parse simple RTF or HTML strings (to start with, probably just with bold and italic text) and create the appropriate attributed string from it; there’s a couple of AppKit extensions to NSAttributedString that do exactly that, but for the moment they are only available in the Mac version of Cocoa, and I haven’t found anything similar for iOS yet.

Thanks

The following people have helped this project grow, with pull requests, comments or bug reports:

  • Jared Crawford contributed support for shadows in AKOCustomFontLabel.
  • Christian Menschel contributed the AKOMultiColumnTextViewDataSource protocol to add custom views in the text columns.

License

The code, as usual, is available through with BSD license (see the LICENSE file), so feel free to use it and even contribute bug fixes or enhancements if you want. The font embedded in the project is Polsku Regula, available through the Open Font Library.org. The project requires Xcode 3.2.3 and the iOS SDK 4.0, and it creates a simple application that works on the iPad (iOS 3.2). As usual, use it at your own risk. Enjoy!

More Repositories

1

SwiftMoment

A time and calendar manipulation library for iOS 9+, macOS 10.11+, tvOS 9+, watchOS 2+ written in Swift 4.
Swift
1,612
star
2

nib2objc

Set of tools and utilities (command line, GUI, Mac Service) to transform NIB files for the iPhone into Objective-C code files
Objective-C
1,131
star
3

iPhoneWebServicesClient

This project showcases different transport formats and libraries to consume web services from an iOS application.
Objective-C
297
star
4

eBook-Template

Template to create PDF, ePub and Kindle books with Asciidoctor
CSS
179
star
5

Senbei

An iPhone client for Fat Free CRM
Objective-C
155
star
6

iphonerestwrapper

This is an Xcode project (for iPhone), showing an Objective-C class (called Wrapper) which can be used to interact with remote REST web services.
Objective-C
152
star
7

async-uitableview

Sample project using the ASIHTTPRequest to load the public Flickr RSS feed, and then load the images in a UITableView in asynchronous fashion
Objective-C
134
star
8

PracticalCommonLisp_ePub

"Practical Common Lisp" by Peter Seibel in ePub format
HTML
118
star
9

bluewoki

A simple Bluetooth-based walkie-talkie for iOS using GameKit
Objective-C
99
star
10

iphone-keypad

A highly sloppy copy of Apple's own iPhone keypad
Objective-C
48
star
11

editorrific

This project features a simple editor similar to the one used in the Twitterriffic iPhone application.
Objective-C
46
star
12

cortito

Cortito - URL Shortener written in PHP
PHP
43
star
13

imagecachetest

This iPhone application is inspired on Alex Curylo’s article about the problems of UIImage’s imageNamed: method.
Objective-C
40
star
14

Sencha-Touch-2-Up-And-Running

Code of the book "Sencha Touch 2: Up and Running" published by O'Reilly
JavaScript
39
star
15

PlaygroundBookGenerator

Ruby scripts that can generate a whole Swift Playgrounds for iPad book from a Markdown file
Ruby
36
star
16

fontbrowser

iPhone Font Browser - This iPhone application is based on code from the Under the Bridge blog and allows users and developers to browse and play with the fonts available in the iPhone OS.
Objective-C
36
star
17

cocoarestwrapper

This is an Xcode project (for Mac OS X), showing an Objective-C class (called Wrapper) which can be used to interact with remote REST web services.
Objective-C
36
star
18

AKCascadingStyle

This project provides a simple framework to centralize style information (fonts, colors, etc) in iPhone and Mac applications.
Objective-C
29
star
19

EasyTableView

A set of UITableViewController and UINavigationController subclasses for quickly prototyping iPhone applications.
Objective-C
28
star
20

Mobile-JavaScript-Application-Development

Code of the book "Mobile JavaScript Application Development" published by O'Reilly
JavaScript
24
star
21

opengles2-xcode-book

This project contains sample code taken from the "OpenGL ES 2.0 Programming Guide" book, by Aaftab Munshi, Dan Ginsburg and Dave Shreiner, adapted for Xcode and the iPhone OS 3.0
Objective-C
21
star
22

iphonestripview

Sample project using a UIKit-based strip component, like those featured in the LinkedIn and Facebook applications.
20
star
23

CodeaCalc

A very simple calculator made with Codea on the iPad
Lua
19
star
24

TwitThis

Sample project showing a helper class which wraps the complexity of having to deal with many different Twitter clients from the same iPhone application
Objective-C
13
star
25

Lorenz

iPhone OS + Mac OS X (app + screen saver) implementation in OpenGL ES 1.1 of the Lorenz Attractor
Objective-C
10
star
26

django-blog-engine

A minimalistic blog application, done as a learning exercise of both Python and the Django Framework.
Python
7
star
27

Backlog

The demo application I showed at the iPhone Dev Day 2009
Objective-C
6
star
28

AKOLibrary

iOS Framework used in projects by akosma software
Objective-C
5
star
29

remproject

The project aims to the creation of an UML tool suitable both for academia and the industry, including Ivar Jacobson's proposed extensions for Aspect-Oriented Software Development (AOSD).
C++
5
star
30

CodeaSort

Implementation of sorting algorithms in Lua, for Codea
Lua
5
star
31

DelegateOrder

Project showing how to determine delegate object method call in Objective-C with NSProxy
Objective-C
5
star
32

GoogleReaderShared

A simple command-line utility for reading and parsing "shared" items in Google Reader
Ruby
4
star
33

Sencha-Touch-2-Minimal-MVC

Minimal Sencha Touch 2 MVC application, as created live during SwissJeese 2012
JavaScript
4
star
34

Swift-Presentation

Cocoa framework used to present Swift
Swift
4
star
35

swift-linux-docker

The Dockerfile and other stuff required to build a complete Swift on Linux Docker image
Shell
3
star
36

SwiftTribool

3-state boolean library for Swift, inspired in Boost.Tribool
Swift
3
star
37

CortitoService

A Mac OS X Service for shortening URLs with cortito
Objective-C
3
star
38

akosma.github.com

My personal Github page
3
star
39

omxplayerphp

Driving omxplayer through PHP on a Raspberry Pi
PHP
3
star
40

FakePhoneGap

Simple implementation of PhoneGap for teaching purposes
Objective-C
3
star
41

RooiFonts

Simple font manager for iOS
Objective-C
3
star
42

SwissAlert

An iPhone application to have the most important Swiss emergency phones at hand
JavaScript
2
star
43

TeachingEditor

JavaScript-based web editor that can be shared with students learning about mobile web apps
JavaScript
2
star
44

omxplayernode

Node.js + Express + socket.io interface for omxplayer on a Raspberry Pi.
JavaScript
2
star
45

akosma

My GitHub profile
2
star
46

iBeacon-Presentation

This presentation is about iBeacon - a new technology based on Bluetooth - for both iOS and Android smartphones and tablets.
Objective-C
2
star
47

Notitas

Simple post-it application for iOS
Objective-C
2
star
48

Markdown-Presentation-Template

Template for creating presentations using Markdown
JavaScript
1
star
49

dvdrental

A fictional movie rental system written in C++, built as an assignment during my master's degree.
C++
1
star
50

Accessible

A demo app covering some iOS 10 Accessibility features, shown in the Mobile Developers Summit Bangalore 2016
Swift
1
star
51

digital2.0

Objective-C
1
star
52

DeviceDNA

Application used to send UDID via e-mail
Objective-C
1
star
53

MinimalisticSwiftBrowser

Minimalistic Browser application for OS X built with Swift. Built on the shoulder of giants.
Swift
1
star
54

actsasmanifesto

Ruby on Rails plugin to change the world
Ruby
1
star
55

delicious_wp

A Ruby script that creates a WordPress entry with last week's posts on del.icio.us
Ruby
1
star
56

Slim-Framework-Dash-Docset

Dash Docset for the Slim Framework Documentation
Shell
1
star
57

iOS7-Presentation

A short summary of new APIs and features available for app developers in iOS 7. Shown in the GOTO Nights in Eindhoven and Amsterdam (November 20th and 21st 2013) and Zurich (December 18th 2013)
Objective-C
1
star
58

SmartPointerTest

A "smart pointer" implementation in Objective-C++
C
1
star
59

nodetutorial

Code written while reading the nodebeginner.org tutorial
JavaScript
1
star