# `GSLayer`

*Class*

The drawing and editing representation of a glyph.

## Declaration

```swift
class GSLayer
```

```objc
@interface GSLayer : NSObject
```

```python
class GSLayer(NSObject)
```

## Overview

A **master layer** provides the glyph drawing associated with a font master. An **Intermediate layer** supplies interpolation data between masters. An **Alternative layer** replaces the associated master layer when its axis rules match. **Color layers** provide color-specific representations. **Smart layers** describe variations along glyph-local axes. Additional layers (**backup layers**) hold working or historical drawings without participating in export.

A layer belongs to a glyph, which in turn belongs to a font. This ownership gives the layer access to font axes, masters, and other glyphs. Detached layers are supported, but APIs that require font or glyph context can return no result or provide only partial behavior. Assign a [`GSLayer.parent`](/Core/GlyphsCore/GSLayer/parent) to a layer without adding it to a glyph to keep it temporary but still connected to a glyph and font.

Shapes form the graphical content of a layer. Paths describe contours, components reference other glyphs, and shape groups organize shapes hierarchically. Anchors provide named attachment positions, hints store outline instructions and path components, and guides assist editing without forming part of the outline.

Layer metrics describe the advance and spacing around the graphical content. Horizontal metrics include the width and side bearings, while vertical metrics include the vertical advance, origin, and side bearings. Metrics and metrics keys can depend on the associated font master and related glyphs.

A layer can produce Bézier paths, emit its content to a pen, or preserve richer paint and composition information in a draw stack. Its grid is derived from the associated master and controls coordinate rounding during editing and geometry operations.

A layer maintains the current selection and provides editing operations for its shapes and other selectable elements. Many editing methods operate on the selection when one exists and on all applicable content otherwise.

A layer can also have a background layer as an editable companion and a separate background image as reference.

## Topics

- [GSLayer Kind](/Core/GlyphsCore/GSLayer-Kind) — The different roles that a layer can serve.
- [GSLayer Shapes](/Core/GlyphsCore/GSLayer-Shapes) — The paths and components that form the outline of a layer.
- [GSLayer Bounds](/Core/GlyphsCore/GSLayer-Bounds) — Bounding rectangles of outlines, selections, and metrics.
- [GSLayer Metrics](/Core/GlyphsCore/GSLayer-Metrics) — Side bearings, baseline offsets, layer box, and metrics keys.
- [GSLayer Grid](/Core/GlyphsCore/GSLayer-Grid) — Setting for rounding coordinates on a layer.
- [GSLayer Background](/Core/GlyphsCore/GSLayer-Background) — Background content and reference images associated with a layer.
- [GSLayer Anchors](/Core/GlyphsCore/GSLayer-Anchors) — Named attachment points on a layer.
- [GSLayer Hints](/Core/GlyphsCore/GSLayer-Hints) — Manual and generated hint data on a layer.
- [GSLayer Guides](/Core/GlyphsCore/GSLayer-Guides) — Layer-local guides used while editing outlines.
- [GSLayer Kerning](/Core/GlyphsCore/GSLayer-Kerning) — Spacing adjustment between specific layers.
- [GSLayer Annotations](/Core/GlyphsCore/GSLayer-Annotations) — Layer-local notes displayed with a glyph.
- [GSLayer Interpolation](/Core/GlyphsCore/GSLayer-Interpolation) — Axis coordinates and rules that place layers in a design space.
- [GSLayer Color](/Core/GlyphsCore/GSLayer-Color) — Colors used to draw a layer.
- [GSLayer Attributes](/Core/GlyphsCore/GSLayer-Attributes) — Additional values stored for a layer.
- [GSLayer Inspection](/Core/GlyphsCore/GSLayer-Inspection) — Intersections between layer outlines and line segments.
- [GSLayer Editing](/Core/GlyphsCore/GSLayer-Editing) — Operations for modifying outlines and other layer content.
- [GSLayer Selection](/Core/GlyphsCore/GSLayer-Selection) — Access and modify the elements selected in a layer.
- [GSLayer Drawing](/Core/GlyphsCore/GSLayer-Drawing) — Create render representations and emit layer contents to pens.
- [GSLayer State](/Core/GlyphsCore/GSLayer-State) — Layer state management.
- [GSLayer Import/Export](/Core/GlyphsCore/GSLayer-Import-Export) — Encoding and decoding for layer data.

