# `GSAnchor`

*Class*

A named point in a layer used for attachment and positioning.

## Declaration

```swift
class GSAnchor
```

```objc
@interface GSAnchor : GSElement
```

```python
class GSAnchor(GSElement)
```

## Overview

Anchor names determine how an anchor is used. A base anchor such as `top` pairs with the corresponding mark anchor `_top`. Other naming schemes support ligatures, cursive attachment, component placement, and contextual mark attachment.

The position is expressed in layer coordinates. The inherited orientation can make the horizontal position relative to the layer width.

A layer identifies its anchors by name and can contain at most one anchor for each name. Use the layer anchor APIs to attach or detach an anchor, and use [`GSAnchor.name`](/Core/GlyphsCore/GSAnchor/name) to rename an attached anchor so that the layer lookup remains consistent.

## Anchor Naming

Anchors are defined by their name. The following list covers naming schemes and names for which Glyphs provides specialized handling.

### Built-in Naming Schemes

- Base anchors use names such as `top`; mark anchors use the same name with a leading underscore, such as `_top`.
- Ligature anchors append a one-based component index after an underscore, such as `top_1` and `top_2`.
- Ligature caret anchors use `caret_N`, such as `caret_1`.
- Cursive attachment anchors use `entry` and `exit`. Cursive anchors can use the same suffix after each name to form separate cursive lookups, such as `entry.medial` and `exit.medial`. Use cursive attachment inside the Glyphs source file without exposing the anchors to the exported font files by prefixing the anchor name with `#`: `#entry` and `#exit`.
- Component connection anchors use `connect` on both the containing layer and the component glyph. Unlike mark attachment, the matching anchor on the component glyph has no leading underscore. Connection anchors are not treated as mark attachment anchors during anchor propagation.
- Context anchors are designated by prefixing the name with `*`, such as `*top`. A period suffix on a context anchor separates the mark class name from a local disambiguation suffix, such as `*top.case`.
- Mirrored components swap directional anchor names such as `left` and `right`, `top` and `bottom`, `entry` and `exit`, and `ogonek` and `ogonekabove`.

### Well-known Anchor Names

- `top`, `bottom`, `_top`, and `_bottom` have special behavior during component anchor traversal.
- `left`, `right`, `top`, `bottom`, `center`, `ogonek`, `ogonekabove`, `nukta`, `candra`, `imatra`, and `iimatra` are recognized by built-in anchor placement.
- `topleft`, `topright`, `bottomleft`, `bottomright`, `bindu`, and `candrabindu` are recognized when generating Indic mark positioning.
- `top_cantillation_final` and `bottom_cantillation` have special handling for Hebrew mark positioning.
- `LSB`, `RSB`, `TSB`, `BSB`, `HALT`, `VHAL`, `lfbd`, and `rtbd` are used to generate spacing feature code.
- `*origin` is reserved for component origin adjustment and is not a context anchor.
- `dotbelow` and names containing `bottom` have special handling for Myanmar mark-to-mark positioning.
- Corner glyphs use fixed anchor names such as `left`, `right`, `origin`, `node1`, `node2`, `start`, `end`, and `direction`.

## Topics

### Creating an Anchor

- [`GSAnchor initWithName:position:`](/Core/GlyphsCore/GSAnchor/initWithName:position:) — Creates a detached anchor.

### Anchor Identity

- [`GSAnchor.name`](/Core/GlyphsCore/GSAnchor/name) — The name that determines the attachment role.
- [`GSAnchor setNameFast:`](/Core/GlyphsCore/GSAnchor/setNameFast:) — Sets the name without copying it or updating an owning layer.

### Context Anchors

- [`GSAnchor.context`](/Core/GlyphsCore/GSAnchor/context) — The OpenType feature context for a context anchor, or `nil` when none is specified.

### Equality

- [`GSAnchor isEqualToAnchor:`](/Core/GlyphsCore/GSAnchor/isEqualToAnchor:) — Whether another anchor has the same position, name, attachment role, lock state, orientation, and attributes.

## Relationships

### Inherits From

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

### Conforms To

- `NSCoding`
- `NSCopying`

