# `GSComponent`

*Class*

A reference to another glyph placed as a shape in a glyph layer.

## Declaration

```swift
class GSComponent
```

```objc
@interface GSComponent : GSTransformableElement
```

```python
class GSComponent(GSTransformableElement)
```

## Overview

- The *base glyph* is the glyph referenced by the component.
- The *component layer* is the specific layer that is referenced.
- The *containing layer* is the layer in which the component is  used as a shape.

Components can use automatic alignment to determine their position in the containing layer. There are different kinds of automatic alignment, see [`GSComponent.GSComponentAlignment`](/Core/GlyphsCore/GSComponent/GSComponentAlignment).

Automatic positioning can also be affected by using an anchor to snap a component into place. This mirrors the use of anchors in OpenType layout for mark positioning and cursive attachment.

*Smart Components* are components that reference a *Smart Glyph*. A Smart Glyph defines glyph-local axes that can be used to alter components of the glyph.

A component references a glyph by its glyph name. This can cause an invalid state in the following situations:

- The referenced glyph does not exist (no base glyph).
- The component references itself, causing an infinite reference cycle (bad reference).
- The referenced layer does not contain an outline (empty base glyph).

## Topics

### Creating a Component

- [`GSComponent initWithComponentName:`](/Core/GlyphsCore/GSComponent/initWithComponentName:) — Creates a component that references a base glyph by name.

### Base Glyph

- [`GSComponent.componentName`](/Core/GlyphsCore/GSComponent/componentName) — The name of the referenced base glyph.
- [`GSComponent.component`](/Core/GlyphsCore/GSComponent/component) — The base glyph resolved from [`GSComponent.componentName`](/Core/GlyphsCore/GSComponent/componentName) in the font of the containing layer.
- [`GSComponent updateComponentGlyph`](/Core/GlyphsCore/GSComponent/updateComponentGlyph) — Resolves the base glyph and updates the reference when the glyph was renamed.
- [`GSComponent updateComponentGlyphDontNotify`](/Core/GlyphsCore/GSComponent/updateComponentGlyphDontNotify) — Resolves the base glyph without registering a change to the component.
- [`GSComponent updateComponentGlyphFast`](/Core/GlyphsCore/GSComponent/updateComponentGlyphFast) — Resolves the base glyph without undo or change notifications.

### Base Layer

- [`GSComponent.componentMasterId`](/Core/GlyphsCore/GSComponent/componentMasterId) — The ID of the base-glyph master to use.
- [`GSComponent componentLayer`](/Core/GlyphsCore/GSComponent/componentLayer) — The applicable layer of the base glyph.
- [`GSComponent preloadCachedLayers`](/Core/GlyphsCore/GSComponent/preloadCachedLayers) — Prepares an interpolated smart-component layer for later access.

### Alignment

- [`GSComponent.GSComponentAlignment`](/Core/GlyphsCore/GSComponent/GSComponentAlignment) — A policy or result of automatically positioning a component.
- [`GSComponent.alignment`](/Core/GlyphsCore/GSComponent/alignment) — The policy for automatic positioning.
- [`GSComponent setAlignmentFast:`](/Core/GlyphsCore/GSComponent/setAlignmentFast:) — Sets the automatic-positioning policy without undo, change notifications, or layer updates.
- [`GSComponent.effectiveAlignment`](/Core/GlyphsCore/GSComponent/effectiveAlignment) — The result of the most recent automatic positioning.
- [`GSComponent.alignmentType`](/Core/GlyphsCore/GSComponent/alignmentType) — The coordinate mode used for automatic base-glyph alignment.
- [`GSComponent.doesAlign`](/Core/GlyphsCore/GSComponent/doesAlign) — Whether the component participates in automatic base-glyph alignment under the current policy.
- [`GSComponent.shouldAlign`](/Core/GlyphsCore/GSComponent/shouldAlign) — Whether the component and containing glyph normally qualify for automatic base-glyph alignment.
- [`GSComponent enableAlignment`](/Core/GlyphsCore/GSComponent/enableAlignment) — Enables automatic positioning.

### Attachment

- [`GSComponent.anchor`](/Core/GlyphsCore/GSComponent/anchor) — The base anchor name to use for automatic attachment.
- [`GSComponent.doesAttach`](/Core/GlyphsCore/GSComponent/doesAttach) — Whether the component participates in automatic anchor attachment under the current policy.
- [`GSComponent.shouldAttach`](/Core/GlyphsCore/GSComponent/shouldAttach) — Whether the component normally qualifies for automatic anchor attachment.
- [`GSComponent.traverseAnchors`](/Core/GlyphsCore/GSComponent/traverseAnchors) — Whether anchor traversal includes anchors from the component layer.

### Smart Components

