fontforge-variable-font 0.4.2__tar.gz → 0.5.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 (25) hide show
  1. {fontforge_variable_font-0.4.2/fontforge_variable_font.egg-info → fontforge_variable_font-0.5.0}/PKG-INFO +2 -2
  2. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/fontforgeVF/__main__.py +19 -16
  3. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/fontforgeVF/design_axes.py +20 -19
  4. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/fontforgeVF/export.py +13 -12
  5. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/fontforgeVF/instance.py +10 -9
  6. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/fontforgeVF/language.py +6 -4
  7. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/fontforgeVF/load.py +25 -20
  8. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/fontforgeVF/utils.py +8 -4
  9. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0/fontforge_variable_font.egg-info}/PKG-INFO +2 -2
  10. fontforge_variable_font-0.5.0/fontforge_variable_font.egg-info/requires.txt +3 -0
  11. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/setup.cfg +2 -2
  12. fontforge_variable_font-0.4.2/fontforge_variable_font.egg-info/requires.txt +0 -3
  13. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/LICENSE +0 -0
  14. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/README.md +0 -0
  15. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/fontforgeVF/__init__.py +0 -0
  16. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/fontforgeVF/delete.py +0 -0
  17. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/fontforge_variable_font.egg-info/SOURCES.txt +0 -0
  18. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/fontforge_variable_font.egg-info/dependency_links.txt +0 -0
  19. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/fontforge_variable_font.egg-info/entry_points.txt +0 -0
  20. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/fontforge_variable_font.egg-info/top_level.txt +0 -0
  21. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/pyproject.toml +0 -0
  22. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/test/test_design_axes.py +0 -0
  23. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/test/test_export.py +0 -0
  24. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.0}/test/test_language.py +0 -0
  25. {fontforge_variable_font-0.4.2 → fontforge_variable_font-0.5.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.4.2
3
+ Version: 0.5.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
@@ -17,7 +17,7 @@ Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
18
  Requires-Dist: fonttools
19
19
  Requires-Dist: fontmake
20
- Requires-Dist: fontforge_plugin_helper
20
+ Requires-Dist: fontforge_plugin_helper>=0.3.0
21
21
  Dynamic: license-file
22
22
 
23
23
  Fontforge Variable Font Plugin
@@ -1,66 +1,69 @@
1
1
  import fontforge
2
2
 
3
- from fontforgeVF import (
3
+ from fontforge_plugin_helper import addSystemHook
4
+
5
+ from . import (
4
6
  delete,
5
7
  design_axes,
6
8
  export,
7
9
  instance,
8
- load
10
+ load,
9
11
  )
10
- from fontforge_plugin_helper import addSystemHook
12
+ from .translation import tr, setTranslation
11
13
 
12
14
 
13
15
  def fontforge_plugin_init(**kw):
16
+ setTranslation()
14
17
  fontforge.registerMenuItem(
15
18
  callback=load.loadMenu,
16
19
  enable=None,
17
20
  context="Font",
18
- submenu=["_Variable Font", '_Open a variable font'],
19
- name="By named _instance...",
21
+ submenu=[tr.get('_Variable Font'), tr.get('_Open a variable font')],
22
+ name=tr.get('By named _instance...'),
20
23
  data=0
21
24
  )
22
25
  fontforge.registerMenuItem(
23
26
  callback=load.loadMenu,
24
27
  enable=None,
25
28
  context="Font",
26
- submenu=["_Variable Font", '_Open a variable font'],
27
- name="By _parameter...",
29
+ submenu=[tr.get('_Variable Font'), tr.get('_Open a variable font')],
30
+ name=tr.get('By _parameter...'),
28
31
  data=1
29
32
  )
30
33
  fontforge.registerMenuItem(
31
34
  callback=export.saveMenu,
32
35
  enable=export.saveEnable,
33
36
  context="Font",
34
- submenu="_Variable Font",
35
- name="_Generate a variable font..."
37
+ submenu=tr.get('_Variable Font'),
38
+ name=tr.get('_Generate a variable font...')
36
39
  )
37
40
 
38
41
  fontforge.registerMenuItem(
39
42
  divider=True,
40
43
  context="Font",
41
- submenu="_Variable Font",
44
+ submenu=tr.get('_Variable Font'),
42
45
  )
43
46
 
44
47
  fontforge.registerMenuItem(
45
48
  callback=design_axes.designAxesMenu,
46
49
  enable=None,
47
50
  context="Font",
48
- submenu="_Variable Font",
49
- name="Design _axes..."
51
+ submenu=tr.get('_Variable Font'),
52
+ name=tr.get('Design _axes...')
50
53
  )
51
54
  fontforge.registerMenuItem(
52
55
  callback=instance.instanceMenu,
53
56
  enable=None,
54
57
  context="Font",
55
- submenu="_Variable Font",
56
- name="Named _instances..."
58
+ submenu=tr.get('_Variable Font'),
59
+ name=tr.get('Named _instances...')
57
60
  )
58
61
  fontforge.registerMenuItem(
59
62
  callback=delete.deleteVFInfoMenu,
60
63
  enable=delete.deleteVFInfoEnable,
61
64
  context="Font",
62
- submenu="_Variable Font",
63
- name="_Delete VF info"
65
+ submenu=tr.get('_Variable Font'),
66
+ name=tr.get('_Delete VF info')
64
67
  )
65
68
 
66
69
  if fontforge.hasUserInterface:
@@ -1,6 +1,7 @@
1
1
  import fontforge
2
2
 
3
3
  from . import utils
4
+ from .translation import tr
4
5
 
5
6
 
6
7
  def _getWidthFromOS2Width(font: fontforge.font) -> int | float:
@@ -125,14 +126,14 @@ def _prepareQuestions_values(questions, k, v):
125
126
  tagVal = utils.getVFValue(font, 'axes.' + k + '.value', defaultTagVal) if tagStat == 1 else defaultTagVal
126
127
  questions[0]["questions"].append({
127
128
  'type': 'choice',
128
- 'question': v["name"] + ':',
129
+ 'question': tr.get(v["name"]) + ':',
129
130
  'tag': k,
130
131
  'checks': True,
131
132
  'answers': [
132
- {'name': 'Unset', 'tag': 'unset', 'default': tagStat == 0},
133
- {'name': 'Set', 'tag': 'custom', 'default': tagStat == 1},
133
+ {'name': tr.get('Unset'), 'tag': 'unset', 'default': tagStat == 0},
134
+ {'name': tr.get('Set'), 'tag': 'custom', 'default': tagStat == 1},
134
135
  ] + ([
135
- {'name': 'Default (' + str(v["auto"](font)) + ')', 'tag': 'auto', 'default': tagStat == 2},
136
+ {'name': tr.get('Default ({0})').format(str(v["auto"](font))), 'tag': 'auto', 'default': tagStat == 2},
136
137
  ] if v["auto"] else []),
137
138
  })
138
139
  if k == 'ital':
@@ -142,8 +143,8 @@ def _prepareQuestions_values(questions, k, v):
142
143
  'tag': k + 'val',
143
144
  'checks': True,
144
145
  'answers': [
145
- {'name': 'No', 'tag': 'false', 'default': not tagVal},
146
- {'name': 'Yes', 'tag': 'true', 'default': tagVal},
146
+ {'name': tr.get('No'), 'tag': 'false', 'default': not tagVal},
147
+ {'name': tr.get('Yes'), 'tag': 'true', 'default': tagVal},
147
148
  ],
148
149
  })
