ShapingEngine
public class ShapingEngine
The ShapingEngine class represents text shaping engine.
-
Creates a shaping engine.
Declaration
Swift
public init() -
Returns the default writing direction of a script.
Declaration
Swift
public static func defaultDirectionForScript(_ scriptTag: SFNTTag) -> WritingDirectionParameters
scriptTagThe tag of the script whose default direction is returned.
Return Value
The default writing direction of the script identified by
scriptTag. -
The typeface which this shaping engine will use for shaping text.
Declaration
Swift
public var typeface: Typeface! -
The type size which this shaping engine will use for shaping text.
Declaration
Swift
public var typeSize: CGFloat -
The script tag which this shaping engine will use for shaping text. Its default value is
DFLT.Declaration
Swift
public var scriptTag: SFNTTag -
The language tag which this shaping engine will use for shaping text. Its default value is
dflt.Declaration
Swift
public var languageTag: SFNTTag -
The user-specified open type feature settings.
If the value of a feature is set to zero, it would be disabled provided that it is not a required feature of the chosen script. If the value of a feature is greater than zero, it would be enabled. In case of an alternate feature, this value would be used to pick the alternate glyph at this position.
Declaration
Swift
public var openTypeFeatures: [SFNTTag : Int] -
The direction in which this shaping engine will place the resultant glyphs. Its default value is
.leftToRight.The value of writing direction must reflect the rendering direction of source script so that cursive and mark glyphs are placed at appropriate locations. It should not be confused with the direction of a bidirectional run as that may not reflect the script direction if overridden explicitly.
Declaration
Swift
public var writingDirection: WritingDirection -
The order in which this shaping engine will process the text. Its default value is
.forward.This method provides a convenient way to shape a bidirectional run whose direction is opposite to that of script. For example, if the direction of a run, ‘car’ is explicitly set as right-to-left, backward order will automatically read it as ‘rac’ without reordering the original text.
Declaration
Swift
public var shapingOrder: ShapingOrder -
Shapes the specified UTF-16 range of text into glyphs.
The output glyphs in the
ShapingResultobject flow visually in writing direction. For left-to-right direction, the position of pen is incremented with glyph’s advance after rendering it. Similarly, for right-to-left direction, the position of pen is decremented with glyph’s advance after rendering it.Declaration
Swift
public func shape(string: String, codeUnitRange: Range<Int>) -> ShapingResultParameters
stringThe text to shape into glyphs.
codeUnitRangeThe UTF-16 range of text to be shaped.
Return Value
A new
ShapingResultobject. -
Shapes the specified range of text into glyphs.
The output glyphs in the
ShapingResultobject flow visually in writing direction. For left-to-right direction, the position of pen is incremented with glyph’s advance after rendering it. Similarly, for right-to-left direction, the position of pen is decremented with glyph’s advance after rendering it.Declaration
Swift
public func shape(string: String, characterRange: Range<String.Index>) -> ShapingResultParameters
stringThe text to shape into glyphs.
characterRangeThe character range of text to be shaped.
Return Value
A new
ShapingResultobject.
View on GitHub
Install in Dash
ShapingEngine Class Reference