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.
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.
undo(undoTitle='')
Capture the current state of the object and create a undo item in a with statement.
Optionally an undoTitle can be provided.
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
normalizeLibKey(value)
Normalizes lib key.
- value must be a
string. - value must be at least one character long.
- Returned value will be an unencoded
unicodestring.
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"]
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'}]