149
150
  else:
@@ -160,7 +161,7 @@ def _prepareQuestions_map(questions, k, v):
160
161
  assert font is not None
161
162
  questions[2]["questions"].append({
162
163
  'type': 'string',
163
- 'question': v["name"] + ':',
164
+ 'question': tr.get(v["name"]) + ':',
164
165
  'tag': k + 'map',
165
166
  'default': ', '.join(list(map(
166
167
  lambda x: str(x[0]) + ',' + str(x[1]),
@@ -174,7 +175,7 @@ def _prepareQuestions_order(questions, k, v):
174
175
  assert font is not None
175
176
  questions[3]["questions"].append({
176
177
  'type': 'string',
177
- 'question': v["name"] + ':',
178
+ 'question': tr.get(v["name"]) + ':',
178
179
  'tag': k + 'order',
179
180
  'default': str(utils.getVFValue(font, 'axes.' + k + '.order', '')),
180
181
  })
@@ -185,7 +186,7 @@ def _prepareQuestions_names(questions, k, v):
185
186
  assert font is not None
186
187
  questions[4]["questions"].append({
187
188
  'type': 'string',
188
- 'question': v["name"] + ':',
189
+ 'question': tr.get(v["name"]) + ':',
189
190
  'tag': k + 'name',
190
191
  'default': utils.getVFValue(
191
192
  font,
@@ -195,7 +196,7 @@ def _prepareQuestions_names(questions, k, v):
195
196
  })
196
197
  questions[4]["questions"].append({
197
198
  'type': 'string',
198
- 'question': '\tLabels:',
199
+ 'question': tr.get('\tLabels:'),
199
200
  'tag': k + 'labels',
200
201
  'default': _loadLabels(k),
201
202
  })
@@ -207,7 +208,7 @@ def _prepareQuestions_localNames(questions, k, v, languages, localNameRange, loc
207
208
  for i in localNameRange:
208
209
  questions[localNameCategory + i - 1]["questions"].append({
209
210
  'type': 'string',
210
- 'question': v["name"] + ':',
211
+ 'question': tr.get(v["name"]) + ':',
211
212
  'tag': k + 'name' + str(i),
212
213
  'default': utils.getVFValue(
213
214
  font, 'axes.' + k + '.localNames.' + hex(languages[i-1]), ''
@@ -215,7 +216,7 @@ def _prepareQuestions_localNames(questions, k, v, languages, localNameRange, loc
215
216
  })
216
217
  questions[localNameCategory + i - 1]["questions"].append({
217
218
  'type': 'string',
218
- 'question': '\tLabels:',
219
+ 'question': tr.get('\tLabels:'),
219
220
  'tag': k + 'labels' + str(i),
220
221
  'default': _loadLabels(k, languages[i-1]) if i <= len(languages) else '',
221
222
  })
@@ -227,7 +228,7 @@ def _prepareQuestions_custom(questions, k, v):
227
228
  if k.startswith('custom'):
228
229
  questions[1]["questions"].append({
229
230
  'type': 'string',
230
- 'question': v["name"] + ' tag:',
231
+ 'question': tr.get('{0} tag:').format(tr.get(v["name"])),
231
232
  'tag': k + 'tag',
232
233
  'default': utils.getVFValue(font, 'axes.' + k + '.tag', ''),
233
234
  })
@@ -235,11 +236,11 @@ def _prepareQuestions_custom(questions, k, v):
235
236
 
236
237
  def _prepareQuestions():
237
238
  questions = [
238
- {'category': 'This master', 'questions': []},
239
- {'category': 'Custom axes', 'questions': []},
240
- {'category': 'Axis map', 'questions': []},
241
- {'category': 'Axis order', 'questions': []},
242
- {'category': 'Axis names', 'questions': []},
239
+ {'category': tr.get('This master'), 'questions': []},
240
+ {'category': tr.get('Custom axes'), 'questions': []},
241
+ {'category': tr.get('Axis map'), 'questions': []},
242
+ {'category': tr.get('Axis order'), 'questions': []},
243
+ {'category': tr.get('Axis names'), 'questions': []},
243
244
  ]
244
245
 
245
246
  languages, localNameCategory, localNameRange = _prepareQuestions_languages(questions)
@@ -427,6 +428,6 @@ def designAxesMenu(u, glyph):
427
428
  * Axis value
428
429
  * Name
429
430
  """
430
- result = fontforge.askMulti("Design axes", _prepareQuestions()) # type: ignore
431
+ result = fontforge.askMulti(tr.get("Design axes"), _prepareQuestions()) # type: ignore
431
432
  if result:
432
433
  _saveResult(result)
@@ -14,6 +14,7 @@ from fontTools.designspaceLib import (
14
14
 
15
15
  from . import utils, language
16
16
  from .design_axes import designAxes, getAxisValue
17
+ from .translation import tr
17
18
 
18
19
 
19
20
  def _getSourceFonts(defaultFont: fontforge.font, filterItalicRoman: bool | None = None) -> list[fontforge.font]:
@@ -431,16 +432,16 @@ def _exportVF(
431
432
  cmd = e.cmd.split(' ')
432
433
  fontforge.logWarning(e.stderr)
433
434
  fontforge.postError(
434
- "Failed to export",
435
- "'{0}' failed with return code {1}".format(cmd[0], e.returncode)
435
+ tr.get("Failed to export"),
436
+ tr.get("'{0}' failed with return code {1}").format(cmd[0], e.returncode)
436
437
  )
437
438
  else:
438
439
  raise
439
440
  else:
440
441
  if fontforge.hasUserInterface():
441
442
  fontforge.postNotice(
442
- "Finished",
443
- "Finished to output variable fonts"
443
+ tr.get("Finished"),
444
+ tr.get("Finished to output variable fonts"),
444
445
  )
445
446
 
446
447
 
@@ -554,14 +555,14 @@ def _saveMenuDialog(font: fontforge.font) -> dict | None:
554
555
  if _hasBothRomanAndItalic(font):
555
556
  questions: list = [
556
557
  {
557
- 'type': 'savepath', 'question': '_Roman VF:', 'tag': 'file',
558
+ 'type': 'savepath', 'question': tr.get('_Roman VF:'), 'tag': 'file',
558
559
  'default':
559
560
  font.default_base_filename + '.ttf' if font.default_base_filename
560
561
  else '.'.join(font.path.split('.')[:-1]) + '.ttf',
561
562
  'filter': '*.{ttf,woff2}',
562
563
  },
563
564
  {
564
- 'type': 'savepath', 'question': '_Italic VF:', 'tag': 'file2',
565
+ 'type': 'savepath', 'question': tr.get('_Italic VF:'), 'tag': 'file2',
565
566
  'default':
566
567
  font.default_base_filename + '-Italic.ttf' if font.default_base_filename
567
568
  else '.'.join(font.path.split('.')[:-1]) + '-Italic.ttf',
@@ -571,7 +572,7 @@ def _saveMenuDialog(font: fontforge.font) -> dict | None:
571
572
  else:
572
573
  questions: list = [
573
574
  {
574
- 'type': 'savepath', 'question': '_Save as:', 'tag': 'file',
575
+ 'type': 'savepath', 'question': tr.get('_Save as:'), 'tag': 'file',
575
576
  'default':
576
577
  font.default_base_filename + '.ttf' if font.default_base_filename
577
578
  else '.'.join(font.path.split('.')[:-1]) + '.ttf',
@@ -580,16 +581,16 @@ def _saveMenuDialog(font: fontforge.font) -> dict | None:
580
581
  ]
581
582
  questions += [
582
583
  {
583
- 'type': 'choice', 'question': 'Options:', 'tag': 'options',
584
+ 'type': 'choice', 'question': tr.get('Options:'), 'tag': 'options',
584
585
  'checks': True, 'multiple': True,
585
586
  'answers': [
586
- {'name': 'Decompose _nested refs', 'tag': 'nestedRefs'},
587
- {'name': 'Decompose _transformed refs', 'tag': 'transformedRefs'},
588
- {'name': "Add '_aalt' feature", 'tag': 'aalt'},
587
+ {'name': tr.get('Decompose _nested refs'), 'tag': 'nestedRefs'},
588
+ {'name': tr.get('Decompose _transformed refs'), 'tag': 'transformedRefs'},
589
+ {'name': tr.get("Add '_aalt' feature"), 'tag': 'aalt'},
589
590
  ],
590
591
  },
591
592
  ]
592
- return fontforge.askMulti("Save variable font", questions)
593
+ return fontforge.askMulti(tr.get("Save variable font"), questions)
593
594
 
594
595
 
595
596
  def saveMenu(u, font: fontforge.font):
@@ -2,6 +2,7 @@ import fontforge
2
2
 
3
3
  from . import utils
4
4
  from .design_axes import designAxes
5
+ from .translation import tr
5
6
 
6
7
 
7
8
  def _instances_getval(font: fontforge.font, cnt: int, key: str, defaultVal):
@@ -19,13 +20,13 @@ def _prepareQuestions_instances(cnt: int):
19
20
  questions = [
20
21
  {
21
22
  'type': 'string',
22
- 'question': 'PostScript Name:',
23
+ 'question': tr.get('PostScript Name:'),
23
24
  'tag': 'psName' + str(cnt),
24
25
  'default': _instances_getval(font, cnt, 'psName', ''),
25
26
  },
26
27
  {
27
28
  'type': 'string',
28
- 'question': 'Subfamily Name:',
29
+ 'question': tr.get('Subfamily Name:'),
29
30
  'tag': 'name' + str(cnt),
30
31
  'default': _instances_getval(font, cnt, 'name', ''),
31
32
  },
@@ -36,18 +37,18 @@ def _prepareQuestions_instances(cnt: int):
36
37
  val = _instances_getval(font, cnt, 'ital', False)
37
38
  questions.append({
38
39
  'type': 'choice',
39
- 'question': v['name'] + ':',
40
+ 'question': tr.get(v['name']) + ':',
40
41
  'tag': k + '_' + str(cnt),
41
42
  'checks': True,
42
43
  'answers': [
43
- {'name': 'No', 'tag': '0', 'default': not val},
44
- {'name': 'Yes', 'tag': '1', 'default': val},
44
+ {'name': tr.get('No'), 'tag': '0', 'default': not val},
45
+ {'name': tr.get('Yes'), 'tag': '1', 'default': val},
45
46
  ],
46
47
  })
47
48
  else:
48
49
  questions.append({
49
50
  'type': 'string',
50
- 'question': v['name'] + ':',
51
+ 'question': tr.get(v['name']) + ':',
51
52
  'tag': k + '_' + str(cnt),
52
53
  'default': str(_instances_getval(font, cnt, k, '')),
53
54
  })
@@ -86,7 +87,7 @@ def _prepareQuestions_instanceLocalNames(questions: list):
86
87
  for j in range(numberOfInstances):
87
88
  page['questions'].append({
88
89
  'type': 'string',
89
- 'question': _instances_getval(font, j + 1, 'name', 'Instance ' + str(j + 1)),
90
+ 'question': _instances_getval(font, j + 1, 'name', tr.get('Instance {0}').format(str(j + 1))),
90
91
  'tag': 'lang' + str(i + 1) + 'name' + str(j + 1),
91
92
  'default': utils.getVFValue(
92
93
  font, 'instances[' + str(j) + '].localNames.' + str(lang), ''
@@ -112,7 +113,7 @@ def _prepareQuestions():
112
113
 
113
114
  for i in range(numberOfInstances):
114
115
  questions.append({
115
- 'category': _instances_getval(font, i + 1, 'name', 'Instance ' + str(i + 1)),
116
+ 'category': _instances_getval(font, i + 1, 'name', tr.get('Instance {0}').format(str(i + 1))),
116
117
  'questions': _prepareQuestions_instances(i + 1)
117
118
  })
118
119
 
@@ -174,6 +175,6 @@ def instanceMenu(u, glyph):
174
175
  By default there is a room for 8 languages, but this will be
175
176
  extended if already more than 4 languages are defined.
176
177
  """
177
- result = fontforge.askMulti("Named instances", _prepareQuestions())
178
+ result = fontforge.askMulti(tr.get("Named instances"), _prepareQuestions())
178
179
  if result:
179
180
  _saveInstances(result)
@@ -1,3 +1,5 @@
1
+ from .translation import tr
2
+
1
3
  languageData = {
2
4
  1: {
3
5
  'name': 'Arabic',
@@ -799,7 +801,7 @@ def languageCodeIterator():
799
801
  if isinstance(msb, int):
800
802
  winLang = msb * 1024 + lsb
801
803
  for name in subLangData['name']:
802
- yield (winLang, subLangData['code'], name.replace('.', langData['name']))
804
+ yield (winLang, subLangData['code'], name.replace('.', langData['name'], 1))
803
805
 
804
806
 
805
807
  def languageCodeLookup(langCode: int) -> str | None:
@@ -825,13 +827,13 @@ def getLanguageList(listNumber: int, defaultCode: int | None = None):
825
827
  for langId, langCode, langName in sorted(languageCodeIterator(), key=lambda x: x[2]):
826
828
  languageList.append({'name': langName, 'tag': hex(langId), 'default': langId == defaultCode})
827
829
  questions = {
828
- 'category': 'Localized names ' + str(
830
+ 'category': tr.get('Localized names {0}').format(str(
829
831
  languageCodeLookup(defaultCode) if defaultCode else str(listNumber)
830
- ),
832
+ )),
831
833
  'questions': [
832
834
  {
833
835
  'type': 'choice',
834
- 'question': 'Language:',
836
+ 'question': tr.get('Language:'),
835
837
  'tag': 'lang' + str(listNumber),
836
838
  'answers': languageList,
837
839
  },
@@ -2,10 +2,11 @@ import faulthandler
2
2
  from os import PathLike
3
3
 
4
4
  import fontforge
5
+ from fontforge_plugin_helper import addFontGenerateHook
5
6
  from fontTools import ttLib
6
7
 
8
+ from .translation import tr
7
9
  from .utils import intOrFloat, checkExtensionTtfOrWoff2, ensureTuple
8
- from fontforge_plugin_helper import addFontGenerateHook
9
10
 
10
11
 
11
12
  def _checkAxisValue(ttf: ttLib.TTFont, axisValues: dict[str, int | float]):
@@ -311,7 +312,7 @@ def _setParameterDialog(filename: str | PathLike, ttf: ttLib.TTFont, tmpdir: str
311
312
  },
312
313
  )
313
314
 
314
- if result := fontforge.askMulti('Please specify an instance to open', questions):
315
+ if result := fontforge.askMulti(tr.get('Please specify an instance to open'), questions):
315
316
  for key in result:
316
317
  result[key] = intOrFloat(result[key]) # type: ignore
317
318
  _doOpenVariableFont(filename, result, ttf, tmpdir) # type: ignore
@@ -320,8 +321,8 @@ def _setParameterDialog(filename: str | PathLike, ttf: ttLib.TTFont, tmpdir: str
320
321
  def _chooseInstanceDialog(filename: str | PathLike, ttf: ttLib.TTFont, tmpdir: str | PathLike):
321
322
  assert 'fvar' in ttf
322
323
  result = fontforge.askChoices(
323
- 'Choose instance(s) to open',
324
- 'Instances in this font',
324
+ tr.get('Choose instance(s) to open'),
325
+ tr.get('Instances in this font'),
325
326
  tuple([str(ttf['name'].getName(i.subfamilyNameID, 3, 1, 0x409)) for i in ttf['fvar'].instances]),
326
327
  multiple=True
327
328
  )
@@ -353,15 +354,15 @@ def loadMenu(u, glyph):
353
354
  non-variable font is selected, simply opens that font.
354
355
  """
355
356
  faulthandler.enable()
356
- if filename := fontforge.openFilename('Open a variable font', '', '*.{ttf,woff2}'):
357
+ if filename := fontforge.openFilename(tr.get('Open a variable font'), '', '*.{ttf,woff2}'):
357
358
  with ttLib.TTFont(filename) as ttf:
358
359
  if 'fvar' not in ttf:
359
- fontforge.logWarning(filename + " does not have 'fvar' table")
360
+ fontforge.logWarning(tr.get("{0} does not have 'fvar' table".format(filename)))
360
361
  fontforge.open(filename)
361
362
  elif [axis for axis in ttf['fvar'].axes if axis.minValue != axis.maxValue]:
362
363
  _selectInstanceDialog(filename, ttf, u)
363
364
  else:
364
- fontforge.logWarning(filename + " has 'fvar' table but all axes are fixed")
365
+ fontforge.logWarning(tr.get("{0} has 'fvar' table but all axes are fixed").format(filename))
365
366
  fontforge.open(filename)
366
367
  faulthandler.disable()
367
368
 
@@ -374,11 +375,13 @@ def _generatePreHook(font: fontforge.font, target: str):
374
375
  if vfInfoExists(font):
375
376
  if target.endswith('.ttf') or target.endswith('.woff2'):
376
377
  ans = fontforge.ask(
377
- "Variable font",
378
- "This font has variable font metadata in its persistent dict.\n"
379
- "Did you intend to output a variable font?\n"
380
- "(all masters need to be opened beforehand)",
381
- ["_Yes", "_No"], # type: ignore
378
+ tr.get("Variable font"),
379
+ tr.get(
380
+ "This font has variable font metadata in its persistent dict.\n"
381
+ "Did you intend to output a variable font?\n"
382
+ "(all masters need to be opened beforehand)"
383
+ ),
384
+ [tr.get("_Yes"), tr.get("_No")], # type: ignore
382
385
  )
383
386
  font.temporary['generateVF'] = (ans == 0)
384
387
  font.changed = changed
@@ -416,15 +419,17 @@ def _loadHook_ttf(font: fontforge.font):
416
419
  if 'fvar' in ttf and [axis for axis in ttf['fvar'].axes if axis.minValue != axis.maxValue]:
417
420
  if ttf['fvar'].instances:
418
421
  ans = fontforge.ask(
419
- "Variable font",
420
- "The font '" + font.familyname + "' in \n"
421
- "'" + font.path + "'\n"
422
- "seems to be a variable font.\n"
423
- "Would you like to open another instance of this font?",
422
+ tr.get("Variable font"),
423
+ tr.get(
424
+ "The font '{0}' in\n"
425
+ "'{1}'\n"
426
+ "seems to be a variable font.\n"
427
+ "Would you like to open another instance of this font?"
428
+ ).format(font.familyname, font.path),
424
429
  [
425
- "_Yes",
426
- "Open with _parameters",
427
- "_No",
430
+ tr.get("_Yes"),
431
+ tr.get("Open with _parameters"),
432
+ tr.get("_No"),
428
433
  ] # type: ignore
429
434
  )
430
435
  if ans == 0 or ans == 1:
@@ -3,6 +3,8 @@ import re
3
3
 
4
4
  import fontforge
5
5
 
6
+ from .translation import tr
7
+
6
8
 
7
9
  def intOrFloat(val: str | int | float):
8
10
  """Convert to ``int`` or ``float`` if possible
@@ -77,10 +79,12 @@ def initPersistentDict(font: fontforge.font):
77
79
  fontforge.logWarning("Non-dict `font.persistent` will be lost")
78
80
  if fontforge.hasUserInterface():
79
81
  if fontforge.ask(
80
- "Data loss warning",
81
- "In active font, `font.persistent` exists but is other than a dict.\n"
82
- "This will be overwritten if you continue.",
83
- ("_OK", "_Cancel"), 0, 1
82
+ tr.get("Data loss warning"),
83
+ tr.get(
84
+ "In active font, `font.persistent` exists but is other than a dict.\n"
85
+ "This will be overwritten if you continue."
86
+ ),
87
+ (tr.get("_OK"), tr.get("_Cancel")), 0, 1
84
88
  ) == 1:
85
89
  raise RuntimeError("user refused to delete existing `font.persistent`")
86
90
  font.persistent = {}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fontforge_variable_font
3
- Version: 0.4.2
3
+ Version: 0.5.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
@@ -17,7 +17,7 @@ Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
18
  Requires-Dist: fonttools
19
19
  Requires-Dist: fontmake
20
- Requires-Dist: fontforge_plugin_helper
20
+ Requires-Dist: fontforge_plugin_helper>=0.3.0
21
21
  Dynamic: license-file
22
22
 
23
23
  Fontforge Variable Font Plugin
@@ -0,0 +1,3 @@
1
+ fonttools
2
+ fontmake
3
+ fontforge_plugin_helper>=0.3.0
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = fontforge_variable_font
3
- version = 0.4.2
3
+ version = 0.5.0
4
4
  author = MihailJP
5
5
  author_email = mihailjp@gmail.com
6
6
  description = A FontForge_plugin to create a variable font
@@ -24,7 +24,7 @@ python_requires = >=3.10
24
24
  install_requires =
25
25
  fonttools
26
26
  fontmake
27
- fontforge_plugin_helper
27
+ fontforge_plugin_helper>=0.3.0
28
28
 
29
29
  [options.entry_points]
30
30
  fontforge_plugin =
@@ -1,3 +0,0 @@
1
- fonttools
2
- fontmake
3
- fontforge_plugin_helper