Swiftgram/Source/TextKit/ASTextKitCoreTextAdditions.h
appleguy 465abb1ded [License] Simplify the Texture license to be pure Apache 2 (removing ASDK-Licenses). (#1077)
* [License] Simplify the Texture license to be pure Apache 2 (removing ASDK-Licenses)

With permission of the Facebook Open Source team, we are simplifying the Texture
license so that clients can rely on the Apache 2 terms that most of Texture is
already covered by. This means that code originally forked from AsyncDisplayKit
will be re-licensed from "BSD 3-clause + PATENTS v2" to Apache 2 without a
PATENTS file.

After getting confirmation that the updates to these core files look good, we'll
propagate this new license header to all files (in this same PR) and get sign-off
from all parties before landing.

* [License] Update all Texture source files to be pure Apache 2.

* Changelog entry for Apache 2 license update.

* Revert "[License] Update all Texture source files to be pure Apache 2."

This reverts commit ffa0fbbba9717d871dd16c4b07539f2f8208fc2b.

* [License] Update all Texture source files to be pure Apache 2, maintaining copyrights.

* [License] Update CONTRIBUTING, README, Podspec & Dangerfile.
2018-08-28 07:39:18 -07:00

85 lines
3.9 KiB
Objective-C

//
// ASTextKitCoreTextAdditions.h
// Texture
//
// Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
// Changes after 4/13/2017 are: Copyright (c) Pinterest, Inc. All rights reserved.
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <AsyncDisplayKit/ASBaseDefines.h>
NS_ASSUME_NONNULL_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.
*/
AS_EXTERN 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.
*/
AS_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.
*/
AS_EXTERN NSAttributedString *ASCleanseAttributedStringOfCoreTextAttributes(NSAttributedString *dirtyAttributedString);
#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.
*/
+ (NSParagraphStyle *)paragraphStyleWithCTParagraphStyle:(CTParagraphStyleRef)coreTextParagraphStyle NS_RETURNS_RETAINED;
@end
NS_ASSUME_NONNULL_END