fontforge-variable-font 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {fontforge_variable_font-0.1.0 → fontforge_variable_font-0.2.0}/PKG-INFO +27 -22
  2. {fontforge_variable_font-0.1.0 → fontforge_variable_font-0.2.0}/README.md +26 -21
  3. fontforge_variable_font-0.2.0/fontforgeVF/__init__.py +6 -0
  4. fontforge_variable_font-0.2.0/fontforgeVF/__main__.py +55 -0
  5. fontforge_variable_font-0.2.0/fontforgeVF/delete.py +37 -0
  6. fontforge_variable_font-0.2.0/fontforgeVF/design_axes.py +430 -0
  7. fontforge_variable_font-0.2.0/fontforgeVF/export.py +598 -0
  8. fontforge_variable_font-0.2.0/fontforgeVF/instance.py +175 -0
  9. fontforge_variable_font-0.2.0/fontforgeVF/language.py +847 -0
  10. fontforge_variable_font-0.2.0/fontforgeVF/load.py +373 -0
  11. fontforge_variable_font-0.2.0/fontforgeVF/utils.py +323 -0
  12. {fontforge_variable_font-0.1.0 → fontforge_variable_font-0.2.0}/fontforge_variable_font.egg-info/PKG-INFO +27 -22
  13. {fontforge_variable_font-0.1.0 → fontforge_variable_font-0.2.0}/fontforge_variable_font.egg-info/SOURCES.txt +9 -0
  14. {fontforge_variable_font-0.1.0 → fontforge_variable_font-0.2.0}/setup.cfg +2 -2
  15. {fontforge_variable_font-0.1.0 → fontforge_variable_font-0.2.0}/LICENSE +0 -0
  16. {fontforge_variable_font-0.1.0 → fontforge_variable_font-0.2.0}/fontforge_variable_font.egg-info/dependency_links.txt +0 -0
  17. {fontforge_variable_font-0.1.0 → fontforge_variable_font-0.2.0}/fontforge_variable_font.egg-info/entry_points.txt +0 -0
  18. {fontforge_variable_font-0.1.0 → fontforge_variable_font-0.2.0}/fontforge_variable_font.egg-info/requires.txt +0 -0
  19. {fontforge_variable_font-0.1.0 → fontforge_variable_font-0.2.0}/fontforge_variable_font.egg-info/top_level.txt +0 -0
  20. {fontforge_variable_font-0.1.0 → fontforge_variable_font-0.2.0}/pyproject.toml +0 -0
  21. {fontforge_variable_font-0.1.0 → fontforge_variable_font-0.2.0}/test/test_design_axes.py +0 -0
  22. {fontforge_variable_font-0.1.0 → fontforge_variable_font-0.2.0}/test/test_export.py +0 -0
  23. {fontforge_variable_font-0.1.0 → fontforge_variable_font-0.2.0}/test/test_language.py +0 -0
  24. {fontforge_variable_font-0.1.0 → fontforge_variable_font-0.2.0}/test/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fontforge_variable_font
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: A FontForge_plugin to create a variable font
5
5
  Home-page: https://github.com/MihailJP/fontforge-variable-font
6
6
  Author: MihailJP
@@ -35,7 +35,7 @@ Install
35
35
  -------
36
36
 
37
37
  ```shell
38
- pip3 install fontforgeVF
38
+ pip3 install fontforge-variable-font
39
39
  ```
40
40
 
41
41
  ### Make sure Fontforge Python module is usable
@@ -174,19 +174,19 @@ For active font as one of VF masters, sets position in each design
174
174
  axis of VF master. Leave unset for unused axes. Registered axes can
175
175
  use default values which refers font properties.
176
176
 
177
- * Italic: default value is whether ``font.italicangle`` is negative.
177
+ - Italic: default value is whether ``font.italicangle`` is negative.
178
178
  This axis is boolean: you choose the master is for italic or not.
179
179
  Seldom used together with slant axis.
180
- * Optical size: can default to ``font.design_size``. Set in points.
180
+ - Optical size: can default to ``font.design_size``. Set in points.
181
181
  Must be positive.
182
- * Slant: can default to ``font.italicangle``. 0 if upright, negative
182
+ - Slant: can default to ``font.italicangle``. 0 if upright, negative
183
183
  if oblique. This value is hardly positive (left-slanted.)
184
- * Width: can default using ``font.os2_width``. 100 if normal width,
184
+ - Width: can default using ``font.os2_width``. 100 if normal width,
185
185
  less if condensed, greater if expanded. Must be positive.
186
- * Weight: can default to ``font.os2_weight``. 400 if regular weight,
186
+ - Weight: can default to ``font.os2_weight``. 400 if regular weight,
187
187
  700 if bold. The minimum is 1 (hairline thin) and the maximum is
188
188
  999 (extreme bold.)
189
- * Custom axes: there is a room for 3 user-defined axes. No default
189
+ - Custom axes: there is a room for 3 user-defined axes. No default
190
190
  values.
191
191
 
192
192
  > [!TIP]
@@ -254,18 +254,18 @@ default.)
254
254
  Names the design axes. For predefined axes can use default name.
255
255
  Custom axes must be named if used.
256
256
 
257
- * Axis name: name of axis itself.
258
- * Labels: comma-separated list which consists of multiple of 4 of
257
+ - Axis name: name of axis itself.
258
+ - Labels: comma-separated list which consists of multiple of 4 of
259
259
  elements. Leading and trailing spaces will be trimmed. Every
260
260
  group of 4 elements:
261
- * Axis value
262
- * Flags
263
- * 0: Neither
264
- * 1: ``OLDER_SIBLING_FONT_ATTRIBUTE``
265
- * 2: ``ELIDABLE_AXIS_VALUE_NAME``
266
- * 3: Both
267
- * Linked value if exist
268
- * Name
261
+ - Axis value
262
+ - Flags
263
+ - 0: Neither
264
+ - 1: ``OLDER_SIBLING_FONT_ATTRIBUTE``
265
+ - 2: ``ELIDABLE_AXIS_VALUE_NAME``
266
+ - 3: Both
267
+ - Linked value if exist
268
+ - Name
269
269
 
270
270
  ##### Localized names
271
271
 
@@ -278,12 +278,12 @@ Set language code before you use. Choose a language from the list.
278
278
  By default there is a room for 8 languages, but this will be
279
279
  extended if already more than 4 languages are defined.
280
280
 
281
- * Axis name: name of axis itself.
282
- * Labels: comma-separated list which consists of even number of
281
+ - Axis name: name of axis itself.
282
+ - Labels: comma-separated list which consists of even number of
283
283
  elements. Leading and trailing spaces will be trimmed. Every
284
284
  pair of elements:
285
- * Axis value
286
- * Name
285
+ - Axis value
286
+ - Name
287
287
 
288
288
  > [!CAUTION]
289
289
  > Do not select the same language more than once, or undefined behavior will
@@ -441,6 +441,11 @@ fontforgeVF.setVFValue(fontCL, "instances[0].localNames.0x407", "Extramager")
441
441
 
442
442
  # Export TTF
443
443
  fontforgeVF.export(fontCL, 'MyFont.ttf')
444
+ fontforgeVF.export(fontCL, 'MyFont.ttf', 'MyFont-Italic.ttf') # if ``ital`` axis enabled
445
+ fontforgeVF.export(fontCL, 'MyFont.ttf',
446
+ decomposeNestedRefs=True,
447
+ decomposeTransformedRefs=True,
448
+ addAalt=True) # these options default to False
444
449
 
445
450
  # Export Webfont
446
451
  fontforgeVF.export(fontCL, 'MyFont.woff2')
@@ -18,7 +18,7 @@ Install
18
18
  -------
19
19
 
20
20
  ```shell
21
- pip3 install fontforgeVF
21
+ pip3 install fontforge-variable-font
22
22
  ```
