GSLayer Class Reference
Inherits from | NSObject |
Conforms to | NSCoding NSCopying |
Tasks
Info
-
parent
property -
font
property -
glyph
property -
name
property -
– ownName
-
color
property -
colorIndex
property -
userData
property -
visible
property -
layerDict
property -
layerId
property -
associatedMasterId
property
Metrics
-
LSB
property -
RSB
property -
width
property -
TSB
property -
BSB
property -
vertWidth
property -
vertOrigin
property -
hasAlignedWidth
property -
isAligned
property -
leftMetricsKey
property -
widthMetricsKey
property -
rightMetricsKey
property -
topMetricsKey
property -
bottomMetricsKey
property -
vertWidthMetricsKey
property
Bezier Handling
-
bezierPath
property -
openBezierPath
property -
drawBezierPath
property -
drawOpenBezierPath
property -
selNode
property -
– initWithLayerDict:
-
– compareString
Paths
-
paths
property -
– insertObject:inPathsAtIndex:
-
– removePathAtIndex:
-
– addPath:
-
– removePath:
-
– elementDidChange:
-
– countOfPaths
-
– objectInPathsAtIndex:
-
– indexOfPath:
Anchors
-
anchors
property -
– countOfAnchors
-
– addAnchor:
-
– removeAnchor:
-
– removeAnchorWithName:
-
– anchorForName:
-
– anchorForName:traverseComponents:
-
– anchorNamesTraversingComponents
-
– copyAnchorsFromComponents
Components
-
components
property -
– countOfComponents
-
– componentAtIndex:
-
– addComponent:
-
– insertComponent:atIndex:
-
– removeComponent:
-
– removeComponentAtIndex:
-
– alignComponents
-
– makeComponents
-
– copyDecomposedLayer
-
– decomposeComponents
-
– decomposeComponent:
-
– decomposeComponentDontNotifiy:
-
– makeFirstComponent:
-
componentNames
property -
background
property -
– contentToBackgroundCheckSelection:keepOldBackground:
-
– swapForegroundWithBackground
-
– clear
Image
Guides
-
guideLines
property -
– guideLineCount
-
– guideLineAtIndex:
-
hints
property -
– countOfHints
-
– addHint:
-
– hintAtIndex:
-
– removeHint:
-
– leftKerningForLayer:
-
– rightKerningForLayer:
-
– setLeftKerning:forLayer:
-
– setRightKerning:forLayer:
-
– leftKerningExeptionForLayer:
-
– setLeftKerningExeption:forLayer:
-
– rightKerningExeptionForLayer:
-
– setRightKerningExeption:forLayer:
Selection
-
selection
property -
– addSelection:
Updating
-
– setDisableUpdates
-
– setEnableUpdates
-
– enableFutureUpdates
-
– updatePath
-
– setNeedUpdateMetrics
-
– syncMetrics
-
– syncLeftMetrics
-
– syncRightMetrics
-
– updateMetrics
-
– associatedFontMaster
-
– glyphMetrics
-
– bounds
-
– boundsOfSelection
-
– cleanUpPaths
-
– checkConnections
-
– correctPathDirection
-
– addExtremePoints
-
– addExtremePointsForce:
-
– addInflectionPoints
-
– calculateIntersectionsStartPoint:endPoint:
-
– calculateIntersectionsStartPoint:endPoint:decompose:
-
– undoManager
-
– glyph
-
– selectedObjects
-
– bezierData
-
– transformSelection:
-
– horizontalShift:otherShifts:
-
– drawInPen:
-
– layerColor
Properties
anchors
An array of GSAnchor objects
@property (strong, nonatomic) NSDictionary<NSString*GSAnchor*> *anchors
associatedMasterId
The associatedMasterId is used to connect a layer which is not a master layer to a FontMaster.
@property (strong, nonatomic, nullable) NSString *associatedMasterId
Discussion
This is needed for copies of layers (e.g. for different versions) to access vertical metrics stored in the FontMaster. It could look like this: “FBCA074D-FCF3-427E-A700-7E318A949AE5”
background
The background layer for this layer
@property (strong, nonatomic, nullable) GSLayer *background
backgroundImage
The image placed in the layer
@property (strong, nonatomic, nullable) GSBackgroundImage *backgroundImage
bezierPath
Returns the bezierpath for the layer. Ignores open paths.
@property (nonatomic, strong, nullable) NSBezierPath *bezierPath
See Also
bottomMetricsKey
The metrics key for the bottom side bearing
@property (nonatomic, strong, nullable) NSString *bottomMetricsKey
colorIndex
Returns the index of the color label
@property (assign, nonatomic) NSInteger colorIndex
Return Value
0–11, anything else means no label
componentNames
An array containing names of the components in the layer
@property (strong, nonatomic) NSArray *componentNames
Discussion
Warning: This replaces all components in the layer.
components
The array of GSComponents objects
@property (strong, nonatomic) NSArray<GSComponent*> *components
drawBezierPath
The bezierPath for drawing the layer. It inclused the paths and componetents.
@property (nonatomic, strong, nullable) NSBezierPath *drawBezierPath
drawOpenBezierPath
The openbBezierPath for drawing the layer. It inclused the paths and componetents.
@property (nonatomic, strong, nullable) NSBezierPath *drawOpenBezierPath
glyph
A pointer to the containing GSGlyph object
@property (readonly, nonatomic, nullable) GSGlyph *glyph
guideLines
An array containing all GSGuideLine objects of the layer
@property (strong, nonatomic) NSArray<GSGuideLine*> *guideLines
hasAlignedWidth
YES if the layer has automatically aligned spacing
@property (nonatomic, readonly) BOOL hasAlignedWidth
layerDict
Returns the content of the layer to store in pList
@property (nonatomic, unsafe_unretained, readonly) NSDictionary *layerDict
layerId
The layer key is used to access the layer in the glyphs layer dictionary.
@property (strong, nonatomic) NSString *layerId
Discussion
For master layers this should be the id of the FontMaster. It could look like this: “FBCA074D-FCF3-427E-A700-7E318A949AE5”
leftMetricsKey
The metrics key for the left side bearing
@property (nonatomic, strong, nullable) NSString *leftMetricsKey
name
The title of the layer.
@property (strong, nonatomic, nullable) NSString *name
Discussion
for master layers this is the name of the associated FontMaster, otherwise it is a custom string (e.g. a date to keep track of history).
openBezierPath
Returns the bezierpath for open paths in the layer
@property (nonatomic, strong, nullable) NSBezierPath *openBezierPath
rightMetricsKey
The metrics key for the right side bearing
@property (nonatomic, strong, nullable) NSString *rightMetricsKey
selNode
if there is one node selected, return it, otherwise return nil
@property (nonatomic, unsafe_unretained, readonly, nullable) GSNode *selNode
selection
An array of GSElement objects.
@property (strong, nonatomic) NSMutableOrderedSet *selection
Discussion
All currently selected elements, otherwise nil.
topMetricsKey
The metrics key for the top side bearing
@property (nonatomic, strong, nullable) NSString *topMetricsKey
userData
A dict where custom plugins can store data. It will be stored in the document file.
@property (strong, nonatomic, nullable) NSMutableDictionary *userData
Discussion
The stored object have to conform to the NSCoding protocol.
vertOrigin
Holds an offset from the top of the glyph (ascender) to be applied in vertical typesetting.
@property (nonatomic) CGFloat vertOrigin
Discussion
Used with vertWidth.
vertWidthMetricsKey
The metrics key for the vertical width
@property (nonatomic, strong, nullable) NSString *vertWidthMetricsKey
visible
If the layer is visible
@property (nonatomic) BOOL visible
Discussion
This is controlled from the Layer panel
widthMetricsKey
The metrics key for the width
@property (nonatomic, strong, nullable) NSString *widthMetricsKey
Instance Methods
addAnchor:
Adds the Anchor to the Layer.
- (void)addAnchor:(GSAnchor *)Anchor
Parameters
- Anchor
A Anchor.
addBackgroundImageWithURL:
Add the image at the given URL as layer image.
- (void)addBackgroundImageWithURL:(NSURL *)URL
Parameters
- URL
The Image URL
Discussion
It verifies if it really is an Image.
addComponent:
Adds the Component to the Layer.
- (void)addComponent:(GSComponent *)Component
Parameters
- Component
A GSComponent object.
addExtremePointsForce:
Add Extreme Points to all paths.
- (void)addExtremePointsForce:(BOOL)Force
Parameters
- Force
Forces extremes if YES.
addPath:
Add a path to the layer
- (void)addPath:(GSPath *)Path
Parameters
- Path
A GSPath object.
Discussion
The path will be added to the end of the layer’s paths array.
addSelection:
adds a element to the selection.
- (void)addSelection:(GSElement *)newSelection
Parameters
- newSelection
The element to add to the selection.
anchorForName:
Returns the corresponding anchor for an anchor name.
- (GSAnchor *)anchorForName:(NSString *)Name
Parameters
- Name
The name of the anchor, e.g. “top”
anchorForName:traverseComponents:
- (GSAnchor *_Nullable)anchorForName:(NSString *_Nonnull)Name traverseComponents:(BOOL)checkComponents
Return Value
The anchor or nil
See Also
anchorNamesTraversingComponents
All anchor names from nested components
- (NSArray *)anchorNamesTraversingComponents
Return Value
A list of anchor names
associatedFontMaster
The master to which the layer belongs.
- (GSFontMaster *)associatedFontMaster
Return Value
The GSFontMaster to which the layer belongs.
bezierData
Returns the bezierpath encoded as NSData.
- (NSData *)bezierData
Return Value
a bezierpath encoded as NSData.
Discussion
This is necessary to send the bezierpath over the Distributed Objects Bridge.
bounds
The bounding box of the layer.
- (NSRect)bounds
Return Value
An NSRect encompassing all paths and components in the layer.
boundsOfSelection
The bounding box of the current selection.
- (NSRect)boundsOfSelection
Return Value
An NSRect encompassing all selected paths, components and anchors on the layer.
calculateIntersectionsStartPoint:endPoint:
Calculates the intersection of all Paths with the line between StartPoint and EndPoint
- (NSArray *)calculateIntersectionsStartPoint:(NSPoint)StartPoint endPoint:(NSPoint)EndPoint
Parameters
- StartPoint
the first point
- EndPoint
the second point
Return Value
a list of point values
calculateIntersectionsStartPoint:endPoint:decompose:
Calculates the intersection of all Paths with the line between StartPoint and EndPoint
- (NSArray *)calculateIntersectionsStartPoint:(NSPoint)StartPoint endPoint:(NSPoint)EndPoint decompose:(BOOL)Decompose
Parameters
- StartPoint
the first point
- EndPoint
the second point
- Decompose
indecates if components should be intersected, too.
Return Value
a list of point values
checkConnections
Checks is all nodes have the correct connection setting and corrects them if necessary.
- (void)checkConnections
cleanUpPaths
Tidies up paths in the layer (removes double points, unnecessary nodes, etc.)
- (void)cleanUpPaths
compareString
Returns a string to easily compare the paths of the layers. Layers are compatible if they have the same compareString.
- (NSString *)compareString
Return Value
An NSString.
Discussion
The string has a letter for each node, all components and all anchor names
Offcurve = o, Curve = c, Line = l.
componentAtIndex:
Returns the component located at theIndex.
- (GSComponent *)componentAtIndex:(NSUInteger)theIndex
Return Value
A GSComponent object.
contentToBackgroundCheckSelection:keepOldBackground:
Moves objects to the background.
- (void)contentToBackgroundCheckSelection:(BOOL)CheckSelection keepOldBackground:(BOOL)Keep
copyDecomposedLayer
A GSLayer copy with all components decomposed.
- (GSLayer *)copyDecomposedLayer
Return Value
The layer containing only paths.
correctPathDirection
Corrects the path directions and reorders the paths in the layer.
- (void)correctPathDirection
countOfHints
The number of hints in the layer
- (NSUInteger)countOfHints
Return Value
Count of hints.
countOfPaths
Returns the count of paths in the layer.
- (NSUInteger)countOfPaths
Return Value
The count of paths in the layer.
decomposeComponent:
Decomposes the Component.
- (void)decomposeComponent:(GSComponent *)Component
Parameters
- Component
The componet to decompose
decomposeComponentDontNotifiy:
Decomposes the Component but does not trigger a UI update
- (void)decomposeComponentDontNotifiy:(GSComponent *)aComponent
Parameters
- aComponent
The componet to decompose
Discussion
This is helpful in places where you just need the result but not need to redraw automatically
decomposeComponents
Decomposes components.
- (void)decomposeComponents
Discussion
This will also effect nested compontens.
drawInPen:
Draw the layer with a pen object
- (void)drawInPen:(NSObject<GSPenProtocol> *)Pen
Parameters
- Pen
An object that conforms to the GSPenProtocol
elementDidChange:
Is called from element objects (anchors, components) if it has changed.
- (void)elementDidChange:(GSElement *)Element
Parameters
- Element
The changed element
enableFutureUpdates
Enables updating but does not notifies for past changes
- (void)enableFutureUpdates
See Also
glyph
The glyph to which the layer belongs. Equivalent to the parent property.
- (GSGlyph *)glyph
Return Value
The GSGlyph object for the layer.
guideLineAtIndex:
Returns the guideline loacated at theIndex.
- (GSGuideLine *_Nullable)guideLineAtIndex:(NSUInteger)theIndex
Parameters
- theIndex
An index within the bounds of the the guidelines array.
Return Value
A GSComponent object.
guideLineCount
Number of guidelines in the layer.
- (NSUInteger)guideLineCount
Return Value
NSUInteger containing the count of local guidelines.
hintAtIndex:
Returns the GSHint at the specified index.
- (GSHint *_Nullable)hintAtIndex:(NSUInteger)theIndex
Return Value
The GSHint object for the specified hint index.
horizontalShift:otherShifts:
Shifts the layer horizontally
- (void)horizontalShift:(CGFloat)Shift otherShifts:(NSDictionary *_Nullable)OtherShifts
Parameters
- Shift
The Shift value.
- OtherShifts
A dict with shift values for the hole shift operation. Keys are glyphs names, value NSNumbers.
Discussion
This OtherShifts dict contains the shift values that will be applied to other glyphs at the same time. This is used to prevent diplacemnt of components if the base glyphs are shifted.
indexOfPath:
Returns the layer loacated at index.
- (NSInteger)indexOfPath:(GSPath *)Path
Parameters
- Path
An path object.
initWithLayerDict:
initialises a layer with a dictionary loaded from a pList.
- (instancetype)initWithLayerDict:(NSDictionary *)layerDict
Parameters
- layerDict
A dictionary
insertComponent:atIndex:
Adds a component at a specified index.
- (void)insertComponent:(GSComponent *)aComponent atIndex:(NSUInteger)Index
insertObject:inPathsAtIndex:
Inserts a path into the paths array at the location specified by Index.
- (void)insertObject:(GSPath *)path inPathsAtIndex:(NSInteger)index
leftKerningExeptionForLayer:
Returns a boolean value if LeftLayer + self has a kerning exeption.
- (BOOL)leftKerningExeptionForLayer:(GSLayer *)LeftLayer
Parameters
- LeftLayer
The GSLayer before the current layer
Return Value
True
if there is an exeption
leftKerningForLayer:
Return the kern value for the sequence LeftLayer + self.
- (CGFloat)leftKerningForLayer:(GSLayer *)LeftLayer
Parameters
- LeftLayer
The GSLayer before the current layer
Return Value
The kerning value as float or MaxInt if there is no value
Discussion
This checks if there is class kerning or exception.
Warning: returnes MaxInt if no value is defined for that pair
makeComponents
Builds the compound glyph from the components suggested in GlyphData.xml (decompose attribute).
- (void)makeComponents
makeFirstComponent:
Makes the component first.
- (void)makeFirstComponent:(GSComponent *)Component
Parameters
- Component
The components that should be first.
objectInPathsAtIndex:
Returns the path at index.
- (GSPath *)objectInPathsAtIndex:(NSUInteger)index
Return Value
A GSPath object.
ownName
retunes a name only for none master layers
- (nullable NSString *)ownName
Return Value
a manually set name
removeAnchor:
Removes the anchor from the Layer.
- (void)removeAnchor:(GSAnchor *)Anchor
Parameters
- Anchor
A GSAnchor object.
removeAnchorWithName:
Removes the anchor with the name AnchorName from the layer.
- (void)removeAnchorWithName:(NSString *)AnchorName
Parameters
- AnchorName
An anchor name.
removeComponent:
Removes a component from the Layer.
- (void)removeComponent:(GSComponent *)Component
Parameters
- Component
A GSComponent object.
removeComponentAtIndex:
Removes a component from the Layer
- (void)removeComponentAtIndex:(NSInteger)Index
Parameters
- Index
The index of the component to be removed.
removeHint:
Removes the Hint from the Layer.
- (void)removeHint:(GSHint *)Hint
Parameters
- Hint
A Hint.
removePath:
This is necessary for scripting over Distributed Object (JSTalk)
- (void)removePath:(GSPath *)Path
Parameters
- Path
The Path to remove from the layer.
removePathAtIndex:
Removes path from the layer
- (void)removePathAtIndex:(NSInteger)Index
Parameters
- Index
Index of the path that will be removed
rightKerningExeptionForLayer:
Returns a boolean value if self + RightLayer has a kerning exeption.
- (BOOL)rightKerningExeptionForLayer:(GSLayer *)RightLayer
Parameters
- RightLayer
The GSLayer after the current layer
Return Value
True
if there is an exeption
rightKerningForLayer:
Return the kern value for the sequence self + RightLayer.
- (CGFloat)rightKerningForLayer:(GSLayer *)RightLayer
Parameters
- RightLayer
The GSLayer after the current layer
Return Value
The kerning value as float or MaxInt if there is no value
Discussion
This checks if there is class kerning or exception.
Warning: returnes MaxInt if no value is defined for that pair
selectedObjects
Returns the element dicts of all selected elements
- (NSDictionary *)selectedObjects
setDisableUpdates
Disables updating
- (void)setDisableUpdates
Discussion
Warning: Always make sure to call setEnableUpdates
See Also
setEnableUpdates
Enables updating and combined notifies for all changes that occured while disabled.
- (void)setEnableUpdates
See Also
setLeftKerning:forLayer:
Sets the kerning for the sequence LeftLayer + self.
- (void)setLeftKerning:(CGFloat)Value forLayer:(GSLayer *)LeftLayer
Parameters
- Value
the kern value as float
- LeftLayer
The GSLayer before the current layer
Discussion
This checks if there is class kerning or exception.
setLeftKerningExeption:forLayer:
Sets, if LeftLayer + self has a exception or not.
- (void)setLeftKerningExeption:(BOOL)Exeption forLayer:(GSLayer *)LeftLayer
Parameters
- Exeption
if it is a exetion or not
- LeftLayer
The layer on the left
setRightKerning:forLayer:
Sets the kerning for the sequence self + RightLayer.
- (void)setRightKerning:(CGFloat)Value forLayer:(GSLayer *)RightLayer
Parameters
- Value
the kern value as float
- RightLayer
The GSLayer after the current layer
Discussion
This checks if there is class kerning or exception.
setRightKerningExeption:forLayer:
Sets, if LeftLayer + self has a exception or not.
- (void)setRightKerningExeption:(BOOL)Exeption forLayer:(GSLayer *)RightLayer
Parameters
- Exeption
if it is a exetion or not
- RightLayer
The layer to the right
swapForegroundWithBackground
Moves objects from the layer to its background layer and vice versa.
- (void)swapForegroundWithBackground
transformSelection:
Transforms all selected elements.
- (void)transformSelection:(NSAffineTransform *)Transform
Parameters
- Transform
the transfrom.
Discussion
This applies the Transform to all elements in the selection.