summaryrefslogtreecommitdiff
path: root/lib/extensions/lettering_generate_json.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/extensions/lettering_generate_json.py')
-rw-r--r--lib/extensions/lettering_generate_json.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/extensions/lettering_generate_json.py b/lib/extensions/lettering_generate_json.py
index f4a01ddb..bfdd1055 100644
--- a/lib/extensions/lettering_generate_json.py
+++ b/lib/extensions/lettering_generate_json.py
@@ -38,6 +38,7 @@ class LetteringGenerateJson(InkstitchExtension):
self.arg_parser.add_argument("--use-custom-leading", type=Boolean, default="false", dest="use_custom_leading")
self.arg_parser.add_argument("--use-custom-spacing", type=Boolean, default="false", dest="use_custom_spacing")
self.arg_parser.add_argument("--use-custom-letter-spacing", type=Boolean, default="false", dest="use_custom_letter_spacing")
+ self.arg_parser.add_argument("--use-glyph-width", type=Boolean, default="false", dest="use_glyph_width")
self.arg_parser.add_argument("-l", "--leading", type=int, default=100, dest="leading")
self.arg_parser.add_argument("-w", "--word-spacing", type=int, default=20, dest="word_spacing")
self.arg_parser.add_argument("-b", "--letter-spacing", type=int, default=100, dest="letter_spacing")
@@ -61,17 +62,14 @@ class LetteringGenerateJson(InkstitchExtension):
hkern = font_info.hkern()
custom_leading = self.options.use_custom_leading
custom_spacing = self.options.use_custom_spacing
- custom_letter_spacing = self.options.use_custom_letter_spacing
word_spacing = font_info.word_spacing()
# use user input in case that the default word spacing is not defined
# in the svg file or the user forces custom values
if custom_spacing or not word_spacing:
word_spacing = self.options.word_spacing
- letter_spacing = font_info.letter_spacing()
- # use user input in case that the default word spacing is not defined
- # in the svg file or the user forces custom values
- if custom_letter_spacing or not letter_spacing:
- letter_spacing = self.options.letter_spacing
+
+ letter_spacing = self._get_letter_spacing(font_info)
+
units_per_em = font_info.units_per_em() or self.options.leading
# use units_per_em for leading (line height) if defined in the font file,
# unless the user wishes to overwrite the value
@@ -127,3 +125,13 @@ class LetteringGenerateJson(InkstitchExtension):
# write data to font.json into the same directory as the font file
with open(output_path, 'w', encoding="utf8") as font_data:
json.dump(data, font_data, indent=4, ensure_ascii=False)
+
+ def _get_letter_spacing(self, font_info):
+ letter_spacing = font_info.letter_spacing()
+ # use user input in case that the default word spacing is not defined
+ # in the svg file or the user forces custom values
+ if self.options.use_custom_letter_spacing or not letter_spacing:
+ letter_spacing = self.options.letter_spacing
+ if self.options.use_glyph_width:
+ letter_spacing = None
+ return letter_spacing