- [`GSComponent.pieceSettings`](/Core/GlyphsCore/GSComponent/pieceSettings) — Explicit interpolation values for smart-component axes.
- [`GSComponent setPieceSettingsFast:`](/Core/GlyphsCore/GSComponent/setPieceSettingsFast:) — Replaces the smart-component settings without copying, undo, or change notifications.
- [`GSComponent setPieceValue:forKey:`](/Core/GlyphsCore/GSComponent/setPieceValue:forKey:) — Sets an explicit interpolation value for a smart-component axis.
- [`GSComponent removePieceValueForKey:`](/Core/GlyphsCore/GSComponent/removePieceValueForKey:) — Removes an explicit interpolation value for a smart-component axis.
- [`GSComponent pieceValueForKey:`](/Core/GlyphsCore/GSComponent/pieceValueForKey:) — The explicit interpolation value for a smart-component axis.
- [`GSComponent valueForAxis:`](/Core/GlyphsCore/GSComponent/valueForAxis:) — The effective interpolation value for a smart-component axis.

### Geometry

- [`GSComponent bounds`](/Core/GlyphsCore/GSComponent/bounds) — The bounds of the transformed component representation.
- [`GSComponent intersects:`](/Core/GlyphsCore/GSComponent/intersects:) — Whether the closed-path representation crosses that of another component.
- [`GSComponent intersectsDontCheckBounds:`](/Core/GlyphsCore/GSComponent/intersectsDontCheckBounds:) — Whether the closed-path representation crosses that of another component without first comparing their bounds.
- [`GSComponent intersectionsWithLineFrom:to:`](/Core/GlyphsCore/GSComponent/intersectionsWithLineFrom:to:) — Intersections between the transformed component representation and a line segment.

### Representations

- [`GSComponent bezierPath`](/Core/GlyphsCore/GSComponent/bezierPath) — The transformed closed paths of the component layer and its nested components.
- [`GSComponent bezierPathIgnorePlaceholder:`](/Core/GlyphsCore/GSComponent/bezierPathIgnorePlaceholder:) — The transformed closed paths of the component layer and its nested components.
- [`GSComponent bezierPathIgnorePlaceholder:seen:hasPaths:`](/Core/GlyphsCore/GSComponent/bezierPathIgnorePlaceholder:seen:hasPaths:) — Collects the transformed closed paths while traversing a component hierarchy.
- [`GSComponent openBezierPath`](/Core/GlyphsCore/GSComponent/openBezierPath) — The transformed open paths of the component layer and its nested components.
- [`GSComponent openBezierPath:`](/Core/GlyphsCore/GSComponent/openBezierPath:) — Collects the transformed open paths while traversing a component hierarchy.

### Decomposition

- [`GSComponent decompose`](/Core/GlyphsCore/GSComponent/decompose) — Replaces the component in its containing layer with transformed copies of the base-glyph layer contents.
- [`GSComponent decomposedPathsRemovingOverlap:`](/Core/GlyphsCore/GSComponent/decomposedPathsRemovingOverlap:) — Detached paths produced by flattening the transformed component contents.

### Hangul Composition

- [`GSComponent hangulModelGlyph`](/Core/GlyphsCore/GSComponent/hangulModelGlyph) — The name of the model syllable selected for the component’s Hangul position.
- [`GSComponent isHangulKeyComponent`](/Core/GlyphsCore/GSComponent/isHangulKeyComponent) — Whether the containing glyph is the model syllable selected for the component’s Hangul position.

### Layer API

- [`GSComponent makeFirst`](/Core/GlyphsCore/GSComponent/makeFirst) — Moves the component to the beginning of its containing layer’s shape order.

### Equality

- [`GSComponent isEqualToComponent:`](/Core/GlyphsCore/GSComponent/isEqualToComponent:) — Whether another component has matching placement and selected configuration values.

### Placeholder Representations

- [`GSComponent newMissingBaseGlyphPath`](/Core/GlyphsCore/GSComponent/newMissingBaseGlyphPath) — A new placeholder path for an unresolved base glyph.
- [`GSComponent newEmptyBaseGlyphPath`](/Core/GlyphsCore/GSComponent/newEmptyBaseGlyphPath) — A new placeholder path for a base-glyph hierarchy without paths.
- [`GSComponent newBadReferencePath`](/Core/GlyphsCore/GSComponent/newBadReferencePath) — A new placeholder path for a recursive component reference.

### Instance Methods

- [`GSComponent baseGlyphsHasChanged`](/Core/GlyphsCore/GSComponent/baseGlyphsHasChanged)
- [`GSComponent isSmartComponent:`](/Core/GlyphsCore/GSComponent/isSmartComponent:)
- [`GSComponent makeDisableAlignment`](/Core/GlyphsCore/GSComponent/makeDisableAlignment)
- [`GSComponent makeEnableAlignment`](/Core/GlyphsCore/GSComponent/makeEnableAlignment)
- [`GSComponent makeForceAlignment`](/Core/GlyphsCore/GSComponent/makeForceAlignment)

## Relationships

### Inherits From

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

## See Also

### Shapes

- [`GSShape`](/Core/GlyphsCore/GSShape) — An abstract base class for graphical elements stored in a glyph layer.
- [`GSPath`](/Core/GlyphsCore/GSPath) — A graphical path made of nodes.
- [`GSShapeGroup`](/Core/GlyphsCore/GSShapeGroup) — A shape group combines zero or more shapes into a single shape, forming a shape tree.

