forked from Cocoanetics/DTCoreText
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDTCoreTextParagraphStyle.h
More file actions
210 lines (146 loc) · 6.31 KB
/
Copy pathDTCoreTextParagraphStyle.h
File metadata and controls
210 lines (146 loc) · 6.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
//
// DTCoreTextParagraphStyle.h
// DTCoreText
//
// Created by Oliver Drobnik on 4/14/11.
// Copyright 2011 Drobnik.com. All rights reserved.
//
/**
`DTCoreTextParagraphStyle` encapsulates the paragraph or ruler attributes used by the NSAttributedString classes on iOS. It is a replacement for `NSParagraphStyle` which is not implemented on iOS.
Since `NSAttributedString` instances use CTParagraphStyle object there are methods to bridge from and to these. Because of this distinction there is no need for a mutable variant of this class.
*/
@interface DTCoreTextParagraphStyle : NSObject <NSCopying>
/**
@name Creating a DTCoreTextParagraphStyle
*/
/**
Returns the default paragraph style.
*/
+ (DTCoreTextParagraphStyle *)defaultParagraphStyle;
/**
@name Bridging to and from CTParagraphStyle
*/
/**
Create a new paragraph style instance from a `CTParagraphStyle`.
@param ctParagraphStyle the `CTParagraphStyle` from which to copy this new style's attributes.
*/
+ (DTCoreTextParagraphStyle *)paragraphStyleWithCTParagraphStyle:(CTParagraphStyleRef)ctParagraphStyle;
/**
Create a new paragraph style instance from a `CTParagraphStyle`.
@param ctParagraphStyle the `CTParagraphStyle` from which to copy this new style's attributes.
*/
- (id)initWithCTParagraphStyle:(CTParagraphStyleRef)ctParagraphStyle;
/**
Create a new `CTParagraphStyle` from the receiver for use as attribute in `NSAttributedString`
@returns The `CTParagraphStyle` based on the receiver's attributes.
*/
- (CTParagraphStyleRef)createCTParagraphStyle;
/**
@name Bridging to and from NSParagraphStyle
*/
#if DTCORETEXT_SUPPORT_NS_ATTRIBUTES
/**
Create a new paragraph style instance from an `NSParagraphStyle`.
Note: on iOS no tab stops are supported.
@param paragraphStyle the `NSParagraphStyle` from which to copy this new style's attributes.
*/
+ (DTCoreTextParagraphStyle *)paragraphStyleWithNSParagraphStyle:(NSParagraphStyle *)paragraphStyle;
/**
Create a new `NSParagraphStyle` from the receiver for use as attribute in `NSAttributedString`.
Note: This method is requires iOS 6 or greater. This does not support tab stops.
@returns The `NSParagraphStyle` based on the receiver's attributes.
*/
- (NSParagraphStyle *)NSParagraphStyle;
#endif
/**-------------------------------------------------------------------------------------
@name Accessing Style Information
---------------------------------------------------------------------------------------
*/
/**
The indentation of the first line of the receiver.
*/
@property (nonatomic, assign) CGFloat firstLineHeadIndent;
/**
The document-wide default tab interval.
The default tab interval in points. Tabs after the last specified in tabStops are placed at integer multiples of this distance (if positive). Default return value is 0.0.
*/
@property (nonatomic, assign) CGFloat defaultTabInterval;
/**
The distance between the paragraph’s top and the beginning of its text content.
*/
@property (nonatomic, assign) CGFloat paragraphSpacingBefore;
/**
The space after the end of the paragraph.
*/
@property (nonatomic, assign) CGFloat paragraphSpacing;
/**
The line height multiple.
Internally line height multiples get converted into minimum and maximum line height.
*/
@property (nonatomic, assign) CGFloat lineHeightMultiple;
/**
The minimum height in points that any line in the receiver will occupy, regardless of the font size or size of any attached graphic. This value is always nonnegative.
*/
@property (nonatomic, assign) CGFloat minimumLineHeight;
/**
The maximum height in points that any line in the receiver will occupy, regardless of the font size or size of any attached graphic. This value is always nonnegative. The default value is 0.
*/
@property (nonatomic, assign) CGFloat maximumLineHeight;
/**
The distance in points from the margin of a text container to the end of lines.
@note This value is negative if it is to be measured from the trailing margin, positive if measured from the same margin as the headIndent.
*/
@property (nonatomic, assign) CGFloat tailIndent;
/**
The distance in points from the leading margin of a text container to the beginning of lines other than the first. This value is always nonnegative.
*/
@property (nonatomic, assign) CGFloat headIndent;
/**
The text alignment of the receiver.
Natural text alignment is realized as left or right alignment depending on the line sweep direction of the first script contained in the paragraph.
*/
@property (nonatomic, assign) CTTextAlignment alignment;
/**
The base writing direction for the receiver.
*/
@property (nonatomic, assign) CTWritingDirection baseWritingDirection;
/**-------------------------------------------------------------------------------------
@name Setting Tab Stops
---------------------------------------------------------------------------------------
*/
/**
The CTTextTab objects, sorted by location, that define the tab stops for the paragraph style.
*/
@property (nonatomic, copy) NSArray *tabStops;
/**
Adds a tab stop to the receiver.
@param position the tab stop position
@param alignment the tab alignment for this tab stop
*/
- (void)addTabStopAtPosition:(CGFloat)position alignment:(CTTextAlignment)alignment;
/**-------------------------------------------------------------------------------------
@name Interacting with CSS
---------------------------------------------------------------------------------------
*/
/**
Create a representation suitable for CSS.
@returns A string with the receiver's style encoded as CSS.
*/
- (NSString *)cssStyleRepresentation;
/**-------------------------------------------------------------------------------------
@name Setting Text Lists
---------------------------------------------------------------------------------------
*/
/**
Text lists containing the paragraph, nested from outermost to innermost. Each text list is a DTCSSListStyle object.
*/
@property (nonatomic, copy) NSArray *textLists;
/**-------------------------------------------------------------------------------------
@name Setting Text Blocks
---------------------------------------------------------------------------------------
*/
/**
Text blocks containing the paragraph, nested from outermost to innermost, to array. Each text block is a DTTextBlock object.
*/
@property (nonatomic, copy) NSArray *textBlocks;
@end