Skip to content

Commit

Permalink
[buildcff2vf] Fixed some typos and Codacy + flake8 errors
Browse files Browse the repository at this point in the history
Fixed typos I noticed while looking at these files.

Fixed Codacy and flake8 errors noted by Chris Chapman on last build.
  • Loading branch information
readroberts authored and cjchapman committed Jun 28, 2019
1 parent 6152bc0 commit e229453
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions python/afdko/buildcff2vf.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,19 @@ def make_flat_curve(self, cur_coords):
# Convert line coords to curve coords.
dx = self.roundNumber(cur_coords[0] / 3.0)
dy = self.roundNumber(cur_coords[1] / 3.0)
new_coords = [dx, dy, dx, dy, cur_coords[0]-2*dx, cur_coords[1]-2*dy]
new_coords = [dx, dy, dx, dy,
cur_coords[0] - 2 * dx, cur_coords[1] - 2 * dy]
return new_coords

def make_curve_coords(self, coords, is_default):
# Convert line coords to curve coords.
prev_cmd = self._commands[self.pt_index - 1]
if is_default:
new_coords = []
for i, cur_coords in enumerate(coords):
for cur_coords in coords:
master_coords = self.make_flat_curve(cur_coords)
new_coords.append(master_coords)
else:
cur_coords = coords
prev_coords = prev_cmd[1][-1]
new_coords = self.make_flat_curve(cur_coords)
return new_coords

Expand Down Expand Up @@ -255,17 +254,18 @@ def check_and_fix_closepath(self, cmd, point_type, pt_coords):
return True
return False

def getCharStrings(self, num_masters, private=None, globalSubrs=None, default_idx=0):
def getCharStrings(self, num_masters, private=None,
globalSubrs=None, default_idx=0):
""" A command looks like:
[op_name, [
[source 0 arglist for op],
[source 1 arglist for op],
...
[source n arglist for op],
I am not optimising this there, as that will be done when
the CFF2 Charstring is creating in fontTools.varLib.build().
I am not optimizing this there, as that will be done when
the CFF2 Charstring is created in fontTools.varLib.build().
If I did, I woudl have to rearragne the arguments to:
If I did, I would have to rearrange the arguments to:
[
[arg 0 for source 0 ... arg 0 for source n]
[arg 1 for source 0 ... arg 1 for source n]
Expand Down Expand Up @@ -294,11 +294,11 @@ def getCharStrings(self, num_masters, private=None, globalSubrs=None, default_id
# if default_idx is not 0, we need to move it to the right index.
if default_idx:
default_font_cs = t2List.pop(0)
t2List.insert(default_idx, default_font_cs)
t2List.insert(default_idx, default_font_cs)
return t2List


def _get_cs(glyphOrder, charstrings, glyphName):
def _get_cs(charstrings, glyphName):
if glyphName not in charstrings:
return None
return charstrings[glyphName]
Expand All @@ -312,7 +312,7 @@ def do_compatibility(vf, master_fonts, default_idx):
font['CFF '].cff.topDictIndex[0].CharStrings for font in master_fonts]

for gname in glyphOrder:
all_cs = [_get_cs(glyphOrder, cs, gname) for cs in charStrings]
all_cs = [_get_cs(cs, gname) for cs in charStrings]
if len([gs for gs in all_cs if gs is not None]) < 2:
continue
# remove the None's from the list.
Expand All @@ -333,7 +333,8 @@ def do_compatibility(vf, master_fonts, default_idx):
if compat_pen.fixed:
fixed_cs_list = compat_pen.getCharStrings(
num_masters, private=default_charstring.private,
globalSubrs=default_charstring.globalSubrs, default_idx=default_idx)
globalSubrs=default_charstring.globalSubrs,
default_idx=default_idx)
cs_list = list(cs_list)
for i, cs in enumerate(cs_list):
mi = all_cs.index(cs)
Expand Down
2 changes: 1 addition & 1 deletion tests/buildcff2vf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_cjk_vf():
assert differ([expected_ttx, actual_ttx, '-s', '<ttFont sfntVersion'])


def test_parse_cjk_vf():
def test_sparse_cjk_vf():
# subset fonts to lists in 'SHSansJPVFTest.subset.txt'
# Check compatibility. Issue is in cid00089.
# keep PostScript names
Expand Down

0 comments on commit e229453

Please sign in to comment.