GSLayer Class Reference
| Inherits from | NSObject |
| Conforms to | NSCoding NSCopying |
Tasks
Info
-
parentproperty -
fontproperty -
glyphproperty -
nameproperty -
– ownName -
colorproperty -
colorIndexproperty -
userDataproperty -
visibleproperty -
layerDictproperty -
layerIdproperty -
associatedMasterIdproperty
Metrics
-
LSBproperty -
RSBproperty -
widthproperty -
TSBproperty -
BSBproperty -
vertWidthproperty -
vertOriginproperty -
hasAlignedWidthproperty -
isAlignedproperty -
leftMetricsKeyproperty -
widthMetricsKeyproperty -
rightMetricsKeyproperty -
topMetricsKeyproperty -
bottomMetricsKeyproperty -
vertWidthMetricsKeyproperty
Bezier Handling
-
bezierPathproperty -
openBezierPathproperty -
drawBezierPathproperty -
drawOpenBezierPathproperty -
selNodeproperty -
– initWithLayerDict: -
– compareString
Paths
-
pathsproperty -
– insertObject:inPathsAtIndex: -
– removePathAtIndex: -
– addPath: -
– removePath: -
– elementDidChange: -
– countOfPaths -
– objectInPathsAtIndex: -
– indexOfPath:
Anchors
-
anchorsproperty -
– countOfAnchors -
– addAnchor: -
– removeAnchor: -
– removeAnchorWithName: -
– anchorForName: -
– anchorForName:traverseComponents: -
– anchorNamesTraversingComponents -
– copyAnchorsFromComponents
Components
-
componentsproperty -
– countOfComponents -
– componentAtIndex: -
– addComponent: -
– insertComponent:atIndex: -
– removeComponent: -
– removeComponentAtIndex: -
– alignComponents -
– makeComponents -
– copyDecomposedLayer -
– decomposeComponents -
– decomposeComponent: -
– decomposeComponentDontNotifiy: -
– makeFirstComponent: -
componentNamesproperty -
backgroundproperty -
– contentToBackgroundCheckSelection:keepOldBackground: -
– swapForegroundWithBackground -
– clear
Image
Guides
-
guideLinesproperty -
– guideLineCount -
– guideLineAtIndex: -
hintsproperty -
– countOfHints -
– addHint: -
– hintAtIndex: -
– removeHint: -
– leftKerningForLayer: -
– rightKerningForLayer: -
– setLeftKerning:forLayer: -
– setRightKerning:forLayer: -
– leftKerningExeptionForLayer: -
– setLeftKerningExeption:forLayer: -
– rightKerningExeptionForLayer: -
– setRightKerningExeption:forLayer:
Selection
-
selectionproperty -
– 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*> *anchorsassociatedMasterId
The associatedMasterId is used to connect a layer which is not a master layer to a FontMaster.
@property (strong, nonatomic, nullable) NSString *associatedMasterIdDiscussion
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 *backgroundbackgroundImage
The image placed in the layer
@property (strong, nonatomic, nullable) GSBackgroundImage *backgroundImagebezierPath
Returns the bezierpath for the layer. Ignores open paths.
@property (nonatomic, strong, nullable) NSBezierPath *bezierPathSee Also
bottomMetricsKey
The metrics key for the bottom side bearing
@property (nonatomic, strong, nullable) NSString *bottomMetricsKeycolorIndex
Returns the index of the color label
@property (assign, nonatomic) NSInteger colorIndexReturn Value
0–11, anything else means no label
componentNames
An array containing names of the components in the layer
@property (strong, nonatomic) NSArray *componentNamesDiscussion
Warning: This replaces all components in the layer.
components
The array of GSComponents objects
@property (strong, nonatomic) NSArray<GSComponent*> *componentsdrawBezierPath
The bezierPath for drawing the layer. It inclused the paths and componetents.
@property (nonatomic, strong, nullable) NSBezierPath *drawBezierPathdrawOpenBezierPath
The openbBezierPath for drawing the layer. It inclused the paths and componetents.
@property (nonatomic, strong, nullable) NSBezierPath *drawOpenBezierPathglyph
A pointer to the containing GSGlyph object
@property (readonly, nonatomic, nullable) GSGlyph *glyphguideLines
An array containing all GSGuideLine objects of the layer
@property (strong, nonatomic) NSArray<GSGuideLine*> *guideLineshasAlignedWidth
YES if the layer has automatically aligned spacing
@property (nonatomic, readonly) BOOL hasAlignedWidthlayerDict
Returns the content of the layer to store in pList
@property (nonatomic, unsafe_unretained, readonly) NSDictionary *layerDictlayerId
The layer key is used to access the layer in the glyphs layer dictionary.
@property (strong, nonatomic) NSString *layerIdDiscussion
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 *leftMetricsKeyname
The title of the layer.
@property (strong, nonatomic, nullable) NSString *nameDiscussion
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 *openBezierPathrightMetricsKey
The metrics key for the right side bearing
@property (nonatomic, strong, nullable) NSString *rightMetricsKeyselNode
if there is one node selected, return it, otherwise return nil
@property (nonatomic, unsafe_unretained, readonly, nullable) GSNode *selNodeselection
An array of GSElement objects.
@property (strong, nonatomic) NSMutableOrderedSet *selectionDiscussion
All currently selected elements, otherwise nil.
topMetricsKey
The metrics key for the top side bearing
@property (nonatomic, strong, nullable) NSString *topMetricsKeyuserData
A dict where custom plugins can store data. It will be stored in the document file.
@property (strong, nonatomic, nullable) NSMutableDictionary *userDataDiscussion
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 vertOriginDiscussion
Used with vertWidth.
vertWidthMetricsKey
The metrics key for the vertical width
@property (nonatomic, strong, nullable) NSString *vertWidthMetricsKeyvisible
If the layer is visible
@property (nonatomic) BOOL visibleDiscussion
This is controlled from the Layer panel
widthMetricsKey
The metrics key for the width
@property (nonatomic, strong, nullable) NSString *widthMetricsKeyInstance Methods
addAnchor:
Adds the Anchor to the Layer.
- (void)addAnchor:(GSAnchor *)AnchorParameters
- Anchor
A Anchor.
addBackgroundImageWithURL:
Add the image at the given URL as layer image.
- (void)addBackgroundImageWithURL:(NSURL *)URLParameters
- URL
The Image URL
Discussion
It verifies if it really is an Image.
addComponent:
Adds the Component to the Layer.
- (void)addComponent:(GSComponent *)ComponentParameters
- Component
A GSComponent object.
addExtremePointsForce:
Add Extreme Points to all paths.
- (void)addExtremePointsForce:(BOOL)ForceParameters
- Force
Forces extremes if YES.
addPath:
Add a path to the layer
- (void)addPath:(GSPath *)PathParameters
- 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 *)newSelectionParameters
- newSelection
The element to add to the selection.
anchorForName:
Returns the corresponding anchor for an anchor name.
- (GSAnchor *)anchorForName:(NSString *)NameParameters
- Name
The name of the anchor, e.g. “top”
anchorForName:traverseComponents:
- (GSAnchor *_Nullable)anchorForName:(NSString *_Nonnull)Name traverseComponents:(BOOL)checkComponentsReturn Value
The anchor or nil
See Also
anchorNamesTraversingComponents
All anchor names from nested components
- (NSArray *)anchorNamesTraversingComponentsReturn Value
A list of anchor names
associatedFontMaster
The master to which the layer belongs.
- (GSFontMaster *)associatedFontMasterReturn Value
The GSFontMaster to which the layer belongs.
bezierData
Returns the bezierpath encoded as NSData.
- (NSData *)bezierDataReturn 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)boundsReturn Value
An NSRect encompassing all paths and components in the layer.
boundsOfSelection
The bounding box of the current selection.
- (NSRect)boundsOfSelectionReturn 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)EndPointParameters
- 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)DecomposeParameters
- 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)checkConnectionscleanUpPaths
Tidies up paths in the layer (removes double points, unnecessary nodes, etc.)
- (void)cleanUpPathscompareString
Returns a string to easily compare the paths of the layers. Layers are compatible if they have the same compareString.
- (NSString *)compareStringReturn 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)theIndexReturn Value
A GSComponent object.
contentToBackgroundCheckSelection:keepOldBackground:
Moves objects to the background.
- (void)contentToBackgroundCheckSelection:(BOOL)CheckSelection keepOldBackground:(BOOL)KeepcopyDecomposedLayer
A GSLayer copy with all components decomposed.
- (GSLayer *)copyDecomposedLayerReturn Value
The layer containing only paths.
correctPathDirection
Corrects the path directions and reorders the paths in the layer.
- (void)correctPathDirectioncountOfHints
The number of hints in the layer
- (NSUInteger)countOfHintsReturn Value
Count of hints.
countOfPaths
Returns the count of paths in the layer.
- (NSUInteger)countOfPathsReturn Value
The count of paths in the layer.
decomposeComponent:
Decomposes the Component.
- (void)decomposeComponent:(GSComponent *)ComponentParameters
- Component
The componet to decompose
decomposeComponentDontNotifiy:
Decomposes the Component but does not trigger a UI update
- (void)decomposeComponentDontNotifiy:(GSComponent *)aComponentParameters
- 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)decomposeComponentsDiscussion
This will also effect nested compontens.
drawInPen:
Draw the layer with a pen object
- (void)drawInPen:(NSObject<GSPenProtocol> *)PenParameters
- Pen
An object that conforms to the GSPenProtocol
elementDidChange:
Is called from element objects (anchors, components) if it has changed.
- (void)elementDidChange:(GSElement *)ElementParameters
- Element
The changed element
enableFutureUpdates
Enables updating but does not notifies for past changes
- (void)enableFutureUpdatesSee Also
glyph
The glyph to which the layer belongs. Equivalent to the parent property.
- (GSGlyph *)glyphReturn Value
The GSGlyph object for the layer.
guideLineAtIndex:
Returns the guideline loacated at theIndex.
- (GSGuideLine *_Nullable)guideLineAtIndex:(NSUInteger)theIndexParameters
- theIndex
An index within the bounds of the the guidelines array.
Return Value
A GSComponent object.
guideLineCount
Number of guidelines in the layer.
- (NSUInteger)guideLineCountReturn Value
NSUInteger containing the count of local guidelines.
hintAtIndex:
Returns the GSHint at the specified index.
- (GSHint *_Nullable)hintAtIndex:(NSUInteger)theIndexReturn Value
The GSHint object for the specified hint index.
horizontalShift:otherShifts:
Shifts the layer horizontally
- (void)horizontalShift:(CGFloat)Shift otherShifts:(NSDictionary *_Nullable)OtherShiftsParameters
- 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 *)PathParameters
- Path
An path object.
initWithLayerDict:
initialises a layer with a dictionary loaded from a pList.
- (instancetype)initWithLayerDict:(NSDictionary *)layerDictParameters
- layerDict
A dictionary
insertComponent:atIndex:
Adds a component at a specified index.
- (void)insertComponent:(GSComponent *)aComponent atIndex:(NSUInteger)IndexinsertObject:inPathsAtIndex:
Inserts a path into the paths array at the location specified by Index.
- (void)insertObject:(GSPath *)path inPathsAtIndex:(NSInteger)indexleftKerningExeptionForLayer:
Returns a boolean value if LeftLayer + self has a kerning exeption.
- (BOOL)leftKerningExeptionForLayer:(GSLayer *)LeftLayerParameters
- 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 *)LeftLayerParameters
- 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)makeComponentsmakeFirstComponent:
Makes the component first.
- (void)makeFirstComponent:(GSComponent *)ComponentParameters
- Component
The components that should be first.
objectInPathsAtIndex:
Returns the path at index.
- (GSPath *)objectInPathsAtIndex:(NSUInteger)indexReturn Value
A GSPath object.
ownName
retunes a name only for none master layers
- (nullable NSString *)ownNameReturn Value
a manually set name
removeAnchor:
Removes the anchor from the Layer.
- (void)removeAnchor:(GSAnchor *)AnchorParameters
- Anchor
A GSAnchor object.
removeAnchorWithName:
Removes the anchor with the name AnchorName from the layer.
- (void)removeAnchorWithName:(NSString *)AnchorNameParameters
- AnchorName
An anchor name.
removeComponent:
Removes a component from the Layer.
- (void)removeComponent:(GSComponent *)ComponentParameters
- Component
A GSComponent object.
removeComponentAtIndex:
Removes a component from the Layer
- (void)removeComponentAtIndex:(NSInteger)IndexParameters
- Index
The index of the component to be removed.
removeHint:
Removes the Hint from the Layer.
- (void)removeHint:(GSHint *)HintParameters
- Hint
A Hint.
removePath:
This is necessary for scripting over Distributed Object (JSTalk)
- (void)removePath:(GSPath *)PathParameters
- Path
The Path to remove from the layer.
removePathAtIndex:
Removes path from the layer
- (void)removePathAtIndex:(NSInteger)IndexParameters
- Index
Index of the path that will be removed
rightKerningExeptionForLayer:
Returns a boolean value if self + RightLayer has a kerning exeption.
- (BOOL)rightKerningExeptionForLayer:(GSLayer *)RightLayerParameters
- 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 *)RightLayerParameters
- 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 *)selectedObjectssetDisableUpdates
Disables updating
- (void)setDisableUpdatesDiscussion
Warning: Always make sure to call setEnableUpdates
See Also
setEnableUpdates
Enables updating and combined notifies for all changes that occured while disabled.
- (void)setEnableUpdatesSee Also
setLeftKerning:forLayer:
Sets the kerning for the sequence LeftLayer + self.
- (void)setLeftKerning:(CGFloat)Value forLayer:(GSLayer *)LeftLayerParameters
- 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 *)LeftLayerParameters
- 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 *)RightLayerParameters
- 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 *)RightLayerParameters
- 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)swapForegroundWithBackgroundtransformSelection:
Transforms all selected elements.
- (void)transformSelection:(NSAffineTransform *)TransformParameters
- Transform
the transfrom.
Discussion
This applies the Transform to all elements in the selection.