Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 109 lines (71 sloc) 6.566 kb
8b2ad80 @Cocoanetics Updated readme
authored
1 DTCoreText
2 ==========
571ae6e @soffes Pretty readme to show off features
soffes authored
3
8b2ad80 @Cocoanetics 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 @Cocoanetics Added Pledgie to Readme
authored
6 Please support us so that we can continue to make DTCoreText even more awesome!
7
6974ca2 @Cocoanetics 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 @Cocoanetics Added Pledgie to Readme
authored
11
8b2ad80 @Cocoanetics 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 @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 @Cocoanetics Added link to Q&A
authored
19 Please read the [Q&A](http://www.cocoanetics.com/2011/08/nsattributedstringhtml-qa/).
20
170bbfb @Cocoanetics Restructured and unified attachment handling for img, video, iframe, …
authored
21 Your help is much appreciated. Please send pull requests for useful additions you make or ask me what work is required.
571ae6e @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 @Cocoanetics Added note about CoreText loading performance workaround to Readme
authored
26
8b2ad80 @Cocoanetics Updated readme
authored
27 License
cfba4d8 @joepasq Added a more detailed installation guide using a subproject.
joepasq authored
28 -------
29
8b2ad80 @Cocoanetics 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 @Cocoanetics 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 @Cocoanetics Updated readme
authored
37 Usage
38 -----
39
e2dae92 @Cocoanetics Fixed spello
authored
40 DTCoreText needs a minimum iOS deployment target of 4.3 because of:
60cfab5 @Cocoanetics Updated readme
authored
41
42 - NSCache
43 - GCD-based threading and locking
44 - Blocks
44061fa @Cocoanetics Updated Readme
authored
45 - ARC
60cfab5 @Cocoanetics Updated readme
authored
46
cfba4d8 @joepasq 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 @Cocoanetics 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 @joepasq Added a more detailed installation guide using a subproject.
joepasq authored
58
a3e815a @Cocoanetics Corrected readme
authored
59 The "Static Library" target from the DTCoreText sub-project
cfba4d8 @joepasq Added a more detailed installation guide using a subproject.
joepasq authored
60 ImageIO.framework
61 QuartzCore.framework
62 libxml2.dylib
63
300a8d8 @Cocoanetics Updated Readme
authored
64 6. Go to File: Project Settings… and change the derived data location to project-relative.
65 7. Add the DerivedData folder to your git ignore.
66 8. In your application's target Build Settings:
ef89d4e @Cocoanetics Updated Instructions as suggested by jockm. Closes #142
authored
67 - Set the "User Header Search Paths" to the directory containing your project with recrusive set to YES.
68 - Set the Header Search Paths to /usr/include/libxml2.
69 - Set "Always Search User Paths" to YES.
70 - Set the "Other Linker Flags" below
cfba4d8 @joepasq Added a more detailed installation guide using a subproject.
joepasq authored
71
72 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.
73
e2bdabf @Cocoanetics indenting
authored
74 LINKER SETTINGS:
3880629 @Cocoanetics markdown
authored
75
300a8d8 @Cocoanetics Updated Readme
authored
76 - 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.
77 - 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 @Cocoanetics indenting
authored
78 - If your app does not use ARC yet (but DTCoreText does) then you also need the -fobjc-arc linker flag.
f6daeef @Cocoanetics Added note about CoreText loading performance workaround to Readme
authored
79
ef89d4e @Cocoanetics Updated Instructions as suggested by jockm. Closes #142
authored
80 *Other Options (only mentioned for completeness)*
8b2ad80 @Cocoanetics Updated readme
authored
81
ef89d4e @Cocoanetics Updated Instructions as suggested by jockm. Closes #142
authored
82 - 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.
83 - 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.
84 - Link your project against the universal static library produced from the "Static Framework".
c987a51 @Cocoanetics Added note to link in libxml2 library from now on.
authored
85
8b2ad80 @Cocoanetics Updated readme
authored
86 Known Issues
87 ------------
f6daeef @Cocoanetics Added note about CoreText loading performance workaround to Readme
authored
88
89 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:
90
91 - trigger the loading on a background thread like shown in http://www.cocoanetics.com/2011/04/coretext-loading-performance/
92 - 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 @Cocoanetics Updated Readme with new known issue
authored
93
94 Some combinations of fonts and unusual list types cause an extra space to appear. e.g. 20 px Courier + Circle
8b2ad80 @Cocoanetics Updated readme
authored
95
86b1501 @Cocoanetics Updated both readies with known differences between Mac's initWithHTM…
authored
96 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.
97
98 In the following "Mac" means the initWithHTML: methods there, "DTCoreText" means DTCoreText's initWithHTML and/or DTHTMLAttributedStringBuilder.
99
100 - Mac does not support the video tag, DTCoreText does.
101 - DTCoreText is able to synthesize small caps by putting all characters in upper case and using a second smaller font for lowercase characters.
102 - 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.
103 - 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 @Cocoanetics Fixed whitespace handling for PRE
authored
104 - 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 @Cocoanetics rewrite list support
authored
105 - Mac does not properly encode a double list start. iOS prints the empty list prefix.
9f535c3 @Cocoanetics Added fixes for unit test so that when testing output matches (wrong)…
authored
106 - Mac seems to ignore list-style-position:outside, iOS does the right thing.
86b1501 @Cocoanetics Updated both readies with known differences between Mac's initWithHTM…
authored
107
8b2ad80 @Cocoanetics Updated readme
authored
108 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.