forked from facebookarchive/AsyncDisplayKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathASTextKitCoreTextAdditions.h
More file actions
88 lines (75 loc) · 3.98 KB
/
ASTextKitCoreTextAdditions.h
File metadata and controls
88 lines (75 loc) · 3.98 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
//
// ASTextKitCoreTextAdditions.h
// AsyncDisplayKit
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <AsyncDisplayKit/ASBaseDefines.h>
NS_ASSUME_NONNULL_BEGIN
ASDISPLAYNODE_EXTERN_C_BEGIN
/**
@abstract Returns whether a given attribute is an unsupported Core Text attribute.
@param attributeName The name of the attribute
@discussion The following Core Text attributes are not supported on NSAttributedString, and thus will not be preserved during the conversion:
- kCTForegroundColorFromContextAttributeName
- kCTSuperscriptAttributeName
- kCTGlyphInfoAttributeName
- kCTCharacterShapeAttributeName
- kCTLanguageAttributeName
- kCTRunDelegateAttributeName
- kCTBaselineClassAttributeName
- kCTBaselineInfoAttributeName
- kCTBaselineReferenceInfoAttributeName
- kCTWritingDirectionAttributeName
- kCTUnderlineColorAttributeName
@result Whether attributeName is an unsupported Core Text attribute.
*/
BOOL ASAttributeWithNameIsUnsupportedCoreTextAttribute(NSString *attributeName);
/**
@abstract Returns an attributes dictionary for use by NSAttributedString, given a dictionary of Core Text attributes.
@param coreTextAttributes An NSDictionary whose keys are CFAttributedStringRef attributes.
@discussion The following Core Text attributes are not supported on NSAttributedString, and thus will not be preserved during the conversion:
- kCTForegroundColorFromContextAttributeName
- kCTSuperscriptAttributeName
- kCTGlyphInfoAttributeName
- kCTCharacterShapeAttributeName
- kCTLanguageAttributeName
- kCTRunDelegateAttributeName
- kCTBaselineClassAttributeName
- kCTBaselineInfoAttributeName
- kCTBaselineReferenceInfoAttributeName
- kCTWritingDirectionAttributeName
- kCTUnderlineColorAttributeName
@result An NSDictionary of attributes for use by NSAttributedString.
*/
extern NSDictionary *NSAttributedStringAttributesForCoreTextAttributes(NSDictionary *coreTextAttributes);
/**
@abstract Returns an NSAttributedString whose Core Text attributes have been converted, where possible, to NSAttributedString attributes.
@param dirtyAttributedString An NSAttributedString that may contain Core Text attributes.
@result An NSAttributedString that's preserved as many CFAttributedString attributes as possible.
*/
extern NSAttributedString *ASCleanseAttributedStringOfCoreTextAttributes(NSAttributedString *dirtyAttributedString);
ASDISPLAYNODE_EXTERN_C_END
#pragma mark -
#pragma mark -
@interface NSParagraphStyle (ASTextKitCoreTextAdditions)
/**
@abstract Returns an NSParagraphStyle initialized with the paragraph specifiers from the given CTParagraphStyleRef.
@param coreTextParagraphStyle A Core Text paragraph style.
@discussion It is important to note that not all CTParagraphStyle specifiers are supported by NSParagraphStyle, and consequently, this is a lossy conversion. Notably, the following specifiers will not preserved:
- kCTParagraphStyleSpecifierTabStops
- kCTParagraphStyleSpecifierDefaultTabInterval
- kCTParagraphStyleSpecifierMaximumLineSpacing
- kCTParagraphStyleSpecifierMinimumLineSpacing
- kCTParagraphStyleSpecifierLineSpacingAdjustment
- kCTParagraphStyleSpecifierLineBoundsOptions
@result An NSParagraphStyle initialized with as many of the paragraph specifiers from `coreTextParagraphStyle` as possible.
*/
+ (instancetype)paragraphStyleWithCTParagraphStyle:(CTParagraphStyleRef)coreTextParagraphStyle;
@end
NS_ASSUME_NONNULL_END