RKerning

../_images/RKerning.gif

Usage

# robofab manual
# Kerning object
# usage examples

f = CurrentFont()
print f.kerning

# getting a value from the kerning dictionary
print f.kerning[('V', 'A')]
print f.kerning[('T', 'X')]
print f.kerning.keys()
< RKerning for Mailer-Regular >
 -123
 None
 [('X', 'emdash'),
    ('K', 'v'),
    ('two', 'perthousand'),
    ('guilsinglleft', 'a'),
    ... etc.]

Description

RKerning is a dictionary of kerning values. RFont makes a RKerning object when it is created and makes available as aFont.kerning attribute. The keys are tuples of the glyphs listed by their names: ('T', 'e'), ('V', 'A') etc. None is returned if the pair does not exist, rather than raising an IndexError. The parent of a kerning object is usually a Font.

Methods

add(value)

Add value to all kerning pairs.

asDict()

Return the object as a plain dictionary.

clear()

Clear all the kerning (why would you want to do that?).

combine(kerningDicts, overwriteExisting=True)

Combine two or more kerning dictionaries. Overwrite exsisting duplicate pairs if overwriteExisting=True.

eliminate(leftGlyphsToEliminate=None, rightGlyphsToEliminate=None, analyzeOnly=False)

Eliminate pairs containing a left glyph that is in the leftGlyphsToEliminate list or a right glyph that is in the rightGlyphsToELiminate list. sideGlyphsToEliminate can be a string: 'a' or list: ['a', 'b']. analyzeOnly will not remove pairs. it will return a count of all pairs that would be removed.

explodeClasses(leftClassDict=None, rightClassDict=None, analyzeOnly=False)

Turn class kerns into real kerning pairs. Classes should be defined in dicts: {'O':['C', 'G', 'Q'], 'H':['B', 'D', 'E', 'F', 'I']}. analyzeOnly will not remove pairs. it will return a count of all pairs that would be added.

get(aPair)

Get a value. Return None if the pair does not exist.

getAverage()

Return average of all kerning pairs.

getExtremes()

Return the lowest and highest kerning values.

getLeft(glyphName)

Return a list of kerns with glyphName as left character.

getRight(glyphName)

Return a list of kerns with glyphName as right character.

has_key(pair)

Returns True if it has the pair.

implodeClasses(leftClassDict=None, rightClassDict=None, analyzeOnly=False)

Condense the number of kerning pairs by applying classes. This will eliminate all pairs containg the classed glyphs leaving pairs that contain the key glyphs behind. analyzeOnly will not remove pairs. It will return a count of all pairs that would be removed.

importAFM(path, clearExisting=True)

Import kerning pairs from an AFM file. clearExisting=True will clear all exising kerning.

interpolate(sourceDictOne, sourceDictTwo, value, clearExisting=True)

Interpolate the kerning between sourceDictOne and sourceDictTwo. clearExisting will clear existing kerning first.

items()

Return a list of (pair, value) tuples.

keys()

Returns a lust of available pairs.

minimize(minimum=10)

Eliminate pairs with value less than minimum.

occurrenceCount(glyphsToCount)

Return a dict with glyphs as keys and the number of occurances of that glyph in the kerning pairs as the value glyphsToCount can be a string: 'a' or list: ['a', 'b']

remove(pair)

Remove a kerning pair.

round(multiple=10)

Round the kerning pair values to increments of multiple.

scale(value)

Scale all kernng pairs by value.

swapNames(swapTable)

Change glyph names in all kerning pairs based on swapTable:

swapTable = {'BeforeName':'AfterName', }
update(kerningDict)

Replace kerning data with the data in the given kerningDict.

values()

Return a list of kerning values.

links