Inherits from NSObject
Conforms to GSContainerProtocol
NSCoding
NSCopying

Overview

@brief: This class defines the font object.

Font info properties, that have a user interface, have proper accessors, eveything else is stored in the custom parameters

Tasks

Other Methods

Font Info

Creating and Initializing a GSFont object

Glyphs

Custom Parameters

Masters

Instances

Kerning

Features

Classes

FeaturePrefixes

Properties

copyright

copyright

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

customParameters

List of custom parameters

@property (nonatomic, retain) NSMutableArray *customParameters

date

The font date

@property (strong, nonatomic) NSDate *date

designer

designer

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

designerURL

designerURL

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

disablesAutomaticAlignment

Disables automatic alignment of components

@property (nonatomic) BOOL disablesAutomaticAlignment

disablesNiceNames

disablesNiceNames

@property BOOL disablesNiceNames

Discussion

This is to prevent the automatic glyph name substitution. Set it to YES before you do big changes. Make sure to disable it after you are finished.

featurePrefixes

An array of GSClass objects that contain additional lookups

@property (nonatomic, strong) NSMutableArray *featurePrefixes

fontDict

Returns the content of the font object to store it in pList.

@property (unsafe_unretained, readonly, nonatomic) NSMutableDictionary *fontDict

Discussion

This is used to store the data in the .glyphs file.

gridMain

The size of the grid.

@property (nonatomic, assign) NSUInteger gridMain

Discussion

If it is 0, all values are stored as floats. 1 and above will ALWAYS round the coordinates.

See Also

gridSubDivision

The subdivision of the grid.

@property (nonatomic, assign) NSUInteger gridSubDivision

Discussion

Divides the grid.

See Also

keepAlternatesTogether

Keeps alternated glyphs next to the base glyph

@property (nonatomic) BOOL keepAlternatesTogether

kerning

the Kerning of the Font

@property (strong, nonatomic) MGOrderedDictionary *kerning

Discussion

1) A Dict for each FontMaster (FontMaster id as key) 2) The Dict contains an entry for each glyph (the glyphID or GroupName (@MMK_L_XXX) is used as key) 3) These entries hold the values: glyphID or GroupName (@MMK_R_XXX) as key, kerning as value.

manufacturer

manufacturer

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

manufacturerURL

manufacturerURL

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

tempData

a mutable dictionary that stores data. It will not be written to disk.

@property (nonatomic, strong, nullable) NSMutableDictionary *tempData

tempOTFFont

The path to the temp font

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

Discussion

This font contains no outlines and no kerning but the full GSUB table. It is used for the feature preview in edit view.

undoManager

The undoManager of the document

@property (nonatomic, readonly, nullable) NSUndoManager *undoManager

Discussion

This is only used for font info and for adding/removing glyphs. Each glyph has it’s own undoManager.

unitsPerEm

unitsPerEm (UPM).

@property (assign, nonatomic) NSUInteger unitsPerEm

userData

Place for plugins to store custom data.

@property (strong, nonatomic, nullable) NSMutableDictionary *userData

Discussion

Here it is possible to store something. Please use a unique key. The objects should be able to serialize to a plist. If they are not, they should return all infos to store in description (as String).

versionMajor

versionMajor

@property (assign, nonatomic) NSUInteger versionMajor

versionMinor

versionMinor

@property (assign, nonatomic) NSUInteger versionMinor

verticalKerning

the vertical Kerning of the Font

@property (strong, nonatomic) MGOrderedDictionary *verticalKerning

Discussion

1) A Dict for each FontMaster (FontMaster id as key) 2) The Dict contains an entry for each glyph (the glyphID or GroupName (@MMK_L_XXX) is used as key) 3) These entries hold the values: glyphID or GroupName (@MMK_R_XXX) as key, kerning as value.

Instance Methods

addClass:

Adds a class to the font

- (void)addClass:(GSClass *)theClass

Parameters

theClass

the Class

addClassFromCode:

Convient method to add a class with the Text

- (void)addClassFromCode:(NSString *)Text

Parameters

Text

the class in FDK syntax, e.g. “@myClass = [A B];”

addCustomParameter:

adds a parameter to the list font

- (void)addCustomParameter:(GSCustomParameter *)Property

Parameters

Property

a GSCustomParameter

addFeaturePrefix:

Adds the Prefix to the font

- (void)addFeaturePrefix:(GSClass *)thePrefix

