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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
|
%global _empty_manifest_terminate_build 0
Name: python-glyphsLib
Version: 6.2.2
Release: 1
Summary: A bridge from Glyphs source files (.glyphs) to UFOs
License: Apache Software License 2.0
URL: https://github.com/googlefonts/glyphsLib
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/00/66/ea8c20168200afbe1f7e2a87ac2bfe413ad2c3ab94f0d362aaa9630aeecc/glyphsLib-6.2.2.tar.gz
BuildArch: noarch
Requires: python3-ufoLib2
Requires: python3-fonttools[ufo,unicode]
Requires: python3-openstep-plist
Requires: python3-skia-pathops
Requires: python3-defcon
Requires: python3-ufonormalizer
%description
This Python 3.7+ library provides a bridge from Glyphs source files (.glyphs) to
UFOs and Designspace files via `defcon <https://github.com/typesupply/defcon/>`__ and `designspaceLib <https://github.com/fonttools/fonttools>`__.
The main methods for conversion are found in ``__init__.py``.
Intermediate data can be accessed without actually writing UFOs, if
needed.
Write and return UFOs
^^^^^^^^^^^^^^^^^^^^^
The following code will write UFOs and a Designspace file to disk.
import glyphsLib
master_dir = "master_ufos"
ufos, designspace_path = glyphsLib.build_masters("MyFont.glyphs", master_dir)
If you want to interpolate instances, please use fontmake instead. It uses this library under the hood when dealing with Glyphs files.
Load UFO objects without writing
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
import glyphsLib
ufos = glyphsLib.load_to_ufos("MyFont.glyphs")
Read and write Glyphs data as Python objects
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
from glyphsLib import GSFont
font = GSFont(glyphs_file)
font.save(glyphs_file)
The ``glyphsLib.classes`` module aims to provide an interface similar to
Glyphs.app's `Python Scripting API <https://docu.glyphsapp.com>`__.
Note that currently not all the classes and methods may be fully
implemented. We try to keep up to date, but if you find something that
is missing or does not work as expected, please open a issue.
and what is not supported yet.
Go back and forth between UFOs and Glyphs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1. You can use the ``ufo2glyphs`` and ``glyphs2ufo`` command line scripts to
round-trip your source files. By default, the scripts try to preserve as
much metadata as possible.
# Generate master UFOs and Designspace file
glyphs2ufo Example.glyphs
# Go back
ufo2glyphs Example.designspace
# You can also combine single UFOs into a Glyphs source file.
ufo2glyphs Example-Regular.ufo Example-Bold.ufo
2. Without a designspace file, using for example the
`Inria fonts by Black[Foundry] <https://github.com/BlackFoundry/InriaFonts/tree/master/masters/INRIA-SANS>`__:
import glob
from defcon import Font
from glyphsLib import to_glyphs
ufos = [Font(path) for path in glob.glob("*Italic.ufo")]
# Sort the UFOs because glyphsLib will create masters in the same order
ufos = sorted(ufos, key=lambda ufo: ufo.info.openTypeOS2WeightClass)
font = to_glyphs(ufos)
font.save("InriaSansItalic.glyphs")
`Here is the resulting glyphs file <https://gist.githubusercontent.com/belluzj/cc3d43bf9b1cf22fde7fd4d2b97fdac4/raw/3222a2bfcf6554aa56a21b80f8fba82f1c5d7444/InriaSansItalic.glyphs>`__
3. With a designspace, using
`Spectral from Production Type <https://github.com/productiontype/Spectral/tree/master/sources>`__:
import glob
from fontTools.designspaceLib import DesignSpaceDocument
from glyphsLib import to_glyphs
doc = DesignSpaceDocument()
doc.read("spectral-build-roman.designspace")
font = to_glyphs(doc)
font.save("SpectralRoman.glyphs")
`Here is the resulting glyphs file <https://gist.githubusercontent.com/belluzj/cc3d43bf9b1cf22fde7fd4d2b97fdac4/raw/3222a2bfcf6554aa56a21b80f8fba82f1c5d7444/SpectralRoman.glyphs>`__
4. In both programmatic cases, if you intend to go back to UFOs after modifying
the file with Glyphs, you should use the ``minimize_ufo_diffs`` parameter to
minimize the amount of diffs that will show up in git after the back and
forth. To do so, the glyphsLib will add some bookkeeping values in various
``userData`` fields. For example, it will try to remember which GSClass came
from groups.plist or from the feature file.
The same option exists for people who want to do Glyphs->UFOs->Glyphs:
``minimize_glyphs_diffs``, which will add some bookkeeping data in UFO ``lib``.
For example, it will keep the same UUIDs for Glyphs layers, and so will need
to store those layer UUIDs in the UFOs.
import glob
import os
from fontTools.designspaceLib import DesignSpaceDocument
from glyphsLib import to_glyphs, to_designspace, GSFont
doc = DesignSpaceDocument()
doc.read("spectral-build-roman.designspace")
font = to_glyphs(doc, minimize_ufo_diffs=True)
doc2 = to_designspace(font, propagate_anchors=False)
# UFOs are in memory only, attached to the doc via `sources`
# Writing doc2 over the original doc should generate very few git diffs (ideally none)
doc2.write(doc.path)
for source in doc2.sources:
path = os.path.join(os.path.dirname(doc.path), source.filename)
# You will want to use ufoNormalizer after
source.font.save(path)
font = GSFont("SpectralRoman.glyphs")
doc = to_designspace(font, minimize_glyphs_diffs=True, propagate_anchors=False)
font2 = to_glyphs(doc)
# Writing font2 over font should generate very few git diffs (ideally none):
font2.save(font.filepath)
In practice there are always a few diffs on things that don't really make a
difference, like optional things being added/removed or whitespace changes or
things getting reordered...
Make a release
^^^^^^^^^^^^^^
Use ``git tag -a`` to make a new annotated tag, or ``git tag -s`` for a GPG-signed
annotated tag, if you prefer.
Name the new tag with with a leading ‘v’ followed by three ``MAJOR.MINOR.PATCH``
digits, like in semantic versioning. Look at the existing tags for examples.
In the tag message write some short release notes describing the changes since the
previous tag.
Finally, push the tag to the remote repository (e.g. assuming your upstream is
called ``origin``):
$ git push origin v0.4.3
This will trigger the CI to build the distribution packages and upload them to
the Python Package Index automatically, if all the tests pass successfully.
%package -n python3-glyphsLib
Summary: A bridge from Glyphs source files (.glyphs) to UFOs
Provides: python-glyphsLib
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-glyphsLib
This Python 3.7+ library provides a bridge from Glyphs source files (.glyphs) to
UFOs and Designspace files via `defcon <https://github.com/typesupply/defcon/>`__ and `designspaceLib <https://github.com/fonttools/fonttools>`__.
The main methods for conversion are found in ``__init__.py``.
Intermediate data can be accessed without actually writing UFOs, if
needed.
Write and return UFOs
^^^^^^^^^^^^^^^^^^^^^
The following code will write UFOs and a Designspace file to disk.
import glyphsLib
master_dir = "master_ufos"
ufos, designspace_path = glyphsLib.build_masters("MyFont.glyphs", master_dir)
If you want to interpolate instances, please use fontmake instead. It uses this library under the hood when dealing with Glyphs files.
Load UFO objects without writing
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
import glyphsLib
ufos = glyphsLib.load_to_ufos("MyFont.glyphs")
Read and write Glyphs data as Python objects
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
from glyphsLib import GSFont
font = GSFont(glyphs_file)
font.save(glyphs_file)
The ``glyphsLib.classes`` module aims to provide an interface similar to
Glyphs.app's `Python Scripting API <https://docu.glyphsapp.com>`__.
Note that currently not all the classes and methods may be fully
implemented. We try to keep up to date, but if you find something that
is missing or does not work as expected, please open a issue.
and what is not supported yet.
Go back and forth between UFOs and Glyphs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1. You can use the ``ufo2glyphs`` and ``glyphs2ufo`` command line scripts to
round-trip your source files. By default, the scripts try to preserve as
much metadata as possible.
# Generate master UFOs and Designspace file
glyphs2ufo Example.glyphs
# Go back
ufo2glyphs Example.designspace
# You can also combine single UFOs into a Glyphs source file.
ufo2glyphs Example-Regular.ufo Example-Bold.ufo
2. Without a designspace file, using for example the
`Inria fonts by Black[Foundry] <https://github.com/BlackFoundry/InriaFonts/tree/master/masters/INRIA-SANS>`__:
import glob
from defcon import Font
from glyphsLib import to_glyphs
ufos = [Font(path) for path in glob.glob("*Italic.ufo")]
# Sort the UFOs because glyphsLib will create masters in the same order
ufos = sorted(ufos, key=lambda ufo: ufo.info.openTypeOS2WeightClass)
font = to_glyphs(ufos)
font.save("InriaSansItalic.glyphs")
`Here is the resulting glyphs file <https://gist.githubusercontent.com/belluzj/cc3d43bf9b1cf22fde7fd4d2b97fdac4/raw/3222a2bfcf6554aa56a21b80f8fba82f1c5d7444/InriaSansItalic.glyphs>`__
3. With a designspace, using
`Spectral from Production Type <https://github.com/productiontype/Spectral/tree/master/sources>`__:
import glob
from fontTools.designspaceLib import DesignSpaceDocument
from glyphsLib import to_glyphs
doc = DesignSpaceDocument()
doc.read("spectral-build-roman.designspace")
font = to_glyphs(doc)
font.save("SpectralRoman.glyphs")
`Here is the resulting glyphs file <https://gist.githubusercontent.com/belluzj/cc3d43bf9b1cf22fde7fd4d2b97fdac4/raw/3222a2bfcf6554aa56a21b80f8fba82f1c5d7444/SpectralRoman.glyphs>`__
4. In both programmatic cases, if you intend to go back to UFOs after modifying
the file with Glyphs, you should use the ``minimize_ufo_diffs`` parameter to
minimize the amount of diffs that will show up in git after the back and
forth. To do so, the glyphsLib will add some bookkeeping values in various
``userData`` fields. For example, it will try to remember which GSClass came
from groups.plist or from the feature file.
The same option exists for people who want to do Glyphs->UFOs->Glyphs:
``minimize_glyphs_diffs``, which will add some bookkeeping data in UFO ``lib``.
For example, it will keep the same UUIDs for Glyphs layers, and so will need
to store those layer UUIDs in the UFOs.
import glob
import os
from fontTools.designspaceLib import DesignSpaceDocument
from glyphsLib import to_glyphs, to_designspace, GSFont
doc = DesignSpaceDocument()
doc.read("spectral-build-roman.designspace")
font = to_glyphs(doc, minimize_ufo_diffs=True)
doc2 = to_designspace(font, propagate_anchors=False)
# UFOs are in memory only, attached to the doc via `sources`
# Writing doc2 over the original doc should generate very few git diffs (ideally none)
doc2.write(doc.path)
for source in doc2.sources:
path = os.path.join(os.path.dirname(doc.path), source.filename)
# You will want to use ufoNormalizer after
source.font.save(path)
font = GSFont("SpectralRoman.glyphs")
doc = to_designspace(font, minimize_glyphs_diffs=True, propagate_anchors=False)
font2 = to_glyphs(doc)
# Writing font2 over font should generate very few git diffs (ideally none):
font2.save(font.filepath)
In practice there are always a few diffs on things that don't really make a
difference, like optional things being added/removed or whitespace changes or
things getting reordered...
Make a release
^^^^^^^^^^^^^^
Use ``git tag -a`` to make a new annotated tag, or ``git tag -s`` for a GPG-signed
annotated tag, if you prefer.
Name the new tag with with a leading ‘v’ followed by three ``MAJOR.MINOR.PATCH``
digits, like in semantic versioning. Look at the existing tags for examples.
In the tag message write some short release notes describing the changes since the
previous tag.
Finally, push the tag to the remote repository (e.g. assuming your upstream is
called ``origin``):
$ git push origin v0.4.3
This will trigger the CI to build the distribution packages and upload them to
the Python Package Index automatically, if all the tests pass successfully.
%package help
Summary: Development documents and examples for glyphsLib
Provides: python3-glyphsLib-doc
%description help
This Python 3.7+ library provides a bridge from Glyphs source files (.glyphs) to
UFOs and Designspace files via `defcon <https://github.com/typesupply/defcon/>`__ and `designspaceLib <https://github.com/fonttools/fonttools>`__.
The main methods for conversion are found in ``__init__.py``.
Intermediate data can be accessed without actually writing UFOs, if
needed.
Write and return UFOs
^^^^^^^^^^^^^^^^^^^^^
The following code will write UFOs and a Designspace file to disk.
import glyphsLib
master_dir = "master_ufos"
ufos, designspace_path = glyphsLib.build_masters("MyFont.glyphs", master_dir)
If you want to interpolate instances, please use fontmake instead. It uses this library under the hood when dealing with Glyphs files.
Load UFO objects without writing
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
import glyphsLib
ufos = glyphsLib.load_to_ufos("MyFont.glyphs")
Read and write Glyphs data as Python objects
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
from glyphsLib import GSFont
font = GSFont(glyphs_file)
font.save(glyphs_file)
The ``glyphsLib.classes`` module aims to provide an interface similar to
Glyphs.app's `Python Scripting API <https://docu.glyphsapp.com>`__.
Note that currently not all the classes and methods may be fully
implemented. We try to keep up to date, but if you find something that
is missing or does not work as expected, please open a issue.
and what is not supported yet.
Go back and forth between UFOs and Glyphs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1. You can use the ``ufo2glyphs`` and ``glyphs2ufo`` command line scripts to
round-trip your source files. By default, the scripts try to preserve as
much metadata as possible.
# Generate master UFOs and Designspace file
glyphs2ufo Example.glyphs
# Go back
ufo2glyphs Example.designspace
# You can also combine single UFOs into a Glyphs source file.
ufo2glyphs Example-Regular.ufo Example-Bold.ufo
2. Without a designspace file, using for example the
`Inria fonts by Black[Foundry] <https://github.com/BlackFoundry/InriaFonts/tree/master/masters/INRIA-SANS>`__:
import glob
from defcon import Font
from glyphsLib import to_glyphs
ufos = [Font(path) for path in glob.glob("*Italic.ufo")]
# Sort the UFOs because glyphsLib will create masters in the same order
ufos = sorted(ufos, key=lambda ufo: ufo.info.openTypeOS2WeightClass)
font = to_glyphs(ufos)
font.save("InriaSansItalic.glyphs")
`Here is the resulting glyphs file <https://gist.githubusercontent.com/belluzj/cc3d43bf9b1cf22fde7fd4d2b97fdac4/raw/3222a2bfcf6554aa56a21b80f8fba82f1c5d7444/InriaSansItalic.glyphs>`__
3. With a designspace, using
`Spectral from Production Type <https://github.com/productiontype/Spectral/tree/master/sources>`__:
import glob
from fontTools.designspaceLib import DesignSpaceDocument
from glyphsLib import to_glyphs
doc = DesignSpaceDocument()
doc.read("spectral-build-roman.designspace")
font = to_glyphs(doc)
font.save("SpectralRoman.glyphs")
`Here is the resulting glyphs file <https://gist.githubusercontent.com/belluzj/cc3d43bf9b1cf22fde7fd4d2b97fdac4/raw/3222a2bfcf6554aa56a21b80f8fba82f1c5d7444/SpectralRoman.glyphs>`__
4. In both programmatic cases, if you intend to go back to UFOs after modifying
the file with Glyphs, you should use the ``minimize_ufo_diffs`` parameter to
minimize the amount of diffs that will show up in git after the back and
forth. To do so, the glyphsLib will add some bookkeeping values in various
``userData`` fields. For example, it will try to remember which GSClass came
from groups.plist or from the feature file.
The same option exists for people who want to do Glyphs->UFOs->Glyphs:
``minimize_glyphs_diffs``, which will add some bookkeeping data in UFO ``lib``.
For example, it will keep the same UUIDs for Glyphs layers, and so will need
to store those layer UUIDs in the UFOs.
import glob
import os
from fontTools.designspaceLib import DesignSpaceDocument
from glyphsLib import to_glyphs, to_designspace, GSFont
doc = DesignSpaceDocument()
doc.read("spectral-build-roman.designspace")
font = to_glyphs(doc, minimize_ufo_diffs=True)
doc2 = to_designspace(font, propagate_anchors=False)
# UFOs are in memory only, attached to the doc via `sources`
# Writing doc2 over the original doc should generate very few git diffs (ideally none)
doc2.write(doc.path)
for source in doc2.sources:
path = os.path.join(os.path.dirname(doc.path), source.filename)
# You will want to use ufoNormalizer after
source.font.save(path)
font = GSFont("SpectralRoman.glyphs")
doc = to_designspace(font, minimize_glyphs_diffs=True, propagate_anchors=False)
font2 = to_glyphs(doc)
# Writing font2 over font should generate very few git diffs (ideally none):
font2.save(font.filepath)
In practice there are always a few diffs on things that don't really make a
difference, like optional things being added/removed or whitespace changes or
things getting reordered...
Make a release
^^^^^^^^^^^^^^
Use ``git tag -a`` to make a new annotated tag, or ``git tag -s`` for a GPG-signed
annotated tag, if you prefer.
Name the new tag with with a leading ‘v’ followed by three ``MAJOR.MINOR.PATCH``
digits, like in semantic versioning. Look at the existing tags for examples.
In the tag message write some short release notes describing the changes since the
previous tag.
Finally, push the tag to the remote repository (e.g. assuming your upstream is
called ``origin``):
$ git push origin v0.4.3
This will trigger the CI to build the distribution packages and upload them to
the Python Package Index automatically, if all the tests pass successfully.
%prep
%autosetup -n glyphsLib-6.2.2
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-glyphsLib -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 6.2.2-1
- Package Spec generated
|