Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: can only concatenate tuple (not "NoneType") to tuple #455

Closed
khaledhosny opened this issue Jun 12, 2023 · 1 comment · Fixed by googlefonts/picosvg#305
Closed

Comments

@khaledhosny
Copy link

Running maximum_color on this font results in:

$ maximum_color Raqq.ttf
I0612 17:14:48.395327 140704745006656 maximum_color.py:480] Generating build.ninja
I0612 17:14:48.409041 140704745006656 ninja.py:124] ninja -C ./build
ninja: Entering directory `./build'
[30/60] /venv/bin/python3.10 -m nanoemoji.write_part_file -v 0 --reuse_tolerance 0.1 --wh 1200 --output_file picosvg/00299.parts.json picosvg/00299.svg
FAILED: picosvg/00299.parts.json
/venv/bin/python3.10 -m nanoemoji.write_part_file -v 0 --reuse_tolerance 0.1 --wh 1200 --output_file picosvg/00299.parts.json picosvg/00299.svg
Traceback (most recent call last):
  File "/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/venv/lib/python3.10/site-packages/nanoemoji/write_part_file.py", line 55, in <module>
    app.run(main)
  File "/venv/lib/python3.10/site-packages/absl/app.py", line 308, in run
    _run_main(main, args)
  File "/venv/lib/python3.10/site-packages/absl/app.py", line 254, in _run_main
    sys.exit(main(argv))
  File "/venv/lib/python3.10/site-packages/nanoemoji/write_part_file.py", line 43, in main
    parts.add(svg)
  File "/venv/lib/python3.10/site-packages/nanoemoji/parts.py", line 165, in add
    shape = shape.apply_transform(transform)
  File "/venv/lib/python3.10/site-packages/picosvg/svg_types.py", line 275, in apply_transform
    return target.update_path(cmds, inplace=True)
  File "/venv/lib/python3.10/site-packages/picosvg/svg_types.py", line 696, in update_path
    for cmd, args in svg_cmds:
  File "/venv/lib/python3.10/site-packages/picosvg/svg_pathops.py", line 101, in svg_commands
    for svg_cmd, svg_args in _SKIA_CMD_TO_SVG_CMD[cmd](points):
  File "/venv/lib/python3.10/site-packages/picosvg/svg_pathops.py", line 55, in _qcurveto_to_svg
    yield ("Q", control_pt + end_pt)
TypeError: can only concatenate tuple (not "NoneType") to tuple
[37/60] /venv/bin/python3.10 -m nanoemoji.write_part_file -v 0 --reuse_tolerance 0.1 --wh 1200 --output_file picosvg/00301.parts.json picosvg/00301.svg
FAILED: picosvg/00301.parts.json
/venv/bin/python3.10 -m nanoemoji.write_part_file -v 0 --reuse_tolerance 0.1 --wh 1200 --output_file picosvg/00301.parts.json picosvg/00301.svg
Traceback (most recent call last):
  File "/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/venv/lib/python3.10/site-packages/nanoemoji/write_part_file.py", line 55, in <module>
    app.run(main)
  File "/venv/lib/python3.10/site-packages/absl/app.py", line 308, in run
    _run_main(main, args)
  File "/venv/lib/python3.10/site-packages/absl/app.py", line 254, in _run_main
    sys.exit(main(argv))
  File "/venv/lib/python3.10/site-packages/nanoemoji/write_part_file.py", line 43, in main
    parts.add(svg)
  File "/venv/lib/python3.10/site-packages/nanoemoji/parts.py", line 165, in add
    shape = shape.apply_transform(transform)
  File "/venv/lib/python3.10/site-packages/picosvg/svg_types.py", line 275, in apply_transform
    return target.update_path(cmds, inplace=True)
  File "/venv/lib/python3.10/site-packages/picosvg/svg_types.py", line 696, in update_path
    for cmd, args in svg_cmds:
  File "/venv/lib/python3.10/site-packages/picosvg/svg_pathops.py", line 101, in svg_commands
    for svg_cmd, svg_args in _SKIA_CMD_TO_SVG_CMD[cmd](points):
  File "/venv/lib/python3.10/site-packages/picosvg/svg_pathops.py", line 55, in _qcurveto_to_svg
    yield ("Q", control_pt + end_pt)
TypeError: can only concatenate tuple (not "NoneType") to tuple
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "/venv/bin/maximum_color", line 8, in <module>
    sys.exit(main())
  File "/venv/lib/python3.10/site-packages/nanoemoji/maximum_color.py", line 510, in main
    app.run(_run)
  File "/venv/lib/python3.10/site-packages/absl/app.py", line 308, in run
    _run_main(main, args)
  File "/venv/lib/python3.10/site-packages/absl/app.py", line 254, in _run_main
    sys.exit(main(argv))
  File "/venv/lib/python3.10/site-packages/nanoemoji/maximum_color.py", line 505, in _run
    maybe_run_ninja(build_file)
  File "/venv/lib/python3.10/site-packages/nanoemoji/ninja.py", line 125, in maybe_run_ninja
    subprocess.run(ninja_cmd, check=True)
  File "/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-C', './build']' returned non-zero exit status 1.
@anthrotype
Copy link
Member

thanks for the report

    yield ("Q", control_pt + end_pt)
TypeError: can only concatenate tuple (not "NoneType") to tuple

ha! oncurve-less truetype contours biting us :)

anthrotype added a commit to googlefonts/picosvg that referenced this issue Aug 4, 2023
Fixes #304
Fixes googlefonts/nanoemoji#455
Fixes googlefonts/noto-emoji#429

since skia-pathops v0.8.0, the Path.segments (SegmentPenIterator) may yield segments with an on-curve point set to None when closed contour is only comprised of quadratic beziers and all the on-curve points can be implied as in-between consecutive off-curve points (special TrueType quadratic spline), this was to match FontTools pen protocol, which the SegmentPenIterator is supposed to work with.
Picosvg was using this interface for converting from pathops.Path to SVG path.d strings, and uncaught TypeError was being raised when that happened. However, it turns out picosvg can avoid the SegmentPenIterator altogether when converting from pathops.Path to SVG, because the Path's RawPathIterator (i.e. iterating over the path itself as opposed to Path.segments) already yields (verb, points) for individual segment that matches what SVG expects (in this particular case, a move, a list of quadratic bezier segments each with one off-curve point, and a close command, no fonttools-style implied points anywhere). This way we can translate between SVG<=>pathops.Path in a more straightforward way (since they are closed to one another than to fonttools pen protocol more geared to font format specifics).
anthrotype added a commit that referenced this issue Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants