class RLib()

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

>>> lib = RLib()

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.

Lib uses :func:normalizers.normalizeLibKey to normalize the key of the dict, and :func:normalizers.normalizeLibValue to normalize the value of the dict.

addObserver(observer, methodName, notification)

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

getRepresentation(name, **kwargs)

Get a representation by name.

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


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


Save the current state of the object.

removeObserver(observer, notification)

Remove an observer object for a notification.

Inherits from subclass: fontParts.fontshell.lib.RLib


The lib’s parent font.


The lib’s parent glyph.




Return the Lib as a dict.

This is a backwards compatibility method.


Removes all keys from Lib, resetting the Lib to an empty dictionary. :

>>> font.lib.clear()

get(key, default=None)

Returns the contents of the named key. key is a string, and the returned values will either be list of key contents or None if no key was found. :

>>> font.lib["public.glyphOrder"]
["A", "B", "C"]

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

>>> lib = font.lib["public.glyphOrder"]
>>> lib.remove("A")
>>> font.lib["public.glyphOrder"] = lib


Returns a list of tuple of each key name and key items. Keys are string and key members are a list of string. The initial list will be unordered.

>>> font.lib.items()
[("public.glyphOrder", ["A", "B", "C"]),
 ("public.postscriptNames", {'be': 'uni0431', 'ze': 'uni0437'})]


Normalizes lib key.

  • value must be a string.
  • value must be at least one character long.
  • Returned value will be an unencoded unicode string.


Returns a list of all the key names in Lib. This list will be unordered.:

>>> font.lib.keys()
["public.glyphOrder", "org.robofab.scripts.SomeData",

pop(key, default=None)

Removes the key from the Lib and returns the list of key members. If no key is found, default is returned. key is a string. This must return either default or a list of items as string.

>>> font.lib.pop("public.glyphOrder")
["A", "B", "C"]


Removes a key from the Lib. key will be a string that is the key to be removed.

This is a backwards compatibility method.


Updates the Lib based on otherLib. *otherLib** is a dict of keys. If a key from otherLib is in Lib the key members will be replaced by the key members from otherLib. If a key from otherLib is not in the Lib, it is added to the Lib. If Lib contain a key name that is not in *otherLib**, it is not changed.

>>> font.lib.update(newLib)


Normalizes lib value.

  • value must not be None.
  • Returned value is the same type as the input value.


Returns a list of each named key’s members. This will be a list of lists, the key members will be a list of string. The initial list will be unordered.

>>> font.lib.items()
[["A", "B", "C"], {'be': 'uni0431', 'ze': 'uni0437'}]


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


changed(*args, **kwargs)

Tell the environment that something has changed in the object. The behavior of this method will vary from environment to environment.

>>> obj.changed()




Last edited on 15/06/2018