RGroups
class RGroups()
A Groups object. This object normally created as part of a
BaseFont
. An orphan Groups object can be created like this
groups = RGroups()
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.
Groups uses :func:normalizers.normalizeGroupKey
to normalize the key of
the dict
, and :func:normalizers.normalizeGroupValue
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.
side1KerningGroups
All groups marked as potential side 1 kerning members.
side1Groups = groups.side1KerningGroups
The value will be a dict
with
string
keys representing group names
and tuple
contaning glyph names.
side2KerningGroups
All groups marked as potential side 1 kerning members.
side2Groups = groups.side2KerningGroups
The value will be a dict
with
string
keys representing group names
and tuple
contaning glyph names.
clear()
Removes all group information from Groups, resetting the Groups to an empty dictionary.
font.groups.clear()
findGlyph(glyphName)
Returns a list
of the group or groups associated with
glyphName.
glyphName will be an string
. If no group is found
to contain glyphName an empty list
will be returned.
font.groups.findGlyph("A")
["A_accented"]
get(groupName, default=None)
Returns the contents of the named group.
groupName is a string
, and the returned values will
either be type-immutable-list
of group contents or None
if no group was found.
font.groups["myGroup"]
("A", "B", "C")
It is important to understand that any changes to the returned group contents will not be reflected in the Groups object. If one wants to make a change to the group contents, one should do the following
group = font.groups["myGroup"]
group.remove("A")
font.groups["myGroup"] = group
normalizeGroupKey(value)
Normalizes group key.
- value must be a
string
. - value must be least one character long.
- Returned value will be an unencoded
unicode
string.
keys()
Returns a list
of all the group names in Groups. This list will be
unordered.
font.groups.keys()
["myGroup4", "myGroup1", "myGroup5"]
remove(groupName)
Removes a group from the Groups. groupName will be
a string
that is the group name to
be removed.
This is a backwards compatibility method.
update(otherGroups)
Updates the Groups based on otherGroups. *otherGroups** is a
dict
of groups information. If a group from otherGroups is in
Groups, the group members will be replaced by the group members from
otherGroups. If a group from otherGroups is not in the Groups,
it is added to the Groups. If Groups contain a group name that is not
in *otherGroups**, it is not changed.
font.groups.update(newGroups)
normalizeGroupValue(value)
Normalizes group value.
- value must be a
list
. - value items must normalize as glyph names with
:func:
normalizeGlyphName
. - Returned value will be a
tuple
of unencodedunicode
strings.
values()
Returns a list
of each named group’s members.
This will be a list of lists, the group members will be a
type-immutable-list
of string
. The initial
list will be unordered.
font.groups.items()
[("A", "B", "C"), ("D", "E", "F")]