adjust font size to make text fit within constrained size

# Conflicts:
#	AsyncDisplayKit/ASTextNode.mm
This commit is contained in:
rcancro
2016-02-12 11:11:06 -08:00
parent a4789f3524
commit a920e353c6
8 changed files with 284 additions and 129 deletions

View File

@@ -58,6 +58,7 @@ struct ASTextKitAttributes {
NSLineBreakMode lineBreakMode;
/**
The maximum number of lines to draw in the drawable region. Leave blank or set to 0 to define no maximum.
This is required to apply scale factors to shrink text to fit within a number of lines
*/
NSUInteger maximumNumberOfLines;
/**
@@ -82,9 +83,13 @@ struct ASTextKitAttributes {
*/
CGFloat shadowRadius;
/**
The minimum scale that the textnode can apply to fit long words in constrained size.
An array of scale factors in descending order to apply to the text to try to make it fit into a constrained size.
*/
CGFloat minimumScaleFactor;
NSArray *pointSizeScaleFactors;
/**
The currently applied scale factor. Only valid if pointSizeScaleFactors are provided. Defaults to 0 (no scaling)
*/
CGFloat currentScaleFactor;
/**
A pointer to a function that that returns a custom layout manager subclass. If nil, defaults to NSLayoutManager.
*/
@@ -112,8 +117,10 @@ struct ASTextKitAttributes {
[shadowColor copy],
shadowOpacity,
shadowRadius,
minimumScaleFactor,
layoutManagerFactory
pointSizeScaleFactors,
currentScaleFactor,
layoutManagerFactory,
layoutManagerDelegate,
};
};
@@ -124,7 +131,8 @@ struct ASTextKitAttributes {
&& maximumNumberOfLines == other.maximumNumberOfLines
&& shadowOpacity == other.shadowOpacity
&& shadowRadius == other.shadowRadius
&& minimumScaleFactor == other.minimumScaleFactor
&& [pointSizeScaleFactors isEqualToArray:other.pointSizeScaleFactors]
&& currentScaleFactor == currentScaleFactor
&& layoutManagerFactory == other.layoutManagerFactory
&& CGSizeEqualToSize(shadowOffset, other.shadowOffset)
&& _objectsEqual(exclusionPaths, other.exclusionPaths)