Parameters

thePrefix

the prefix

addFontMaster:

Adds the fontMaster to the font

- (void)addFontMaster:(GSFontMaster *)fontMaster

Parameters

fontMaster

The master to add.

addGlyph:

Adds the Glyph object to the font.

- (void)addGlyph:(GSGlyph *)Glyph

Parameters

Glyph

A GSGlyph object.

addGlyphsFromArray:

Adds the Glyphs object to the font.

- (void)addGlyphsFromArray:(NSArray *)Glyphs

Parameters

Glyphs

A NSArray of GSGlyph objects.

addInstance:

Adds the Instance to the font

- (void)addInstance:(GSInstance *)Instance

Parameters

Instance

The Instance to add to the font.

charStringFromDisplayString:

Converts a string that contains slash seperated glyph names in a regular unicode string

- (NSString *)charStringFromDisplayString:(NSString *)String

Parameters

String

A String containing slash seperated glyph names

Return Value

A UTF-16 string. For it will assigne a cached PUA codes for unencoded glyphs

characterForGlyph:

Returns a UTF32Char for the glyph.

- (UTF32Char)characterForGlyph:(GSGlyph *)Glyph

Parameters

Glyph

a GSGlyph object

Return Value

a UTF32Char

Discussion

It uses the unicode to find the char value. For unencoded glyphs it returns a cached PUA value.

classForTag:

Returns the class with the name.

- (GSClass *)classForTag:(NSString *)Tag

Parameters

Tag

The class name.

compileTempFontError:

Recalculates the temp font.

- (BOOL)compileTempFontError:(out NSError *__autoreleasing *)Error

Parameters

Error

if there is a problem, it returns an NSError object (by reference) that contains details.

Return Value

YES if successfull, NO, if not.

Discussion

Call it, if you changed something like the glyph set or the features and need to make sure the temp font is up to date. This is usually done automatically.

compressKerning

Compresses the kerning

- (void)compressKerning

Discussion

if a GSGlyph has a Kerning Group and Direct Kerning, the Kerning is changed to Class Kerning.

countOfCustomParameters

The number of parameters in the font

- (NSUInteger)countOfCustomParameters

countOfFeaturePrefixes

the count of the Prefixes in the font

- (NSUInteger)countOfFeaturePrefixes

countOfFeatures

The count of the features

- (NSUInteger)countOfFeatures

Return Value

The number of features in the Font.

countOfFontMasters

The count of masters in the font.

- (NSInteger)countOfFontMasters

Return Value

The number of layers currently in the font.

countOfGlyphs

The count of glyphs in the font

- (NSUInteger)countOfGlyphs

countOfInstances

The count of the Instances

- (NSUInteger)countOfInstances

Return Value

The number of Instances currently in the Font.

customBoolValueForKey:

A convenient method to check if a custom parameter is set and has a positiv setting

- (BOOL)customBoolValueForKey:(NSString *)key

Parameters

key

the name of the custom parameter

Return Value

YES/NO

customParameterForKey:

Returns the custom property with Name

- (GSCustomParameter *)customParameterForKey:(NSString *)key

Parameters

key

The name of the parameter

Return Value

The parameter object

Discussion

This will always return the first entry with this name. If there are multiple parameters with the same name, parse the customParameters array directly.

customValueForKey:

This returns the value of the parameter object with Name

- (id)customValueForKey:(NSString *)key

Parameters

key

The name of the parameter

Return Value

The value of the parameter object object

Discussion

This will always return the first entry with this name. If there are multiple parameters with the same name, parse the customParameters array directly.

disableUpdateInterface

Delayes redrawing and updates.

- (void)disableUpdateInterface

Discussion

Will record the changes and update once in enableUpdateInterface. If you don’t need updates, use stopUpdateInterface

Warning: Always call enableUpdateInterface afterwards

elementDidChange:

This is called be child objects to tell the containing class that it has changed

- (void)elementDidChange:(id)element

Parameters

element

the calling object

enableUpdateInterface

Reanables redrawing and updates.

- (void)enableUpdateInterface

Discussion

This only has an effect if disableUpdateInterface was called before

featureForTag:

Returns the feature with the name or tag.

- (GSFeature *)featureForTag:(NSString *)Tag

Parameters

Tag

The feature tag (like “smcp”)

featurePrefixForTag:

Returns the Prefix with the name.

- (GSClass *)featurePrefixForTag:(NSString *)Tag

