RKerning

class RKerning()

A Kerning object. This object normally created as part of a BaseFont. An orphan Kerning object can be created like this

groups = RKerning()

This object behaves like a Python dictionary. Most of the dictionary functionality comes from BaseDict, look at that object for the required environment implementation details.

Kerning uses :func:normalizers.normalizeKerningKey to normalize the key of the dict, and :func:normalizers.normalizeKerningValue to normalize the the value of the dict.

addObserver(observer, methodName, notification)

Add an observer object. that will receive notification for the given methodName.

asDefcon()

Return the defcon object.

asFontParts()

Return a fontParts object

destroyAllRepresentations(notification=None)

Destroy all representations.

destroyRepresentation(name, **kwargs)

Destroy the stored representation for name and optionally kwargs.

getRepresentation(name, **kwargs)

Get a representation by name.

Optionally arguments could be provided if the representation factory requires arguments.

holdChanges()

Capture changes and bundle them in a single change in a with statement.

performUndo()

Create a undo item and add it the the undo manager.

prepareUndo(undoTitle='')

Save the current state of the object.

releaseHeldChanges()

removeObserver(observer, notification)

Remove an observer object for a notification.

undo(undoTitle='')

Capture the current state of the object and create a undo item in a with statement.

Optionally an undoTitle can be provided.

Inherits from subclass: fontParts.fontshell.kerning.RKerning

font

The Kerning’s parent BaseFont.

copyAttributes

changed()

naked()

asDict(returnIntegers=True)

Return the Kerning as a dict.

This is a backwards compatibility method.

clear()

Removes all information from Kerning, resetting the Kerning to an empty dictionary.

font.kerning.clear()

find(pair, default=None)

Returns the value for the kerning pair - even if the pair only exists implicitly (one or both sides may be members of a kerning group).

pair is a tuple of two string, and the returned values will either be integer/float or None if no pair was found.

font.kerning[("A", "V")]
-25

get(pair, default=None)

Returns the value for the kerning pair. pair is a tuple of two string, and the returned values will either be integer/float or None if no pair was found.

font.kerning[("A", "V")]
-25

It is important to understand that any changes to the returned value will not be reflected in the Kerning object. If one wants to make a change to the value, one should do the following

value = font.kerning[("A", "V")]
value += 10
font.kerning[("A", "V")] = value

interpolate(factor, minKerning, maxKerning, round=True, suppressError=True)

Interpolates all pairs between two BaseKerning objects:

myKerning.interpolate(kerningOne, kerningTwo)

minKerning and maxKerning. The interpolation occurs on a 0 to 1.0 range where minKerning is located at 0 and maxKerning is located at 1.0. The kerning data is replaced by the interpolated kerning.

  • factor is the interpolation value. It may be less than 0 and greater than 1.0. It may be an integer/float, tuple or list. If it is a tuple or list, the first number indicates the x factor and the second number indicates the y factor.
  • round is a bool indicating if the result should be rounded to int. The default behavior is to round interpolated kerning.
  • suppressError is a bool indicating if incompatible data should be ignored or if an error should be raised when such incompatibilities are found. The default behavior is to ignore incompatible data.

items()

Returns a list of tuple of each pair and value. Pairs are a tuple of two string and values are integer/float.

The initial list will be unordered.

font.kerning.items()
[(("A", "V"), -30), (("A", "W"), -10)]

normalizeKerningKey(value)

Normalizes kerning key.

  • value must be a tuple or list.
  • value must contain only two members.
  • value items must be string.
  • value items must be at least one character long.
  • Returned value will be a two member tuple of unencoded unicode strings.

keys()

Returns a list of all the pairs in Kerning. This list will be unordered.

font.kerning.keys()
[("A", "Y"), ("A", "V"), ("A", "W")]

pop(pair, default=None)

Removes the pair from the Kerning and returns the value as an int. If no pair is found, default is returned. pair is a tuple of two string. This must return either

default or a integer/float.

font.kerning.pop(("A", "V"))
-20
font.kerning.pop(("A", "W"))
-10.5

remove(pair)

Removes a pair from the Kerning. pair will be a tuple of two string.

This is a backwards compatibility method.

round(multiple=1)

Rounds the kerning values to increments of multiple, which will be an int.

The default behavior is to round to increments of 1.

scaleBy(factor)

Scales all kerning values by factor. factor will be an integer/float, tuple or list. The first value of the factor will be used to scale the kerning values.

myKerning.scaleBy(2)
myKerning.scaleBy((2,3))

update(otherKerning)

Updates the Kerning based on otherKerning. otherKerning is a dict of kerning information. If a pair from otherKerning is in Kerning, the pair value will be replaced by the value from otherKerning. If a pair from otherKerning is not in the Kerning, it is added to the pairs. If Kerning contains a pair that is not in otherKerning, it is not changed.

font.kerning.update(newKerning)

normalizeKerningValue(value)

Normalizes kerning value.

  • value must be an integer/float.
  • Returned value is the same type as input value.

values()

Returns a list of each pair’s values, the values will be integer/float.

The list will be unordered.

font.kerning.items()
[-20, -15, 5, 3.5]

copyData(source)

Subclasses may override this method. If so, they should call the super.

__contains__(key)

getParent()

setChanged()

add(value)

combine(kerningDicts, overwriteExisting=True)

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

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

getAverage()

getExtremes()

getLeft(glyphName)

getRight(glyphName)

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

importAFM(path, clearExisting=True)

minimize(minimum=10)

occurrenceCount(glyphsToCount)

setParent(parent)

swapNames(swaptable)

Last edited on 29/11/2024