Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 110 lines (72 sloc) 6.598 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
6974ca2 Oliver Drobnik try to replace paypal form button with regular button
authored
8 <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=M5DZ3PAN7NW8J">
9 <img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" />
10 </a>
04d37a0 Oliver Drobnik Added Pledgie to Readme
authored
11
8b2ad80 Oliver Drobnik Updated readme
authored
12 The project covers two broad areas:
13
14 1. Layouting - Interfacing with CoreText, generating NSAttributedString instances from HTML code
15 2. UI - several UI-related classes render these objects
571ae6e Sam Soffes Pretty readme to show off features
soffes authored
16
17 This is useful for drawing simple rich text like any HTML document without having to use a `UIWebView`.
18
5c366fa Oliver Drobnik Added link to Q&A
authored
19 Please read the [Q&A](http://www.cocoanetics.com/2011/08/nsattributedstringhtml-qa/).
20
170bbfb Oliver Drobnik Restructured and unified attachment handling for img, video, iframe, obj...
authored
21 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
22
23 If you find brief test cases where the created `NSAttributedString` differs from the version on OSX please send them to us!
24
25 Follow [@cocoanetics](http://twitter.com/cocoanetics) on Twitter.
f6daeef Oliver Drobnik Added note about CoreText loading performance workaround to Readme
authored
26
8b2ad80 Oliver Drobnik Updated readme
authored
27 License
cfba4d8 Joe Pasqualetti Added a more detailed installation guide using a subproject.
joepasq authored
28 -------
29
8b2ad80 Oliver Drobnik Updated readme
authored
30 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.
31
befdca7 Oliver Drobnik added Documentation target and link to gh-pages
authored
32 Documentation
33 -------------
34
35 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).
36
8b2ad80 Oliver Drobnik Updated readme
authored
37 Usage
38 -----
39
c67b0e8 Oliver Drobnik updated read me to reflect decreased deployment target
authored
40 DTCoreText needs a minimum iOS deployment target of iOS 4.2 because of:
60cfab5 Oliver Drobnik Updated readme
authored
41
42 - NSCache
43 - GCD-based threading and locking
44 - Blocks
44061fa Oliver Drobnik Updated Readme
authored
45 - ARC
60cfab5 Oliver Drobnik Updated readme
authored
46
cfba4d8 Joe Pasqualetti Added a more detailed installation guide using a subproject.
joepasq authored
47 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.
48
49 1. Download DTCoreText as a subfolder of your project folder
50 2. Open the destination project and drag `DTCoreText.xcodeproj` as a subordinate item in the Project Navigator
51 3. In your prefix.pch file add:
52
53 #import "DTCoreText.h"
54
300a8d8 Oliver Drobnik Updated Readme
authored
55 4. In your application target's Build Phases add the "Static Library" from the DTCoreText sub-project as a dependency.
56
57 5. 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):
cfba4d8 Joe Pasqualetti Added a more detailed installation guide using a subproject.
joepasq authored
58
a3e815a Oliver Drobnik Corrected readme
authored
59 The "Static Library" target from the DTCoreText sub-project
cfba4d8 Joe Pasqualetti Added a more detailed installation guide using a subproject.
joepasq authored
60 ImageIO.framework
61 QuartzCore.framework
62 libxml2.dylib
4ae0d3d Oliver Drobnik Added mention of CoreText.framework to read me. Closes #171
authored
63 CoreText.framework (DOH!)
cfba4d8 Joe Pasqualetti Added a more detailed installation guide using a subproject.
joepasq authored
64
300a8d8 Oliver Drobnik Updated Readme
authored
65 6. Go to File: Project Settings… and change the derived data location to project-relative.
66 7. Add the DerivedData folder to your git ignore.
67 8. In your application's target Build Settings:
ef89d4e Oliver Drobnik Updated Instructions as suggested by jockm. Closes #142
authored
68 - Set the "User Header Search Paths" to the directory containing your project with recrusive set to YES.
69 - Set the Header Search Paths to /usr/include/libxml2.
70 - Set "Always Search User Paths" to YES.
71 - Set the "Other Linker Flags" below
cfba4d8 Joe Pasqualetti Added a more detailed installation guide using a subproject.
joepasq authored
72
73 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.
74
e2bdabf Oliver Drobnik indenting
authored
75 LINKER SETTINGS:
3880629 Oliver Drobnik markdown
authored
76
300a8d8 Oliver Drobnik Updated Readme
authored
77 - add the -ObjC to your app target's "Other Linker Flags". This is needed whenever you link in any static library that contains Objective-C classes and categories.
78 - if you find that your app crashes with an unrecognized selector from one of this library's categories, you might also need the -all_load linker flag. Alternatively you can use -force-load with the full path to the static library. This causes the linker to load all categories from the static library.
e2bdabf Oliver Drobnik indenting
authored
79 - If your app does not use ARC yet (but DTCoreText does) then you also need the -fobjc-arc linker flag.
f6daeef Oliver Drobnik Added note about CoreText loading performance workaround to Readme
authored
80
ef89d4e Oliver Drobnik Updated Instructions as suggested by jockm. Closes #142
authored
81 *Other Options (only mentioned for completeness)*
8b2ad80 Oliver Drobnik Updated readme
authored
82
ef89d4e Oliver Drobnik Updated Instructions as suggested by jockm. Closes #142
authored
83 - Copy all classes and headers from the Core/Source folder to your project. Note for this you need to also generate and include the xxd'ed version of default.css.
84 - Link your project against the libDTCoreText static library that you previously compiled. 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.
85 - Link your project against the universal static library produced from the "Static Framework".
c987a51 Oliver Drobnik Added note to link in libxml2 library from now on.
authored
86
8b2ad80 Oliver Drobnik Updated readme
authored
87 Known Issues
88 ------------
f6daeef Oliver Drobnik Added note about CoreText loading performance workaround to Readme
authored
89
90 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:
91
92 - trigger the loading on a background thread like shown in http://www.cocoanetics.com/2011/04/coretext-loading-performance/
93 - 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
94
95 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
96
86b1501 Oliver Drobnik Updated both readies with known differences between Mac's initWithHTML a...
authored
97 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.
98
99 In the following "Mac" means the initWithHTML: methods there, "DTCoreText" means DTCoreText's initWithHTML and/or DTHTMLAttributedStringBuilder.
100
101 - Mac does not support the video tag, DTCoreText does.
102 - DTCoreText is able to synthesize small caps by putting all characters in upper case and using a second smaller font for lowercase characters.
103 - 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.
104 - 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
105 - 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)
d65442a Oliver Drobnik rewrite list support
authored
106 - Mac does not properly encode a double list start. iOS prints the empty list prefix.
9f535c3 Oliver Drobnik Added fixes for unit test so that when testing output matches (wrong) Ma...
authored
107 - Mac seems to ignore list-style-position:outside, iOS does the right thing.
86b1501 Oliver Drobnik Updated both readies with known differences between Mac's initWithHTML a...
authored
108
8b2ad80 Oliver Drobnik Updated readme
authored
109 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.