[fonttools/fonttools] c431b8: [svgLib.path] add tests for implicit moveto after ...

0 views
Skip to first unread message

Cosimo Lupo

unread,
Aug 20, 2026, 11:03:27 AM (6 days ago) Aug 20
to fontto...@googlegroups.com
Branch: refs/heads/svglib-4154-implicit-moveto
Home: https://github.com/fonttools/fonttools
Commit: c431b87b1491cc363ef2fd0172d027b01afa06ad
https://github.com/fonttools/fonttools/commit/c431b87b1491cc363ef2fd0172d027b01afa06ad
Author: Cosimo Lupo <cos...@anthrotype.com>
Date: 2026-08-20 (Thu, 20 Aug 2026)

Changed paths:
M Tests/svgLib/path/parser_test.py

Log Message:
-----------
[svgLib.path] add tests for implicit moveto after closepath

Per SVG 1.1 sec 8.3.3, a drawto command immediately following a closepath
starts a new subpath at the initial point of the just-closed subpath. The
parser currently drops that implicit moveTo, never emits the terminating
endPath for the new subpath, and raises TypeError when the command after
Z is S/s or T/t. These tests fail until the fix in the next commit.

Refs https://github.com/fonttools/fonttools/issues/4154


Commit: 13f952ca459479ff9ceeb5a76cc0f326d4d842df
https://github.com/fonttools/fonttools/commit/13f952ca459479ff9ceeb5a76cc0f326d4d842df
Author: Cosimo Lupo <cos...@anthrotype.com>
Date: 2026-08-20 (Thu, 20 Aug 2026)

Changed paths:
M Lib/fontTools/svgLib/path/parser.py
M Tests/svgLib/path/parser_test.py

Log Message:
-----------
[svgLib.path] implement implicit moveto after closepath

Fixes https://github.com/fonttools/fonttools/issues/4154

start_pos doubled as both the current subpath's initial point and the
subpath-open flag: Z set it to None, so a drawto command following a
closepath continued drawing without opening a new subpath, and the final
endPath was suppressed too. Split the two roles: start_pos now retains
the initial point across a closepath and a new subpath_open flag tracks
whether closePath/endPath is still owed. Any drawto command (not M/Z)
arriving with no open subpath now emits the implicit moveTo at the
just-closed subpath's initial point, per SVG 1.1 sec 8.3.3.

Z also sets command to None (implicit numbers after Z stay invalid), so
last_command is None for the command right after a closepath; the S/T
reflection checks now use tuple membership instead of substring matching
so they don't raise TypeError and correctly fall back to the current
point (the previous command Z is not a C/S or Q/T).

A redundant Z (Z Z) still emits a single closePath and no spurious
moveTo, preserving #4122.


Commit: 27370d69f5ef0141dbcb45afe752f2c3075e3044
https://github.com/fonttools/fonttools/commit/27370d69f5ef0141dbcb45afe752f2c3075e3044
Author: Cosimo Lupo <cos...@anthrotype.com>
Date: 2026-08-20 (Thu, 20 Aug 2026)

Changed paths:
M Tests/svgLib/path/parser_test.py

Log Message:
-----------
[svgLib.path] add tests rejecting paths that do not start with a moveto

A path data segment must begin with a moveto command per the SVG spec;
a user agent renders nothing when the first command is anything else.
The parser instead silently emitted a leading drawto with no moveTo
before it -- invalid pen output. These tests require ValueError before
any pen call for every leading command other than M/m (Z and bare
coordinates included), keep empty/whitespace paths as no-ops, and pin
that current_pos affects an initial relative moveto but does not
legalize a leading drawto. They fail until the fix in the next commit.


Commit: 099c8e0f8bad43650ccf17a041a2c3f3a5828991
https://github.com/fonttools/fonttools/commit/099c8e0f8bad43650ccf17a041a2c3f3a5828991
Author: Cosimo Lupo <cos...@anthrotype.com>
Date: 2026-08-20 (Thu, 20 Aug 2026)

Changed paths:
M Lib/fontTools/svgLib/path/parser.py

Log Message:
-----------
[svgLib.path] reject paths that do not start with a moveto

A path data segment must begin with a moveto command per the SVG spec;
a user agent renders nothing when the first command is anything else.
The parser instead silently emitted a leading drawto with no moveTo
before it, producing invalid pen output (TTGlyphPen raises PenError on
it). Check the first token after tokenization and raise ValueError
before any pen call. A path starting with bare coordinates now gets
this error instead of the 'Unallowed implicit command' one; empty and
whitespace-only paths remain a no-op.


Compare: https://github.com/fonttools/fonttools/compare/c431b87b1491%5E...099c8e0f8bad

To unsubscribe from these emails, change your notification settings at https://github.com/fonttools/fonttools/settings/notifications
Reply all
Reply to author
Forward
0 new messages