# `GSGlyph saveToFile:format:context:error:`

*Instance Method*

Writes the glyph in Glyphs source syntax to an open file.

## Declaration

```swift
func save(to file: UnsafeMutablePointer<FILE>, format formatVersion: GSFormatVersion, context: GSSaveContext) throws
```

```objc
- (BOOL) saveToFile:(FILE *) file format:(GSFormatVersion) formatVersion context:(GSSaveContext *) context error:(NSError **) error;
```

```python
saveToFile_format_context_error_(file: FILE, formatVersion: GSFormatVersion, context: GSSaveContext) -> tuple[bool, NSError]
```

## Parameters

- `file` — An open writable file positioned where the glyph content is written.
- `formatVersion` — The source format used for the representation.
- `context` — The options and shared state for the save operation.
- `error` — On return, an error that prevented encoding.

## Return Value

Whether the glyph was encoded successfully.

## Discussion

The save context controls optional data such as layers and the last-change timestamp.

## See Also

### Encoding

- [`GSGlyph propertyListValueFormat:error:`](/Core/GlyphsCore/GSGlyph/propertyListValueFormat:error:) — A property-list representation in a Glyphs source format.
- [`GSGlyph propertyListValueFormat:options:error:`](/Core/GlyphsCore/GSGlyph/propertyListValueFormat:options:error:) — A property-list representation using specified save options.