### Creating a Layer

- [`GSLayer initWithDict:format:`](/Core/GlyphsCore/GSLayer/initWithDict:format:) — Creates a layer from a property-list representation.

### Identity

- [`GSLayer.layerId`](/Core/GlyphsCore/GSLayer/layerId) — The identifier under which the layer is stored in its glyph.
- [`GSLayer.layerKey`](/Core/GlyphsCore/GSLayer/layerKey) — A derived key that distinguishes the layer by its role and attributes.
- [`GSLayer resetLayerKey`](/Core/GlyphsCore/GSLayer/resetLayerKey) — Invalidates the derived layer key after information used to form it changes.
- [`GSLayer.layerGroupKey`](/Core/GlyphsCore/GSLayer/layerGroupKey) — A derived key used to group corresponding special and color layers.

### Ownership

- [`GSLayer.parent`](/Core/GlyphsCore/GSLayer/parent) — The glyph containing the layer, or `nil` while the layer is detached.
- [`GSLayer.glyph`](/Core/GlyphsCore/GSLayer/glyph) — The glyph containing the layer, or `nil` while the layer is detached.
- [`GSLayer.font`](/Core/GlyphsCore/GSLayer/font) — The font containing the layer through its glyph, or `nil` while the layer is detached.

### Associated Master

- [`GSLayer.associatedMasterId`](/Core/GlyphsCore/GSLayer/associatedMasterId) — The identifier of the font master that supplies metrics and other master-specific values.
- [`GSLayer associatedFontMaster`](/Core/GlyphsCore/GSLayer/associatedFontMaster) — The master that supplies master-specific values for the layer.
- [`GSLayer associatedFontMasterThin:`](/Core/GlyphsCore/GSLayer/associatedFontMasterThin:) — Resolves the associated master with control over the amount of interpolated master data.
- [`GSLayer associatedFontMasterFast`](/Core/GlyphsCore/GSLayer/associatedFontMasterFast) — Directly looks up the associated master by its identifier.

### Naming

- [`GSLayer.name`](/Core/GlyphsCore/GSLayer/name) — A custom name for the layer.
- [`GSLayer.nameUI`](/Core/GlyphsCore/GSLayer/nameUI) — A name suitable for presenting the layer in the user interface.

### Color Label

- [`GSLayer.color`](/Core/GlyphsCore/GSLayer/color) — A custom color label, or `nil` when the layer has no custom color label.
- [`GSLayer.colorIndex`](/Core/GlyphsCore/GSLayer/colorIndex) — A standard color label, or [`GSLabelColor.GSLabelColorNoColor`](/Core/GlyphsCore/GSLabelColor/GSLabelColorNoColor) when no standard label is assigned.

### Copying

- [`GSLayer copyWithOptions:`](/Core/GlyphsCore/GSLayer/copyWithOptions:) — Creates an independent copy with the requested optional content.
- [`GSLayer copyWithOptions:selection:`](/Core/GlyphsCore/GSLayer/copyWithOptions:selection:) — Creates an independent copy with the requested optional content and selection handling.

### Equality and Comparison