23
23
 
24
24
  ### Make sure Fontforge Python module is usable
@@ -157,19 +157,19 @@ For active font as one of VF masters, sets position in each design
157
157
  axis of VF master. Leave unset for unused axes. Registered axes can
158
158
  use default values which refers font properties.
159
159
 
160
- * Italic: default value is whether ``font.italicangle`` is negative.
160
+ - Italic: default value is whether ``font.italicangle`` is negative.
161
161
  This axis is boolean: you choose the master is for italic or not.
162
162
  Seldom used together with slant axis.
163
- * Optical size: can default to ``font.design_size``. Set in points.
163
+ - Optical size: can default to ``font.design_size``. Set in points.
164
164
  Must be positive.
165
- * Slant: can default to ``font.italicangle``. 0 if upright, negative
165
+ - Slant: can default to ``font.italicangle``. 0 if upright, negative
166
166
  if oblique. This value is hardly positive (left-slanted.)
167
- * Width: can default using ``font.os2_width``. 100 if normal width,
167
+ - Width: can default using ``font.os2_width``. 100 if normal width,
168
168
  less if condensed, greater if expanded. Must be positive.
169
- * Weight: can default to ``font.os2_weight``. 400 if regular weight,
169
+ - Weight: can default to ``font.os2_weight``. 400 if regular weight,
170
170
  700 if bold. The minimum is 1 (hairline thin) and the maximum is
171
171
  999 (extreme bold.)
172
- * Custom axes: there is a room for 3 user-defined axes. No default
172
+ - Custom axes: there is a room for 3 user-defined axes. No default
173
173
  values.
174
174
 
175
175
  > [!TIP]
@@ -237,18 +237,18 @@ default.)
237
237
  Names the design axes. For predefined axes can use default name.
238
238
  Custom axes must be named if used.
239
239
 
240
- * Axis name: name of axis itself.
241
- * Labels: comma-separated list which consists of multiple of 4 of
240
+ - Axis name: name of axis itself.
241
+ - Labels: comma-separated list which consists of multiple of 4 of
242
242
  elements. Leading and trailing spaces will be trimmed. Every
243
243
  group of 4 elements:
244
- * Axis value
245
- * Flags
246
- * 0: Neither
247
- * 1: ``OLDER_SIBLING_FONT_ATTRIBUTE``
248
- * 2: ``ELIDABLE_AXIS_VALUE_NAME``
249
- * 3: Both
250
- * Linked value if exist
251
- * Name
244
+ - Axis value
245
+ - Flags
246
+ - 0: Neither
247
+ - 1: ``OLDER_SIBLING_FONT_ATTRIBUTE``
248
+ - 2: ``ELIDABLE_AXIS_VALUE_NAME``
249
+ - 3: Both
250
+ - Linked value if exist
251
+ - Name
252
252
 
253
253
  ##### Localized names
254
254
 
@@ -261,12 +261,12 @@ Set language code before you use. Choose a language from the list.
261
261
  By default there is a room for 8 languages, but this will be
262
262
  extended if already more than 4 languages are defined.
263
263
 
264
- * Axis name: name of axis itself.
265
- * Labels: comma-separated list which consists of even number of
264
+ - Axis name: name of axis itself.
265
+ - Labels: comma-separated list which consists of even number of
266
266
  elements. Leading and trailing spaces will be trimmed. Every
267
267
  pair of elements:
268
- * Axis value
269
- * Name
268
+ - Axis value
269
+ - Name
270
270
 
271
271
  > [!CAUTION]
272
272
  > Do not select the same language more than once, or undefined behavior will
@@ -424,6 +424,11 @@ fontforgeVF.setVFValue(fontCL, "instances[0].localNames.0x407", "Extramager")
424
424
 
425
425
  # Export TTF
426
426
  fontforgeVF.export(fontCL, 'MyFont.ttf')