Parameters

Tag

The prefix name.

filterGlyphs:

Returns all glyph names that are present and set to export

- (NSArray *_Nullable)filterGlyphs:(NSArray *)GlyphNames

Parameters

GlyphNames

A array of glyph names

Return Value

A list of all glyphs that are in the font

filterKeepGlyphs:

Returns all glyph names that are present and set to export

- (NSArray *_Nullable)filterKeepGlyphs:(NSArray *)GlyphNames

Parameters

GlyphNames

A array of glyph names

Return Value

A list of exporting glyphs

fontMasterAtIndex:

The master located at index

- (GSFontMaster *)fontMasterAtIndex:(NSInteger)Index

Parameters

Index

An index

Return Value

A GSFontMaster instance or nil if index is out of bounds

fontMasterForId:

Returns the fontmaster with this id

- (GSFontMaster *)fontMasterForId:(NSString *)Id

Parameters

Id

The ID of the font master. This is supposed to be a Unique id

Return Value

A GSFontMaster instance.

generateInstance:error:

Generates an instance

- (GSFont *_Nullable)generateInstance:(GSInstance *)Instance error:(NSError *__autoreleasing *)Error

Parameters

Instance

The Instance to use for interpolation.

Error

if there is a problem, it returns an NSError object (by reference) that contains details.

Return Value

The interpolated font, or nil if something went wrong.

Discussion

It returns a new GSFont object with one master interpolated all glyphs/layers according to the settings in Instance.

glyphAtIndex:

The glyph object located at index.

- (GSGlyph *)glyphAtIndex:(NSInteger)Index

Parameters

Index

An index within the bounds of the the glyphs array.

Return Value

a GSGlyph object.

Discussion

Checks for valid index and returns nil if index is to high.

glyphForCharacter:

Returns the glyph with the chars unicode.

- (GSGlyph *)glyphForCharacter:(UTF32Char)Char

Parameters

Char

A (unicode) char.

Return Value

a GSGlyph object

glyphForId:

Returns the GSGlyph with this ID.

- (GSGlyph *)glyphForId:(NSString *)Id

Parameters

Id

the ID of the glyph.

Return Value

a GSGlyph object.

Discussion

Warning: This is a bit slow.

glyphForName:

Returns the GSGlyph with this name.

- (GSGlyph *)glyphForName:(NSString *)Name

Parameters

Name

the name of the glyph.

Return Value

a GSGlyph object.

Discussion

Warning: This is a bit slow.

glyphForUnicode:

Returns the GSGlyph with this this Unicode.

- (GSGlyph *)glyphForUnicode:(NSString *)Unicode

Parameters

Unicode

the unicode as a hex string (‘004C’)

Return Value

a GSGlyph object or nil if not found.

See Also

glyphForUnicodes:

Returns the GSGlyph with this this Unicode.

- (GSGlyph *)glyphForUnicodes:(NSOrderedSet *)unicodes

Parameters

unicodes

a list of unicodes as hex strings (‘004C’)

Return Value

a GSGlyph object or nil if not found.

See Also

glyphNames

A list of glyph names

- (NSArray *)glyphNames

Return Value

A list of glyph names

glyphNamesForWildcard:error:

A list of glyph names matching query

- (NSArray *)glyphNamesForWildcard:(NSString *)query error:(NSError *__autoreleasing *)error

Parameters

query

This can be a name containing wildcards (“a.*”) or a query (“script=arabic”)

error

if something goes wrong, it contains an error on return

Return Value

a list of glyph names or nil

gridLength

The effective grid width.

- (CGFloat)gridLength

Return Value

The effective size of the grid

Discussion

Calculated by Grid / Subdivision

hasGlyphs:

Returns a Boolean value if the font contains the glyphs

- (BOOL)hasGlyphs:(NSArray *)GlyphNames

Parameters

GlyphNames

A array of glyph names

Return Value

YES if all glyphs are in the font.

indexOfGlyph:

Returns the index of the glyph.

- (NSInteger)indexOfGlyph:(GSGlyph *)Glyph

Parameters

Glyph

The Glyph you are looking for

Return Value

The Index of the glyph or NSNotFound if not found

initWithFontDict:

initializes a font with a dictionary loaded from a pList.

- (instancetype)initWithFontDict:(NSDictionary *)fontDict

Parameters

fontDict

A dictionary

initWithURL:error:

Initializes a font with the contents of the location specified by a given URL.

