Inherits from NSObject
Conforms to NSCoding
NSCopying

Overview

The class defining the layer object

Tasks

Info

Metrics

Bezier Handling

Paths

Anchors

Components

Image

Guides

Selection

Updating

Properties

BSB

The bottom side bearing

@property (nonatomic, assign) CGFloat BSB

LSB

The left side bearing.

@property (nonatomic) CGFloat LSB

RSB

The right side bearing.

@property (nonatomic) CGFloat RSB

TSB

The top side bearing

@property (nonatomic, assign) CGFloat TSB

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

bottomMetricsKey

The metrics key for the bottom side bearing

@property (nonatomic, strong, nullable) NSString *bottomMetricsKey

color

The NSColor object of the color label

@property (strong, nonatomic, nullable) NSColor *color

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

font

Returns the containing GSFont object

@property (readonly, nonatomic, nullable) GSFont *font

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

hints

The array of hints

@property (nonatomic, strong) NSArray<GSHint*> *hints

isAligned

YES if the layer is automatically aligned

@property (nonatomic, readonly) BOOL isAligned

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

parent

Returns the containing GSGlyph object

@property (weak, nonatomic, nullable) GSGlyph *parent

paths

An array of GSPath objects

@property (strong, nonatomic, nullable) NSArray<GSPath*> *paths

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.

vertWidth

The vertical width

@property (nonatomic, assign) CGFloat 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

width

The width.

@property (nonatomic, assign) CGFloat width

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.

addExtremePoints

Add Extreme Points to all paths.

- (void)addExtremePoints

addExtremePointsForce:

Add Extreme Points to all paths.

- (void)addExtremePointsForce:(BOOL)Force

Parameters

Force

Forces extremes if YES.

addHint:

Adds the Hint to the Layer.

- (void)addHint:(GSHint *)Hint

Parameters

Hint

A GSHint.

addInflectionPoints

Adds nodes in segment inflections.

- (void)addInflectionPoints

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.

alignComponents

Helper function to fix component position.

- (void)alignComponents

Discussion

Call this every time you need to access the component. If the first component is a letter and the second is a accent, the Letter is placed at the origin, the width of the glyphs is copied from the referenced Glyph. If it find corresponding anchors it alignes the accents on it.

anchorForName:

Returns the corresponding anchor for an anchor name.

- (GSAnchor *)anchorForName:(NSString *)Name

Parameters

Name

The name of the anchor, e.g. “top”

Return Value

The GSAnchor object for the anchor name.

anchorForName:traverseComponents:

Returns a GSAnchor with for the given name.

- (GSAnchor *_Nullable)anchorForName:(NSString *_Nonnull)Name traverseComponents:(BOOL)checkComponents

Parameters

Name

The name of the anchor

checkComponents

if it should look into components

Return Value

The anchor or nil

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

clear

Empties the layer.

- (void)clear

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

Parameters

theIndex

An index within the bounds of the the paths array.

Return Value

A GSComponent object.

contentToBackgroundCheckSelection:keepOldBackground:

Moves objects to the background.

- (void)contentToBackgroundCheckSelection:(BOOL)CheckSelection keepOldBackground:(BOOL)Keep

Parameters

CheckSelection

Only selected objects if YES.

Keep

Replaces background layer if NO.

copyAnchorsFromComponents

Decomposes only the anchors.

- (void)copyAnchorsFromComponents

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

countOfAnchors

The count of the anchors

- (NSInteger)countOfAnchors

countOfComponents

Number of components in the layer.

- (NSUInteger)countOfComponents

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

glyph

The glyph to which the layer belongs. Equivalent to the parent property.

- (GSGlyph *)glyph

Return Value

The GSGlyph object for the layer.

glyphMetrics

Metrics for the Layer

- (GSGlyphMetrics)glyphMetrics

Return Value

The vertical metrics from the fonts fontMaster with the same layerId/associatedlayerId and the width of 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

Parameters

theIndex

An index within the bounds of the hints array.

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.

Return Value

The Index of Path in the paths array. If path is not in the paths array it returns NSNotFound.

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

Parameters

aComponent

A GSComponent object.

Index

An index within the components array.

insertObject:inPathsAtIndex:

Inserts a path into the paths array at the location specified by Index.

- (void)insertObject:(GSPath *)path inPathsAtIndex:(NSInteger)index

Parameters

path

A GSPath object.

index

An index within the paths array.

layerColor

The color for the layer.

- (NSColor *)layerColor

Return Value

the color as NSColor

Discussion

This can be a Palette entry (for MS color fonts) or the Master color for color layer fonts

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

Parameters

index

An index within the bounds of the the paths array.

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

setEnableUpdates

Enables updating and combined notifies for all changes that occured while disabled.

- (void)setEnableUpdates

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

setNeedUpdateMetrics

marks the RSB and LSB to need update.

- (void)setNeedUpdateMetrics

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

syncLeftMetrics

Recalculates the LSB using the metrics keys.

- (void)syncLeftMetrics

syncMetrics

Recalculates the LSB and RSB using the metrics keys.

- (void)syncMetrics

syncRightMetrics

Recalculates the RSB using the metrics keys.

- (void)syncRightMetrics

transformSelection:

Transforms all selected elements.

- (void)transformSelection:(NSAffineTransform *)Transform

Parameters

Transform

the transfrom.

Discussion

This applies the Transform to all elements in the selection.

undoManager

The undoManager of the parent (GSGlyph).

- (NSUndoManager *)undoManager

Return Value

An NSUndoManager object.

updateMetrics

Recalculates the LSB and RSB.

- (void)updateMetrics

updatePath

Is called from an object after it changed the outline of the layer.

- (void)updatePath