- [`GSLayer isEqualToLayer:`](/Core/GlyphsCore/GSLayer/isEqualToLayer:) — Whether another layer has equal metrics, attributes, shapes, anchors, hints, guides, and background content.
- [`GSLayer compareString`](/Core/GlyphsCore/GSLayer/compareString) — A signature describing the interpolation-relevant structure of the layer.
- [`GSLayer compareStringOptions:`](/Core/GlyphsCore/GSLayer/compareStringOptions:) — A signature describing selected parts of the interpolation-relevant structure.
- [`GSLayer compareParticlesOptions:`](/Core/GlyphsCore/GSLayer/compareParticlesOptions:) — The individual parts that form a structural compatibility signature.

### Instance Properties

- [`GSLayer.hasAlignedWidthFast`](/Core/GlyphsCore/GSLayer/hasAlignedWidthFast) — Whether automatic alignment controls the layer width. just checking, not updating
- [`GSLayer.userDataFast`](/Core/GlyphsCore/GSLayer/userDataFast)

### Instance Methods

- [`GSLayer addAnchors:`](/Core/GlyphsCore/GSLayer/addAnchors:) — Add the anchors form the list
- [`GSLayer addAnchorsFast:`](/Core/GlyphsCore/GSLayer/addAnchorsFast:) — Add the anchors form the list without undo and KVO
- [`GSLayer applyCustomParameters:font:error:`](/Core/GlyphsCore/GSLayer/applyCustomParameters:font:error:)
- [`GSLayer applyCustomParameters:supporting:font:error:`](/Core/GlyphsCore/GSLayer/applyCustomParameters:supporting:font:error:)
- [`GSLayer axisInternalValueForId:`](/Core/GlyphsCore/GSLayer/axisInternalValueForId:)
- [`GSLayer checkConnectionsFast`](/Core/GlyphsCore/GSLayer/checkConnectionsFast) — same as `checkConnections` but without notifying and undo. Good when loading the path
- [`GSLayer cleanupPathAfterDeleting:`](/Core/GlyphsCore/GSLayer/cleanupPathAfterDeleting:)
- [`GSLayer keyForAttributeAxisRules`](/Core/GlyphsCore/GSLayer/keyForAttributeAxisRules) — A stable key of the Alternative-layer axis rules.
- [`GSLayer metricsKey:state:annotation:defaultKey:`](/Core/GlyphsCore/GSLayer/metricsKey:state:annotation:defaultKey:)
- [`GSLayer setAnchorsFast:`](/Core/GlyphsCore/GSLayer/setAnchorsFast:) — Internal fast anchor setter.
- [`GSLayer setCoordinate:forAxisId:`](/Core/GlyphsCore/GSLayer/setCoordinate:forAxisId:)
- [`GSLayer setNeedsAlignment`](/Core/GlyphsCore/GSLayer/setNeedsAlignment) — The next time the layer is drawn, align the components.
- [`GSLayer setWidthFast:`](/Core/GlyphsCore/GSLayer/setWidthFast:) — same as `setWidth:` but without notifying and undo. Good when loading the layer

### Type Methods

- [`GSLayer axisRuleKey:rule:`](/Core/GlyphsCore/GSLayer/axisRuleKey:rule:) — A stable key for an axis rule.

## Relationships

### Inherits From

- `NSObject`

### Inherited By

- [`GSBackgroundLayer`](/Core/GlyphsCore/GSBackgroundLayer)

### Conforms To

- [`GSContainerProtocol`](/Core/GlyphsCore/GSContainerProtocol)
- [`GSUserDataProtocol`](/Core/GlyphsCore/GSUserDataProtocol)
- `NSCoding`
- `NSCopying`

## See Also

### Essentials

- [`GSFont`](/Core/GlyphsCore/GSFont) — The top-level model object of a Glyphs document.
- [`GSGlyph`](/Core/GlyphsCore/GSGlyph) — A named glyph and its layer collection in a font.
- [`GSAxis`](/Core/GlyphsCore/GSAxis) — `GSAxis` represents an axis in a `GSFont` object.
- [`GSFontMaster`](/Core/GlyphsCore/GSFontMaster)
- [`GSInstance`](/Core/GlyphsCore/GSInstance)

