Inherits from NSObject
Conforms to GSContainerProtocol
NSCoding
NSCopying

Overview

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

Font Methods

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

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];”

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.

addGlyphs:

Adds the Glyphs object to the font.

- (void)addGlyphs:(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:(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.

customPropertyForKey:

Returns the custom property with Name

- (GSCustomParameter *)customPropertyForKey:(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

Disables redrawing and updates.

- (void)disableUpdateInterface

Discussion

Warning: Always call enableUpdateInterface afterwards

enableUpdateInterface

Reanables redrawing and updates.

- (void)enableUpdateInterface

Discussion

This only has an effect if disableUpdateInterface was called before

featureAtIndex:

The feature at index

- (id)featureAtIndex:(NSUInteger)theIndex

Parameters

theIndex

The index of the feature

Return Value

The feature located at theIndex.

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 *)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 *)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 *)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

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

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.

insertInstance:atIndex:

Inserts the instance at Index

- (void)insertInstance:(GSInstance *)Instance atIndex:(NSUInteger)index

Parameters

Instance

The instance to insert.

index

The index at what to insert the instance.

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

instanceAtIndex:

The Instance at index

- (GSInstance *)instanceAtIndex:(NSUInteger)index

Parameters

index

The index of the instance.

Return Value

The Instance located at index.

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 *)GlyphNames

Parameters

GlyphNames

A array of glyph names

Return Value

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

kerningForFontMasterID:LeftKey:RightKey:

Returns a kerning value

- (CGFloat)kerningForFontMasterID:(id)FontMasterID LeftKey:(id)LeftKey RightKey:(id)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)

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

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.

removeInstanceAtIndex:

Removes the Instance at Index.

- (void)removeInstanceAtIndex:(NSUInteger)index

Parameters

index

The of the Instance to be removed.

removeKerningForFontMasterID:LeftKey:RightKey:

removes a kerning value

- (void)removeKerningForFontMasterID:(id)FontMasterID LeftKey:(id)LeftKey RightKey:(id)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

removeUserObjectForKey:

Removed the object with this key.

- (void)removeUserObjectForKey:(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:

adds a kerning value

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

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

setUserObject:forKey:

Adds something to the fonts userData.

- (void)setUserObject:(id)value forKey:(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

updateMetrics

Recalculate the LSB and RSB for all glyph

- (void)updateMetrics

Discussion

This will not apply the metrics keys.