- (instancetype)initWithURL:(NSURL *)fileURL error:(NSError **)outError

Parameters

fileURL

the location of the file

outError

If there is a error it contains an NSError object

Return Value

the GSFont object or nil

insertFontMaster:atIndex:

Inserts the FontMaster at Index

- (void)insertFontMaster:(GSFontMaster *)FontMaster atIndex:(NSUInteger)theIndex

Parameters

FontMaster

The master to add to the font

theIndex

The index to insert FontMaster.

insertObject:inClassesAtIndex:

Insert the Class at theIndex in the font

- (void)insertObject:(GSClass *)theClass inClassesAtIndex:(NSUInteger)theIndex

Parameters

theClass

the class

theIndex

the index

insertObject:inFeaturePrefixesAtIndex:

Insert the Prefix at theIndex in the font

- (void)insertObject:(id)thePrefix inFeaturePrefixesAtIndex:(unsigned)theIndex

Parameters

thePrefix

the prefix

theIndex

the index

insertObject:inInstancesAtIndex:

Inserts the instance at Index

- (void)insertObject:(GSInstance *)Instance inInstancesAtIndex:(NSUInteger)index

Parameters

Instance

The instance to insert.

index

The index at what to insert the instance.

isUpdateInterfaceEnabled

Check if the updating is enabled

- (BOOL)isUpdateInterfaceEnabled

Return Value

NO if disableUpdateInterface was called

keepsGlyphs:

Tests if all the glyphs are present and set to export

- (BOOL)keepsGlyphs:(NSArray<NSString*> *)GlyphNames

Parameters

GlyphNames

A array of glyph names

Return Value

YES if all glyphs will end up in a exported font.

kerningForFontMasterID:LeftKey:RightKey:direction:

Returns a kerning value

- (CGFloat)kerningForFontMasterID:(id)FontMasterID LeftKey:(id)LeftKey RightKey:(id)RightKey direction:(GSWritingDirection)direction

Parameters

FontMasterID

The Master id

LeftKey

either a glyph id or a glyph group (@MM_L_XXX)

RightKey

either a glyph id or a glyph group (@MM_R_XXX)

Return Value

the kerning value

newGlyphWithName:changeName:

Adds a new glyph with this glyphName to the font

- (GSGlyph *)newGlyphWithName:(NSString *)glyphName changeName:(BOOL)changeName

Parameters

glyphName

The new glyph name

changeName

If changeName is yes, the glyphName will be converted to nice-name, otherwise not.

Return Value

The new glyph.

objectInCustomParametersAtIndex:

The parameter at theIndex

- (id)objectInCustomParametersAtIndex:(NSUInteger)index

Parameters

index

The index

Return Value

The GSCustomParameter or nil of index is out of range

objectInFeaturesAtIndex:

The feature at index

- (GSFeature *)objectInFeaturesAtIndex:(NSUInteger)idx

Parameters

idx

The index of the feature

Return Value

The feature located at theIndex.

objectInInstancesAtIndex:

The Instance at index

- (GSInstance *)objectInInstancesAtIndex:(NSUInteger)index

Parameters

index

The index of the instance.

Return Value

The Instance located at index.

panose

The panose value for the font

- (NSMutableArray *)panose

removeClass:

Removes the class from the font

- (void)removeClass:(GSClass *)theClass

Parameters

theClass

the class

removeFeaturePrefix:

Remove the Prefix at theIndex from the font

- (void)removeFeaturePrefix:(GSClass *)thePrefix

Parameters

thePrefix

the prefix

removeFontMaster:

Removes the fontMaster from the font

- (void)removeFontMaster:(GSFontMaster *)fontMaster

Parameters

fontMaster

The master to remove.

removeFontMasterAtIndex:

Removes the fontmaster with this id

- (void)removeFontMasterAtIndex:(NSInteger)Index

Parameters

Index

The index of the FontMaster to remove.

removeGlyph:

Removes the Glyph from the font

- (void)removeGlyph:(GSGlyph *)Glyph

Parameters

Glyph

A GSGlyph to remove from the font.

removeGlyphs:

Removes the Glyphs from the font

- (void)removeGlyphs:(NSArray *)Glyphs

Parameters

Glyphs

A NSArray of GSGlyph to remove from the font.

removeKerningForFontMasterID:LeftKey:RightKey:

removes a kerning value

