Skip to content

Commit

Permalink
clean flattend_kernel_table generation using itertools
Browse files Browse the repository at this point in the history
  • Loading branch information
mjishnu committed Sep 24, 2024
1 parent db83168 commit 042eefb
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions handwrite/svgtottf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import itertools
import json
import os
import sys
Expand Down Expand Up @@ -141,12 +142,8 @@ def set_kerning(self, table):
kerning_table = table.get("table", False)
if not kerning_table:
raise ValueError("Kerning offsets not found in the config file.")
flatten_list = (
lambda y: [x for a in y for x in flatten_list(a)]
if type(y) is list
else [y]
)
offsets = [0 if x is None else x for x in flatten_list(kerning_table)]
flattened_kerning_table = list(itertools.chain.from_iterable(kerning_table))
offsets = [0 if x is None else x for x in flattened_kerning_table]
self.font.addKerningClass("kern", "kern-1", rows, cols, offsets)

def generate_font_file(self, filename, outdir, config_file):
Expand Down

0 comments on commit 042eefb

Please sign in to comment.