Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 103 lines (65 sloc) 6.222 kb
8b2ad80 Oliver Drobnik Updated readme
authored
1 DTCoreText
2 ==========
571ae6e Sam Soffes Pretty readme to show off features
soffes authored
3
8b2ad80 Oliver Drobnik Updated readme
authored
4 This project aims to duplicate the methods present on Mac OSX which allow creation of `NSAttributedString` from HTML code on iOS. Previously we referred to it as NSAttributedString+HTML (or NSAS+HTML in short) but this only covers about half of what this framework does.
5
04d37a0 Oliver Drobnik Added Pledgie to Readme
authored
6 Please support us so that we can continue to make DTCoreText even more awesome!
7
8 <a href='http://www.pledgie.com/campaigns/16615'><img alt='Click here to lend your support to: Migrate DTCoreText to libxml2 and make a donation at www.pledgie.com !' src='http://www.pledgie.com/campaigns/16615.png?skin_name=chrome' border='0' /></a>
9
8b2ad80 Oliver Drobnik Updated readme
authored
10 The project covers two broad areas:
11
12 1. Layouting - Interfacing with CoreText, generating NSAttributedString instances from HTML code
13 2. UI - several UI-related classes render these objects
571ae6e Sam Soffes Pretty readme to show off features
soffes authored
14
15 This is useful for drawing simple rich text like any HTML document without having to use a `UIWebView`.
16
5c366fa Oliver Drobnik Added link to Q&A
authored
17 Please read the [Q&A](http://www.cocoanetics.com/2011/08/nsattributedstringhtml-qa/).
18
170bbfb Oliver Drobnik Restructured and unified attachment handling for img, video, iframe, obj...
authored
19 Your help is much appreciated. Please send pull requests for useful additions you make or ask me what work is required.
571ae6e Sam Soffes Pretty readme to show off features
soffes authored
20
21 If you find brief test cases where the created `NSAttributedString` differs from the version on OSX please send them to us!
22
23 Follow [@cocoanetics](http://twitter.com/cocoanetics) on Twitter.
f6daeef Oliver Drobnik Added note about CoreText loading performance workaround to Readme
authored
24
8b2ad80 Oliver Drobnik Updated readme
authored
25 License
cfba4d8 Joe Pasqualetti Added a more detailed installation guide using a subproject.
joepasq authored
26 -------
27
8b2ad80 Oliver Drobnik Updated readme
authored
28 It is open source and covered by a standard BSD license. That means you have to mention *Cocoanetics* as the original author of this code. You can purchase a Non-Attribution-License from us.
29
befdca7 Oliver Drobnik added Documentation target and link to gh-pages
authored
30 Documentation
31 -------------
32
33 Documentation can be [browsed online](http://cocoanetics.github.com/DTCoreText) or installed in your Xcode Organizer via the [Atom Feed URL](http://cocoanetics.github.com/DTCoreText/DTCoreText.atom).
34
8b2ad80 Oliver Drobnik Updated readme
authored
35 Usage
36 -----
37
e2dae92 Oliver Drobnik Fixed spello
authored
38 DTCoreText needs a minimum iOS deployment target of 4.3 because of:
60cfab5 Oliver Drobnik Updated readme
authored
39
40 - NSCache
41 - GCD-based threading and locking
42 - Blocks
44061fa Oliver Drobnik Updated Readme
authored
43 - ARC
60cfab5 Oliver Drobnik Updated readme
authored
44
cfba4d8 Joe Pasqualetti Added a more detailed installation guide using a subproject.
joepasq authored
45 The best way to use DTCoreText with Xcode 4.2 is to add it in Xcode as a subproject of your project with the following steps.
46
47 1. Download DTCoreText as a subfolder of your project folder
48 2. Open the destination project and drag `DTCoreText.xcodeproj` as a subordinate item in the Project Navigator
49 3. In your prefix.pch file add:
50
51 #import "DTCoreText.h"
52 #import <SenTestingKit/SenTestingKit.h>
53 #define ALLOW_IPHONE_SPECIAL_CASES 1
54
55 4. In your application target's Build Phases add all of the below to the Link Binary With Libraries phase (you can also do this from the Target's Summary view in the Linked Frameworks and Libraries):
56
57 libDTCoreText.a
58 CoreText.framework
59 ImageIO.framework
60 QuartzCore.framework
61 libxml2.dylib
62 SenTestingKit.framework
63
64 5. Go to File: Project Settings… and change the derived data location to project-relative.
65 6. Add the DerivedData folder to your git ignore.
66 6. In your application's target Build Settings set the "User Header Search Paths" to the directory containing your project with recrusive set to YES. Set the Header Search Paths to `/usr/include/libxml2`. Set "Always Search User Paths" to YES.
67
68 If you do not want to deal with Git submodules simply add DTCoreText to your project's git ignore file and pull updates to DTCoreText as its own independent Git repository. Otherwise you are free to add DTCoreText as a submodule.
69
70 *You also have these other installation options instead:*
f6daeef Oliver Drobnik Added note about CoreText loading performance workaround to Readme
authored
71
cfba4d8 Joe Pasqualetti Added a more detailed installation guide using a subproject.
joepasq authored
72 - Copy all classes and headers from the Core/Source folder to your project.
73 - Link your project against the libDTCoreText static library. Note that the "Static Library" target does not produce a universal library. You will also need to add all header files contained in the Core/Source folder to your project.
74 - Link your project against the universal static library produced from the "Static Framework".
8b2ad80 Oliver Drobnik Updated readme
authored
75
cfba4d8 Joe Pasqualetti Added a more detailed installation guide using a subproject.
joepasq authored
76 When linking you need` to add the -ObjC and -all_load to your app target's "Other Linker Flags". If your app does not use ARC yet (but DTCoreText does) then you also need the -fobjc-arc linker flag.
8b2ad80 Oliver Drobnik Updated readme
authored
77
60cfab5 Oliver Drobnik Updated readme
authored
78 When building from source it is recommended that you at the ALLOW_IPHONE_SPECIAL_CASES define to your PCH, this setting is "baked into" the library and framework targets.
79
0a56851 Kyle Hickinson Added note about libxml2
kylehickinson authored
80 The project has been changed to use libxml2 for parsing HTML, so you need to link in the libxml2.dylib, and, if you're copying all files from Core/Source, you must add the path "/usr/include/libxml2" to your header search paths as well.
c987a51 Oliver Drobnik Added note to link in libxml2 library from now on.
authored
81
8b2ad80 Oliver Drobnik Updated readme
authored
82 Known Issues
83 ------------
f6daeef Oliver Drobnik Added note about CoreText loading performance workaround to Readme
authored
84
85 CoreText has a problem prior to iOS 5 where it takes around a second on device to initialize its internal font lookup table. You have two workarounds available:
86
87 - trigger the loading on a background thread like shown in http://www.cocoanetics.com/2011/04/coretext-loading-performance/
88 - if you only use certain fonts then add the variants to the DTCoreTextFontOverrides.plist, this speeds up the finding of a specific font face from the font family
3e41ffc Oliver Drobnik Updated Readme with new known issue
authored
89
90 Some combinations of fonts and unusual list types cause an extra space to appear. e.g. 20 px Courier + Circle
8b2ad80 Oliver Drobnik Updated readme
authored
91
86b1501 Oliver Drobnik Updated both readies with known differences between Mac's initWithHTML a...
authored
92 In many aspects DTCoreText is superior to the Mac version of generating NSAttributedStrings from HTML. These become apparent in the MacUnitTest where the output from both is directly compared. I am summarizing them here for references.
93
94 In the following "Mac" means the initWithHTML: methods there, "DTCoreText" means DTCoreText's initWithHTML and/or DTHTMLAttributedStringBuilder.
95
96 - Mac does not support the video tag, DTCoreText does.
97 - DTCoreText is able to synthesize small caps by putting all characters in upper case and using a second smaller font for lowercase characters.
98 - I suspect that Mac makes use of the -webkit-margin-* CSS styles for spacing the paragraphs, DTCoreText only uses the -webkit-margin-bottom and margin-bottom at present.
99 - Mac supports CSS following addresses, e.g. "ul ul" to change the list style for stacked lists. DTCoreText does not support that and so list bullets stay the same for multiple levels.
3f8b370 Oliver Drobnik Fixed whitespace handling for PRE
authored
100 - Mac outputs newlines in PRE tags as \n, iOS replaces these with Unicode Line Feed characters so that the paragraph spacing is applied at the end of the PRE tag, not after each line. (iOS wraps code lines when layouting)
86b1501 Oliver Drobnik Updated both readies with known differences between Mac's initWithHTML a...
authored
101
8b2ad80 Oliver Drobnik Updated readme
authored
102 If you find an issue then you are welcome to fix it and contribute your fix via a GitHub pull request.
Something went wrong with that request. Please try again.