427
+ fontforgeVF.export(fontCL, 'MyFont.ttf', 'MyFont-Italic.ttf') # if ``ital`` axis enabled
428
+ fontforgeVF.export(fontCL, 'MyFont.ttf',
429
+ decomposeNestedRefs=True,
430
+ decomposeTransformedRefs=True,
431
+ addAalt=True) # these options default to False
427
432
 
428
433
  # Export Webfont
429
434
  fontforgeVF.export(fontCL, 'MyFont.woff2')
@@ -0,0 +1,6 @@
1
+ from fontforgeVF.delete import *
2
+ from fontforgeVF.design_axes import *
3
+ from fontforgeVF.export import *
4
+ from fontforgeVF.language import *
5
+ from fontforgeVF.load import *
6
+ from fontforgeVF.utils import *
@@ -0,0 +1,55 @@
1
+ from fontforgeVF import (
2
+ delete,
3
+ design_axes,
4
+ export,
5
+ instance,
6
+ load
7
+ )
8
+ import fontforge
9
+
10
+
11
+ def fontforge_plugin_init(**kw):
12
+ fontforge.registerMenuItem(
13
+ callback=load.loadMenu,
14
+ enable=load.loadEnable,
15
+ context="Font",
16
+ submenu=["_Variable Font", '_Open a variable font'],
17
+ name="By named _instance...",
18
+ data=0
19
+ )
20
+ fontforge.registerMenuItem(
21
+ callback=load.loadMenu,
22
+ enable=load.loadEnable,
23
+ context="Font",
24
+ submenu=["_Variable Font", '_Open a variable font'],
25
+ name="By _parameter...",
26
+ data=1
27
+ )
28
+ fontforge.registerMenuItem(
29
+ callback=export.saveMenu,
30
+ enable=export.saveEnable,
31
+ context="Font",
32
+ submenu="_Variable Font",
33
+ name="_Generate a variable font..."
34
+ )
35
+ fontforge.registerMenuItem(
36
+ callback=design_axes.designAxesMenu,
37
+ enable=design_axes.designAxesEnable,
38
+ context="Font",
39
+ submenu="_Variable Font",
40
+ name="Design _axes..."
41
+ )
42
+ fontforge.registerMenuItem(
43
+ callback=instance.instanceMenu,
44
+ enable=instance.instanceEnable,
45
+ context="Font",
46
+ submenu="_Variable Font",
47
+ name="Named _instances..."
48
+ )
49
+ fontforge.registerMenuItem(
50
+ callback=delete.deleteVFInfoMenu,
51
+ enable=delete.deleteVFInfoEnable,
52
+ context="Font",
53
+ submenu="_Variable Font",
54
+ name="_Delete VF info"
55
+ )
@@ -0,0 +1,37 @@
1
+ from fontforgeVF import utils
2
+ import fontforge
3
+
4
+
5
+ __all__ = [
6
+ "deleteVFInfo",
7
+ ]
8
+
9
+
10
+ def deleteVFInfo(font: fontforge.font) -> bool:
11
+ """Deletes VF info
12
+
13
+ Deletes ``VF`` key from ``font.persistent`` if it is a ``dict``.
14
+ Otherwise does nothing. If such case that the ``dict`` will be
15
+ empty, ``font.persistent`` will be set to ``None``.
16
+
17
+ :return: ``True`` if the key was deleted, ``False`` otherwise.
18
+ """
19
+ if utils.vfInfoExists(font):
20
+ del font.persistent['VF']
21
+ if len(font.persistent) == 0:
22
+ font.persistent = None
23
+ return True
24
+ else:
25
+ return False
26
+
27
+
28
+ def deleteVFInfoMenu(u, glyph):
29
+ """Menu emtry to delete VF info from UI
30
+
31
+ This menu is enabled if active font has VF info.
32
+ """
33
+ deleteVFInfo(fontforge.activeFont())
34
+
35
+
36
+ def deleteVFInfoEnable(u, glyph):
37
+ return utils.vfInfoExists(fontforge.activeFont())