RLib

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.

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.lib.RLib

font

The lib’s parent font.

glyph

The lib’s parent glyph.

layer

The lib’s parent layer.

copyAttributes

changed()

naked()

asDict()

Return the Lib as a dict.

This is a backwards compatibility method.

clear()

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

items()

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'})]

normalizeLibKey(value)

Normalizes lib key.

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

keys()

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

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

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"]

remove(key)

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

This is a backwards compatibility method.

update(otherLib)

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)

normalizeLibValue(value)

Normalizes lib value.

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

values()

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'}]

copyData(source)

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

__contains__(key)

getParent()

setChanged()

setParent(parent)

Last edited on 08/12/2024