- (void)removeKerningForFontMasterID:(NSString *)FontMasterID LeftKey:(NSString *)LeftKey RightKey:(NSString *)RightKey

Parameters

FontMasterID

The Master id

LeftKey

either a glyph id or a glyph group (@MM_L_XXX)

RightKey

either a glyph id or a glyph group (@MM_R_XXX)

removeObjectFromClassesAtIndex:

Remove the class at theIndex from the font

- (void)removeObjectFromClassesAtIndex:(NSUInteger)theIndex

Parameters

theIndex

the index

removeObjectFromCustomParametersAtIndex:

Removes the parameter a theIndex

- (void)removeObjectFromCustomParametersAtIndex:(NSUInteger)index

Parameters

index

The index

removeObjectFromCustomParametersForKey:

Removes the parameter with this name from the font

- (void)removeObjectFromCustomParametersForKey:(id)key

Parameters

key

The name of the parameter

Discussion

It will only remove the first parameter with that name

removeObjectFromInstancesAtIndex:

Removes the Instance at Index.

- (void)removeObjectFromInstancesAtIndex:(NSUInteger)index

Parameters

index

The of the Instance to be removed.

removeUserDataForKey:

Removed the object with this key.

- (void)removeUserDataForKey:(NSString *)key

Parameters

key

The to remove

replaceObjectInClassesAtIndex:withObject:

Replaces the the class a theIndex with Class

- (void)replaceObjectInClassesAtIndex:(NSUInteger)theIndex withObject:(GSClass *)theClass

Parameters

theIndex

the index

theClass

the class

resetCache

If you changed the glyphs array yourself, call that method to reset some chances.

- (void)resetCache

saveNameForGlyph:

Calculates a names that is unique for the font

- (NSString *)saveNameForGlyph:(GSGlyph *)Glyph

Parameters

Glyph

The Glyph

Return Value

The glyph name with a .0XX suffix if the name is already in use by another glyph

saveNameForName:

Calculates a names that is unique for the font

- (NSString *)saveNameForName:(NSString *)GlyphName

Parameters

GlyphName

The glyph name

Return Value

The glyph name with a .0XX suffix if the name is already in use by another glyph

scaleBy:

Scale the hole font.

- (void)scaleBy:(CGFloat)Scale

Parameters

Scale

Multiplier for scale the font (glyphs, kerning and metrics)

setCustomParameter:forKey:

Sets the key value pair in the font

- (void)setCustomParameter:(id)value forKey:(NSString *)key

Parameters

value

a value

key

The name of the parameter

Discussion

if a parameter with this name is already present, its value will be updated. Otherwise a new parameter will be added

setKerningForFontMasterID:LeftKey:RightKey:Value:direction:

adds a kerning value

- (void)setKerningForFontMasterID:(id)FontMasterID LeftKey:(id)LeftKey RightKey:(id)RightKey Value:(CGFloat)Value direction:(GSWritingDirection)direction

Parameters

FontMasterID

The Master id

LeftKey

either a glyph id or a glyph group (@MM_L_XXX)

RightKey

either a glyph id or a glyph group (@MM_R_XXX)

Value

the kerning value

setTempData:forKey:

Adds key/value to tempData. Pass nil as value to remove previous set data

- (void)setTempData:(nullable id)value forKey:(nonnull NSString *)key

Parameters

value

and object or nil

key

the key

setUserData:forKey:

Adds something to the fonts userData.

- (void)setUserData:(nullable id)value forKey:(nonnull NSString *)key

Parameters

value

The object should be able to serialize to a plist. If they are not, they should return all infos to store in description (as String).

key

Please use an uniqe key that gives some indecation who put it there (e.g. prefix it with your name or project).

Discussion

This also triggers undo/document dirty state.

sortGlyphs

Is called if the there are changes.

- (void)sortGlyphs

sortKerning

Triggers the soring of kerning

- (void)sortKerning

stopUpdateInterface

Disable redrawing and updates completly.

- (void)stopUpdateInterface

Discussion

Changes will not trigger an update. Only use this calefully and call enableUpdateInterface if you need future updates.

Warning: Always call enableUpdateInterface afterwards

updateMetrics

Recalculate the LSB and RSB for all glyph

- (void)updateMetrics

Discussion

This will not apply the metrics keys.

userDataForKey:

convenience accessor to get to the content of the userData dict

- (id)userDataForKey:(NSString *)key

Parameters

key

the key

Return Value

the data stored with key