File: groups.rst

package info (click to toggle)
fontparts 0.13.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 1,996 kB
  • sloc: python: 18,700; makefile: 216; javascript: 143
file content (122 lines) | stat: -rw-r--r-- 3,696 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
.. highlight:: python
.. module:: fontParts.base

######
Groups
######

***********
Description
***********

Groups are collections of glyphs. Groups are used for many things, from OpenType features, kerning, or just keeping track of a collection of related glyphs. The name of the group must be at least one character, with no limit to the maximum length for the name, nor any limit on the characters used in a name. With the exception of the kerning groups defined below, glyphs may be in more than one group and they may appear within the same group more than once. Glyphs in the groups are not required to be in the font.

Groups behave like a Python dictionary. Anything you can do with a dictionary in Python, you can do with Groups.

::

    font = CurrentFont()
    for name, members in font.groups.items():
        print(name)
        print(members)

It is important to understand that any changes to the returned group contents will not be reflected in the groups object. This means that the following will not update the font's groups:

::

    group = list(font.groups["myGroup"])
    group.remove("A")

If one wants to make a change to the group contents, one should do the following instead:

::

    group = list(font.groups["myGroup"])
    group.remove("A")
    font.groups["myGroup"] = group

Kerning Groups
==============

Groups may be used as members of kerning pairs in :class:`BaseKerning`. These groups are divided into two types: groups that appear on the first side of a kerning pair and groups that appear on the second side of a kerning pair.

Kerning groups must begin with standard prefixes. The prefix for groups intended for use in the first side of a kerning pair is ``public.kern1.``. The prefix for groups intended for use in the second side of a kerning pair is ``public.kern2.``. One or more characters must follow the prefix.

Kerning groups must strictly adhere to the following rules:

#. Kerning group names must begin with the appropriate prefix.
#. Only kerning groups are allowed to use the kerning group prefixes in their names.
#. Kerning groups are not required to appear in the kerning pairs.
#. Glyphs must not appear in more than one kerning group per side.

These rules come from the `Unified Font Object <http://unifiedfontobject.org/versions/ufo3/groups.plist/>`_, more information on implementation details for application developers can be found there.

********
Overview
********

.. autosummary::
    :nosignatures:

    BaseGroups.copy
    BaseGroups.font
    BaseGroups.__contains__
    BaseGroups.__delitem__
    BaseGroups.__getitem__
    BaseGroups.__iter__
    BaseGroups.__len__
    BaseGroups.__setitem__
    BaseGroups.clear
    BaseGroups.get
    BaseGroups.items
    BaseGroups.keys
    BaseGroups.pop
    BaseGroups.update
    BaseGroups.values
    BaseGroups.findGlyph
    BaseGroups.naked
    BaseGroups.changed

*********
Reference
*********

.. autoclass:: BaseGroups

Copy
====

.. automethod:: BaseGroups.copy

Parents
=======

* :attr:`~BaseGroups.font` The groups' parent :class:`BaseFont`.

Dictionary
==========

.. automethod:: BaseGroups.__contains__
.. automethod:: BaseGroups.__delitem__
.. automethod:: BaseGroups.__getitem__
.. automethod:: BaseGroups.__iter__
.. automethod:: BaseGroups.__len__
.. automethod:: BaseGroups.__setitem__
.. automethod:: BaseGroups.clear
.. automethod:: BaseGroups.get
.. automethod:: BaseGroups.items
.. automethod:: BaseGroups.keys
.. automethod:: BaseGroups.pop
.. automethod:: BaseGroups.update
.. automethod:: BaseGroups.values

Queries
=======

.. automethod:: BaseGroups.findGlyph

Environment
===========

.. automethod:: BaseGroups.naked
.. automethod:: BaseGroups.changed