fontlab-python-plugmix 1.1.18__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fontlab_plugmix/__init__.py +41 -0
- fontlab_plugmix/backend.py +285 -0
- fontlab_plugmix/boot.py +140 -0
- fontlab_plugmix/filter.py +83 -0
- fontlab_plugmix/filters/__init__.py +4 -0
- fontlab_plugmix/filters/apply.py +158 -0
- fontlab_plugmix/filters/delete_small_paths.py +57 -0
- fontlab_plugmix/filters/dialog.py +119 -0
- fontlab_plugmix/filters/host.py +120 -0
- fontlab_plugmix/general.py +144 -0
- fontlab_plugmix/general_plugins/__init__.py +4 -0
- fontlab_plugmix/general_plugins/host.py +137 -0
- fontlab_plugmix/general_plugins/zoom_to_selection.py +27 -0
- fontlab_plugmix/geometry.py +64 -0
- fontlab_plugmix/kinds.py +33 -0
- fontlab_plugmix/menu.py +29 -0
- fontlab_plugmix/palette.py +24 -0
- fontlab_plugmix/palettes/__init__.py +4 -0
- fontlab_plugmix/palettes/apply.py +159 -0
- fontlab_plugmix/palettes/host.py +369 -0
- fontlab_plugmix/palettes/step_and_repeat.py +53 -0
- fontlab_plugmix/palettes/ui.py +86 -0
- fontlab_plugmix/plugin.py +14 -0
- fontlab_plugmix/plugins/__init__.py +4 -0
- fontlab_plugmix/plugins/anchor_cloud.py +30 -0
- fontlab_plugmix/plugins/angled_handles.py +40 -0
- fontlab_plugmix/plugins/center_lines.py +28 -0
- fontlab_plugmix/plugins/crosshair.py +39 -0
- fontlab_plugmix/plugins/duplicate_anchors.py +50 -0
- fontlab_plugmix/plugins/glyph_focus.py +28 -0
- fontlab_plugmix/plugins/imprecise_italic_angle.py +44 -0
- fontlab_plugmix/plugins/node_indexes.py +26 -0
- fontlab_plugmix/plugins/nodes_close_to_zones.py +35 -0
- fontlab_plugmix/plugins/offcurve_outside_bounds.py +31 -0
- fontlab_plugmix/plugins/only_selected_handles.py +38 -0
- fontlab_plugmix/plugins/rsb_line.py +39 -0
- fontlab_plugmix/plugins/segment_length.py +36 -0
- fontlab_plugmix/plugins/selected_coordinates.py +27 -0
- fontlab_plugmix/plugins/smooth_node_angles.py +51 -0
- fontlab_plugmix/plugins/tops_and_bottoms.py +34 -0
- fontlab_plugmix/plugins/two_point_distance.py +38 -0
- fontlab_plugmix/plugins/unitizer.py +35 -0
- fontlab_plugmix/plugins/vertical_metrics.py +39 -0
- fontlab_plugmix/registry.py +434 -0
- fontlab_plugmix/reporter.py +127 -0
- fontlab_plugmix/snapshot.py +285 -0
- fontlab_plugmix/tool.py +104 -0
- fontlab_plugmix/tools/__init__.py +4 -0
- fontlab_plugmix/tools/bridge.py +169 -0
- fontlab_plugmix/tools/host.py +143 -0
- fontlab_plugmix/tools/smart_select.py +77 -0
- fontlab_python_plugmix-1.1.18.dist-info/METADATA +444 -0
- fontlab_python_plugmix-1.1.18.dist-info/RECORD +56 -0
- fontlab_python_plugmix-1.1.18.dist-info/WHEEL +4 -0
- fontlab_python_plugmix-1.1.18.dist-info/licenses/LICENSE +201 -0
- fontlab_python_plugmix-1.1.18.dist-info/licenses/NOTICE +228 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# this_file: src/fontlab_plugmix/tools/host.py
|
|
2
|
+
"""Register native tools, keep their bridges alive and own Window toggles."""
|
|
3
|
+
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
from typing import Any, ClassVar
|
|
6
|
+
|
|
7
|
+
from fontlab_plugmix.kinds import Services, guarded
|
|
8
|
+
|
|
9
|
+
from .bridge import ToolBridge
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class UnsupportedCapability(RuntimeError):
|
|
13
|
+
"""This FontLab build lacks native Python tool registration."""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class _Registration:
|
|
18
|
+
"""Strong references required for FontLab's callback lifetime."""
|
|
19
|
+
|
|
20
|
+
native: Any
|
|
21
|
+
bridge: ToolBridge
|
|
22
|
+
plugin: Any
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ToolHost:
|
|
26
|
+
"""Own native tool registrations and persistent enable actions."""
|
|
27
|
+
|
|
28
|
+
_retained: ClassVar[list[_Registration]] = []
|
|
29
|
+
|
|
30
|
+
def __init__(self, services: Services, registry: Any) -> None:
|
|
31
|
+
self.services, self.registry = services, registry
|
|
32
|
+
self.actions: dict[str, int] = {}
|
|
33
|
+
self.registered: dict[str, _Registration] = {}
|
|
34
|
+
self.workspace: Any = None
|
|
35
|
+
|
|
36
|
+
def _workspace(self) -> Any:
|
|
37
|
+
"""Require the verified flWorkspace Python tool hook."""
|
|
38
|
+
workspace_class = getattr(self.services.fontlab, "flWorkspace", None)
|
|
39
|
+
if workspace_class is None:
|
|
40
|
+
raise UnsupportedCapability("FontLab has no flWorkspace.registerPythonTool")
|
|
41
|
+
workspace = workspace_class.instance()
|
|
42
|
+
if not callable(getattr(workspace, "registerPythonTool", None)):
|
|
43
|
+
raise UnsupportedCapability("FontLab has no flWorkspace.registerPythonTool")
|
|
44
|
+
return workspace
|
|
45
|
+
|
|
46
|
+
def _register(self, name: str) -> None:
|
|
47
|
+
"""Pin the bridge before FontLab can call its first callback."""
|
|
48
|
+
if name in self.registered:
|
|
49
|
+
return
|
|
50
|
+
plugin = self.registry.available("tool")[name]()
|
|
51
|
+
bridge = ToolBridge(plugin, self.services)
|
|
52
|
+
workspace = self._workspace()
|
|
53
|
+
native = workspace.registerPythonTool(plugin.title, None, bridge)
|
|
54
|
+
self.workspace = workspace
|
|
55
|
+
self.registered[name] = _Registration(native, bridge, plugin)
|
|
56
|
+
|
|
57
|
+
def _unregister(self, name: str) -> None:
|
|
58
|
+
"""Drop overlay first, then native registration, even after errors."""
|
|
59
|
+
record = self.registered.get(name)
|
|
60
|
+
if record is None:
|
|
61
|
+
return
|
|
62
|
+
record.bridge.deactivate()
|
|
63
|
+
self.workspace.unregisterPythonTool(record.native)
|
|
64
|
+
self.registered.pop(name, None)
|
|
65
|
+
|
|
66
|
+
def _checked(self, name: str) -> None:
|
|
67
|
+
self.services.menus.action(self.actions[name]).setChecked(
|
|
68
|
+
name in self.registered
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
def install(self) -> None:
|
|
72
|
+
"""Install one Window toggle per tool; skip unsupported native hooks."""
|
|
73
|
+
for name, cls in self.registry.available("tool").items():
|
|
74
|
+
token = self.services.menus.add_action(
|
|
75
|
+
"Window",
|
|
76
|
+
f"Plugmix: Tool {cls.title}",
|
|
77
|
+
lambda *args, name=name: guarded(
|
|
78
|
+
self, self.services.sink, lambda: self.toggle(name)
|
|
79
|
+
),
|
|
80
|
+
checkable=True,
|
|
81
|
+
)
|
|
82
|
+
self.actions[name] = token
|
|
83
|
+
if name in self.registry.enabled_tools():
|
|
84
|
+
try:
|
|
85
|
+
self._register(name)
|
|
86
|
+
except UnsupportedCapability as error:
|
|
87
|
+
guarded(
|
|
88
|
+
self,
|
|
89
|
+
self.services.sink,
|
|
90
|
+
lambda error=error: (_ for _ in ()).throw(error),
|
|
91
|
+
)
|
|
92
|
+
self.services.menus.action(token).setEnabled(False)
|
|
93
|
+
except Exception as error: # noqa: BLE001 - one tool cannot block boot
|
|
94
|
+
guarded(
|
|
95
|
+
self,
|
|
96
|
+
self.services.sink,
|
|
97
|
+
lambda error=error: (_ for _ in ()).throw(error),
|
|
98
|
+
)
|
|
99
|
+
self._checked(name)
|
|
100
|
+
|
|
101
|
+
def toggle(self, name: str) -> bool:
|
|
102
|
+
"""Apply the user's explicit registration choice and persist it."""
|
|
103
|
+
if name not in self.actions:
|
|
104
|
+
raise KeyError(name)
|
|
105
|
+
active = name in self.registered
|
|
106
|
+
try:
|
|
107
|
+
if active:
|
|
108
|
+
self._unregister(name)
|
|
109
|
+
try:
|
|
110
|
+
self.registry.set_tool_enabled(name, False)
|
|
111
|
+
except Exception:
|
|
112
|
+
guarded(self, self.services.sink, lambda: self._register(name))
|
|
113
|
+
raise
|
|
114
|
+
else:
|
|
115
|
+
self._register(name)
|
|
116
|
+
try:
|
|
117
|
+
self.registry.set_tool_enabled(name, True)
|
|
118
|
+
except Exception:
|
|
119
|
+
guarded(self, self.services.sink, lambda: self._unregister(name))
|
|
120
|
+
raise
|
|
121
|
+
finally:
|
|
122
|
+
self._checked(name)
|
|
123
|
+
return name in self.registered
|
|
124
|
+
|
|
125
|
+
def close(self) -> None:
|
|
126
|
+
"""Unregister every tool and remove owned actions without losing prefs."""
|
|
127
|
+
for name in tuple(self.registered):
|
|
128
|
+
try:
|
|
129
|
+
self._unregister(name)
|
|
130
|
+
except Exception as error: # noqa: BLE001 - pin a still-native bridge
|
|
131
|
+
self._retained.append(self.registered.pop(name))
|
|
132
|
+
guarded(
|
|
133
|
+
self,
|
|
134
|
+
self.services.sink,
|
|
135
|
+
lambda error=error: (_ for _ in ()).throw(error),
|
|
136
|
+
)
|
|
137
|
+
for token in tuple(self.actions.values()):
|
|
138
|
+
guarded(
|
|
139
|
+
self,
|
|
140
|
+
self.services.sink,
|
|
141
|
+
lambda token=token: self.services.menus.remove(token),
|
|
142
|
+
)
|
|
143
|
+
self.actions.clear()
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# this_file: src/fontlab_plugmix/tools/smart_select.py
|
|
3
|
+
"""Drag a rectangle to select whole contours touched by their nodes.
|
|
4
|
+
|
|
5
|
+
Selection-only cut from But Ko's Smart Select Tool: no double-click contour
|
|
6
|
+
containment, no native node movement and no geometry edits.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from fontlab_plugmix.reporter import Mark
|
|
10
|
+
from fontlab_plugmix.snapshot import GlyphSnapshot
|
|
11
|
+
from fontlab_plugmix.tool import Tool, ToolContext, ToolEvent
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def touched_contours(
|
|
15
|
+
glyph: GlyphSnapshot, first: tuple[float, float], last: tuple[float, float]
|
|
16
|
+
) -> tuple[int, ...]:
|
|
17
|
+
"""Return contours with any node inside the inclusive drag rectangle."""
|
|
18
|
+
left, right = sorted((first[0], last[0]))
|
|
19
|
+
bottom, top = sorted((first[1], last[1]))
|
|
20
|
+
return tuple(
|
|
21
|
+
index
|
|
22
|
+
for index, contour in enumerate(glyph.contours)
|
|
23
|
+
if any(
|
|
24
|
+
left <= node.x <= right and bottom <= node.y <= top
|
|
25
|
+
for node in contour.nodes
|
|
26
|
+
)
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class SmartSelect(Tool):
|
|
31
|
+
"""Emphasise a drag rectangle and select whole contours on release."""
|
|
32
|
+
|
|
33
|
+
name = "smart_select"
|
|
34
|
+
title = "Smart Select"
|
|
35
|
+
|
|
36
|
+
def __init__(self) -> None:
|
|
37
|
+
self.ctx: ToolContext | None = None
|
|
38
|
+
self.origin: tuple[float, float] | None = None
|
|
39
|
+
self.end: tuple[float, float] | None = None
|
|
40
|
+
|
|
41
|
+
def activate(self, ctx: ToolContext) -> None:
|
|
42
|
+
self.ctx = ctx
|
|
43
|
+
self.origin = self.end = None
|
|
44
|
+
|
|
45
|
+
def deactivate(self) -> None:
|
|
46
|
+
self.origin = self.end = None
|
|
47
|
+
self.ctx = None
|
|
48
|
+
|
|
49
|
+
def press(self, event: ToolEvent) -> bool:
|
|
50
|
+
self.origin = self.end = (event.x, event.y)
|
|
51
|
+
return True
|
|
52
|
+
|
|
53
|
+
def move(self, event: ToolEvent) -> bool:
|
|
54
|
+
if self.origin is None or not event.buttons:
|
|
55
|
+
return False
|
|
56
|
+
self.end = event.x, event.y
|
|
57
|
+
self.ctx.redraw()
|
|
58
|
+
return True
|
|
59
|
+
|
|
60
|
+
def release(self, event: ToolEvent) -> bool:
|
|
61
|
+
if self.origin is None:
|
|
62
|
+
return False
|
|
63
|
+
start, self.end = self.origin, (event.x, event.y)
|
|
64
|
+
self.origin = None
|
|
65
|
+
glyph = self.ctx.snapshot()
|
|
66
|
+
if glyph is not None:
|
|
67
|
+
self.ctx.select(
|
|
68
|
+
touched_contours(glyph, start, self.end), toggle=event.shift
|
|
69
|
+
)
|
|
70
|
+
return True
|
|
71
|
+
|
|
72
|
+
def marks(self, glyph: GlyphSnapshot | None) -> list[Mark]:
|
|
73
|
+
if self.origin is None or self.end is None:
|
|
74
|
+
return []
|
|
75
|
+
x1, y1 = self.origin
|
|
76
|
+
x2, y2 = self.end
|
|
77
|
+
return [Mark("polyline", ((x1, y1), (x2, y1), (x2, y2), (x1, y2), (x1, y1)))]
|
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: fontlab-python-plugmix
|
|
3
|
+
Version: 1.1.18
|
|
4
|
+
Summary: Native FontLab 9 reporter and filter plugins
|
|
5
|
+
License: Apache License
|
|
6
|
+
Version 2.0, January 2004
|
|
7
|
+
http://www.apache.org/licenses/
|
|
8
|
+
|
|
9
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
10
|
+
|
|
11
|
+
1. Definitions.
|
|
12
|
+
|
|
13
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
14
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
15
|
+
|
|
16
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
17
|
+
the copyright owner that is granting the License.
|
|
18
|
+
|
|
19
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
20
|
+
other entities that control, are controlled by, or are under common
|
|
21
|
+
control with that entity. For the purposes of this definition,
|
|
22
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
23
|
+
direction or management of such entity, whether by contract or
|
|
24
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
25
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
26
|
+
|
|
27
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
28
|
+
exercising permissions granted by this License.
|
|
29
|
+
|
|
30
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
31
|
+
including but not limited to software source code, documentation
|
|
32
|
+
source, and configuration files.
|
|
33
|
+
|
|
34
|
+
"Object" form shall mean any form resulting from mechanical
|
|
35
|
+
transformation or translation of a Source form, including but
|
|
36
|
+
not limited to compiled object code, generated documentation,
|
|
37
|
+
and conversions to other media types.
|
|
38
|
+
|
|
39
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
40
|
+
Object form, made available under the License, as indicated by a
|
|
41
|
+
copyright notice that is included in or attached to the work
|
|
42
|
+
(an example is provided in the Appendix below).
|
|
43
|
+
|
|
44
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
45
|
+
form, that is based on (or derived from) the Work and for which the
|
|
46
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
47
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
48
|
+
of this License, Derivative Works shall not include works that remain
|
|
49
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
50
|
+
the Work and Derivative Works thereof.
|
|
51
|
+
|
|
52
|
+
"Contribution" shall mean any work of authorship, including
|
|
53
|
+
the original version of the Work and any modifications or additions
|
|
54
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
55
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
56
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
57
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
58
|
+
means any form of electronic, verbal, or written communication sent
|
|
59
|
+
to the Licensor or its representatives, including but not limited to
|
|
60
|
+
communication on electronic mailing lists, source code control systems,
|
|
61
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
62
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
63
|
+
excluding communication that is conspicuously marked or otherwise
|
|
64
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
65
|
+
|
|
66
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
67
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
68
|
+
subsequently incorporated within the Work.
|
|
69
|
+
|
|
70
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
71
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
72
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
73
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
74
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
75
|
+
Work and such Derivative Works in Source or Object form.
|
|
76
|
+
|
|
77
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
78
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
79
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
80
|
+
(except as stated in this section) patent license to make, have made,
|
|
81
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
82
|
+
where such license applies only to those patent claims licensable
|
|
83
|
+
by such Contributor that are necessarily infringed by their
|
|
84
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
85
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
86
|
+
institute patent litigation against any entity (including a
|
|
87
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
88
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
89
|
+
or contributory patent infringement, then any patent licenses
|
|
90
|
+
granted to You under this License for that Work shall terminate
|
|
91
|
+
as of the date such litigation is filed.
|
|
92
|
+
|
|
93
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
94
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
95
|
+
modifications, and in Source or Object form, provided that You
|
|
96
|
+
meet the following conditions:
|
|
97
|
+
|
|
98
|
+
(a) You must give any other recipients of the Work or
|
|
99
|
+
Derivative Works a copy of this License; and
|
|
100
|
+
|
|
101
|
+
(b) You must cause any modified files to carry prominent notices
|
|
102
|
+
stating that You changed the files; and
|
|
103
|
+
|
|
104
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
105
|
+
that You distribute, all copyright, patent, trademark, and
|
|
106
|
+
attribution notices from the Source form of the Work,
|
|
107
|
+
excluding those notices that do not pertain to any part of
|
|
108
|
+
the Derivative Works; and
|
|
109
|
+
|
|
110
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
111
|
+
distribution, then any Derivative Works that You distribute must
|
|
112
|
+
include a readable copy of the attribution notices contained
|
|
113
|
+
within such NOTICE file, excluding those notices that do not
|
|
114
|
+
pertain to any part of the Derivative Works, in at least one
|
|
115
|
+
of the following places: within a NOTICE text file distributed
|
|
116
|
+
as part of the Derivative Works; within the Source form or
|
|
117
|
+
documentation, if provided along with the Derivative Works; or,
|
|
118
|
+
within a display generated by the Derivative Works, if and
|
|
119
|
+
wherever such third-party notices normally appear. The contents
|
|
120
|
+
of the NOTICE file are for informational purposes only and
|
|
121
|
+
do not modify the License. You may add Your own attribution
|
|
122
|
+
notices within Derivative Works that You distribute, alongside
|
|
123
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
124
|
+
that such additional attribution notices cannot be construed
|
|
125
|
+
as modifying the License.
|
|
126
|
+
|
|
127
|
+
You may add Your own copyright statement to Your modifications and
|
|
128
|
+
may provide additional or different license terms and conditions
|
|
129
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
130
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
131
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
132
|
+
the conditions stated in this License.
|
|
133
|
+
|
|
134
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
135
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
136
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
137
|
+
this License, without any additional terms or conditions.
|
|
138
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
139
|
+
the terms of any separate license agreement you may have executed
|
|
140
|
+
with Licensor regarding such Contributions.
|
|
141
|
+
|
|
142
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
143
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
144
|
+
except as required for reasonable and customary use in describing the
|
|
145
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
146
|
+
|
|
147
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
148
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
149
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
150
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
151
|
+
implied, including, without limitation, any warranties or conditions
|
|
152
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
153
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
154
|
+
appropriateness of using or redistributing the Work and assume any
|
|
155
|
+
risks associated with Your exercise of permissions under this License.
|
|
156
|
+
|
|
157
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
158
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
159
|
+
unless required by applicable law (such as deliberate and grossly
|
|
160
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
161
|
+
liable to You for damages, including any direct, indirect, special,
|
|
162
|
+
incidental, or consequential damages of any character arising as a
|
|
163
|
+
result of this License or out of the use or inability to use the
|
|
164
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
165
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
166
|
+
other commercial damages or losses), even if such Contributor
|
|
167
|
+
has been advised of the possibility of such damages.
|
|
168
|
+
|
|
169
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
170
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
171
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
172
|
+
or other liability obligations and/or rights consistent with this
|
|
173
|
+
License. However, in accepting such obligations, You may act only
|
|
174
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
175
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
176
|
+
defend, and hold each Contributor harmless for any liability
|
|
177
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
178
|
+
of your accepting any such warranty or additional liability.
|
|
179
|
+
|
|
180
|
+
END OF TERMS AND CONDITIONS
|
|
181
|
+
|
|
182
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
183
|
+
|
|
184
|
+
To apply the Apache License to your work, attach the following
|
|
185
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
186
|
+
replaced with your own identifying information. (Don't include
|
|
187
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
188
|
+
comment syntax for the file format. We also recommend that a
|
|
189
|
+
file or class name and description of purpose be included on the
|
|
190
|
+
same "printed page" as the copyright notice for easier
|
|
191
|
+
identification within third-party archives.
|
|
192
|
+
|
|
193
|
+
Copyright [yyyy] [name of copyright owner]
|
|
194
|
+
|
|
195
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
196
|
+
you may not use this file except in compliance with the License.
|
|
197
|
+
You may obtain a copy of the License at
|
|
198
|
+
|
|
199
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
200
|
+
|
|
201
|
+
Unless required by applicable law or agreed to in writing, software
|
|
202
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
203
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
204
|
+
See the License for the specific language governing permissions and
|
|
205
|
+
limitations under the License.
|
|
206
|
+
License-File: LICENSE
|
|
207
|
+
License-File: NOTICE
|
|
208
|
+
Requires-Python: >=3.11
|
|
209
|
+
Requires-Dist: fontlab-fontlabapp>=1.2.10
|
|
210
|
+
Provides-Extra: test
|
|
211
|
+
Requires-Dist: pytest; extra == 'test'
|
|
212
|
+
Requires-Dist: pytest-cov; extra == 'test'
|
|
213
|
+
Description-Content-Type: text/markdown
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
this_file: README.md
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
# fontlab-python-plugmix
|
|
220
|
+
|
|
221
|
+
Reference Extensions pack for App's `fontlabapp.plugins` core: 50 plugins: 39 reporters,
|
|
222
|
+
five filters, four tools, one palette and one General plugin. Concrete plugins live
|
|
223
|
+
in `Extensions/`; the core owns discovery, preferences, callbacks and native UI.
|
|
224
|
+
The separate `fontlab_plugmix` compatibility package remains intact.
|
|
225
|
+
|
|
226
|
+
The pack ships as `fontlab-python-plugmix-extensions.zip`, built by
|
|
227
|
+
`python tools/build_pack.py [OUT_DIR]` (Extensions, `Scripts/Plugmix`, this README).
|
|
228
|
+
The wheel is the compatibility package only and contains no Extensions.
|
|
229
|
+
|
|
230
|
+
## Extensions and action scripts
|
|
231
|
+
|
|
232
|
+
Install `fontlab-fontlabapp>=1.2.10` and `fontlab-fly>=1.3.0` with its canonical providers in FontLab's Python
|
|
233
|
+
3.11 arm64 environment before using the bundles, action or startup snippet.
|
|
234
|
+
Their API imports use `fly.ap`; Fly preserves App module and class identity.
|
|
235
|
+
The pack installer declares and requests Fly >=1.3.0 alongside App; hand-copy
|
|
236
|
+
installation must prepare those packages first. The legacy compatibility library
|
|
237
|
+
keeps its App-only dependency.
|
|
238
|
+
|
|
239
|
+
See [Extensions/README.md](Extensions/README.md) for the bundle layout and manifest.
|
|
240
|
+
Open `install.vfpy` in FontLab (or copy the Extensions contents into the FontLab
|
|
241
|
+
user-data `Extensions/` folder by hand). The file is a short stub that hands the
|
|
242
|
+
work to
|
|
243
|
+
[fontlab-instamix](https://github.com/fontlabcom/fontlab-python-instamix); if
|
|
244
|
+
instamix is not installed yet, the stub installs it from PyPI first. Instamix
|
|
245
|
+
links the 50 bundles into `Extensions/<kind>/`, installs `Scripts/Plugmix` and
|
|
246
|
+
records the install under the extension id `com.fontlab.python-plugmix`.
|
|
247
|
+
Run App's `install.vfpy` first, and run it again after updating App: it records
|
|
248
|
+
the App version FontLab reports, all bundles need the plugin core first released in 1.2.9. Four of the five filters (Scale Outlines, Move Outlines, Round Outline To Grid, Slant Outlines) need the coordinate writer first released in 1.2.10; the complete pack therefore requires 1.2.10 or newer. An older recorded version rejects bundles above its declared minimum. App's startup hook discovers the bundles. Each bundle is self-contained Python source
|
|
249
|
+
with a `plugin.json`; it needs no package install or reporter launcher.
|
|
250
|
+
|
|
251
|
+
Use the Reporters palette or View > Reporters to enable reporters. The only
|
|
252
|
+
remaining script, `Scripts/Plugmix/Show Reporters.py`, opens that palette. Reporters
|
|
253
|
+
do not edit font geometry; enabling one persists its stable ID. Duplicate Anchor
|
|
254
|
+
Rings retains its 5, 8 or 12 handle-size API, with the default of 8.
|
|
255
|
+
|
|
256
|
+
App and the retained compatibility runtime both use `fontlab-plugmix.json`.
|
|
257
|
+
Choose one runtime per FontLab session; do not combine their startup installers.
|
|
258
|
+
Cross-runtime preference migration remains unqualified. The installer adds no
|
|
259
|
+
packages and does not edit FontLab's startup file.
|
|
260
|
+
|
|
261
|
+
## Retained compatibility package
|
|
262
|
+
|
|
263
|
+
`src/fontlab_plugmix/` remains a separate installable package with 19 reporters,
|
|
264
|
+
an undoable Filter, a dockable Palette, a native Tool and a General menu command.
|
|
265
|
+
Its code, tests, dependencies and legal attribution are retained.
|
|
266
|
+
|
|
267
|
+
For this runtime, install the package and `fontlab-fontlabapp>=1.2.10` in FontLab's
|
|
268
|
+
Python 3.11 environment and explicitly call `fontlab_plugmix.install()` once per
|
|
269
|
+
session. The optional `initScript-snippet.py` now starts App through
|
|
270
|
+
`fly.ap.plugins.install()`; use it only with the App runtime. Use native MeVisLab
|
|
271
|
+
PythonQt inside FontLab, without another Qt binding. Native per-canvas painters
|
|
272
|
+
are preferred, with App's `EditorPainters` fallback on older builds.
|
|
273
|
+
|
|
274
|
+
The compatibility View menu has 19 `Plugmix: Show …` actions and Zoom to Selection.
|
|
275
|
+
Glyph has Delete Small Paths; Window has Step and Repeat Panel and Tool Smart
|
|
276
|
+
Select. Choices live in FontLab's Data directory as `fontlab-plugmix.json`.
|
|
277
|
+
`install(config_dir=...)` selects an owned directory for tests, and
|
|
278
|
+
`boot.uninstall()` removes owned actions, overlays and panels while retaining
|
|
279
|
+
saved choices. Unknown preference keys survive. The compatibility runtime maps
|
|
280
|
+
old `nodes_outside_paths` choices to `offcurve_outside_bounds`; this is not a
|
|
281
|
+
cross-runtime migration guarantee.
|
|
282
|
+
|
|
283
|
+
Filter, Tool and General choices default on until explicitly changed. Palettes
|
|
284
|
+
start hidden. Saved preferences retain `enabled`, `enabled_filters`,
|
|
285
|
+
`enabled_palettes`, `enabled_tools`, `enabled_general` and last-used `params`.
|
|
286
|
+
|
|
287
|
+
### Compatibility reporters
|
|
288
|
+
|
|
289
|
+
| Reporter | Overlay |
|
|
290
|
+
| --- | --- |
|
|
291
|
+
| Duplicate Anchor Rings | Red/yellow rings for every unordered anchor pair less than one font unit apart; three coincident anchors produce three ring pairs. |
|
|
292
|
+
| Node Indexes | Full contour index beside every on- and off-curve node. |
|
|
293
|
+
| Selected Node Coordinates | Coordinates beside selected nodes. |
|
|
294
|
+
| Two Point Distance | A segment, length and angle for exactly two selected nodes. |
|
|
295
|
+
| Off-curve Handles Outside Bounds | Off-curve handles beyond the on-curve bounding rectangle. This uses bounds, unlike mekkablue's ShowNodesOutsidePaths path-containment test. |
|
|
296
|
+
| Center Lines | Advance/2, x-height/2 and cap-height/2 lines. |
|
|
297
|
+
| Vertical Metrics | Labelled ascender, descender, x-height, cap-height and baseline lines. |
|
|
298
|
+
| Angled Handles | Rings on off-curve handles outside horizontal, vertical and italic axes. |
|
|
299
|
+
| Crosshair | Thin, far-reaching guides through selected nodes; no mouse tracking. |
|
|
300
|
+
| Tops and Bottoms | Rings and y labels at tied highest and lowest on-curve positions. |
|
|
301
|
+
| Segment Length | Straight and flattened curve lengths where both on-curve ends are selected, or all when nothing is selected; runs of more than two off-curves are skipped. |
|
|
302
|
+
| Glyph Focus | Translucent shade outside the advance box between descender and ascender. |
|
|
303
|
+
| Emphasise Selected Handles | Accent lines and rings for handles next to selected nodes; native handles remain visible. |
|
|
304
|
+
| Anchor Cloud | Names and positions of the current glyph's anchors. |
|
|
305
|
+
| RSB Line | Advance boundary plus RSB and LSB labels from the native ink box. |
|
|
306
|
+
| Unitizer | Vertical grid behind the glyph at UPM / 18 increments; units per em is a class attribute. |
|
|
307
|
+
| Nodes Close to Zones | Rings on on-curves near selected-master zone edges or metric heights. |
|
|
308
|
+
| Imprecise Italic Angle | Straight segments within 2° of the master slant but not exactly on it. |
|
|
309
|
+
| Smooth Node Angles | Handle-angle mismatch and handle-length ratio at smooth nodes. |
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
Anchor Cloud shows local anchors only. A font-wide cloud still needs reliable
|
|
313
|
+
revision-based invalidation. Stroke, text and ring sizes stay constant while
|
|
314
|
+
zooming. Center Lines, Vertical Metrics, Crosshair, Tops and Bottoms, RSB Line and
|
|
315
|
+
Unitizer request background painting; older builds substitute foreground painting
|
|
316
|
+
and log that choice once. Each reporter captures the glyph separately on repaint;
|
|
317
|
+
zones and native ink bounds are read only when requested.
|
|
318
|
+
|
|
319
|
+
Native drawing maps glyph points through the glyph text-block transform, the
|
|
320
|
+
block placement and `canvas.mapToViewportF`. Text-block placement matters away
|
|
321
|
+
from the canvas origin. Native compatibility observations are historical;
|
|
322
|
+
shortcut and keyboard cursor mapping changes still need an in-app recheck.
|
|
323
|
+
|
|
324
|
+
### Other compatibility plugins
|
|
325
|
+
|
|
326
|
+
- Delete Small Paths deletes closed contours below the threshold (default 400
|
|
327
|
+
font units squared) using flattened path area or flattened bounds area. Open
|
|
328
|
+
contours and exact-threshold values stay. It edits selected current-master
|
|
329
|
+
glyphs through one geometry Undo step, skips automatic layers and unsafe
|
|
330
|
+
shared/transformed outlines per glyph, and retains safe glyphs in the selection.
|
|
331
|
+
- Step and Repeat duplicates selected contours with count additional copies and
|
|
332
|
+
repeated X/Y offsets through one geometry Undo step. It retains unselected
|
|
333
|
+
contours, leaves copies unselected and refuses shared/transformed outlines,
|
|
334
|
+
non-master display layers, stale contour counts and zero-offset repeats.
|
|
335
|
+
Count zero or no selection is a no-op. Dock ownership survives temporary
|
|
336
|
+
hiding; the Window toggle provides explicit close if close detection is absent.
|
|
337
|
+
- Smart Select selects whole contours touched by a dragged rectangle; Shift
|
|
338
|
+
toggles them. It changes selection only and omits the source plugin's
|
|
339
|
+
double-click containment and native move handling.
|
|
340
|
+
- Zoom to Selection fits the selected nodes with a margin. It omits delayed
|
|
341
|
+
viewport adjustment and a shortcut. General font events use stable `fgId`
|
|
342
|
+
identities and share the palette host's refresh timer.
|
|
343
|
+
|
|
344
|
+
### Write an App reporter through Fly
|
|
345
|
+
|
|
346
|
+
`compute()` receives immutable Python data and returns marks in font units.
|
|
347
|
+
Native reads and writes belong in the host layer. Pure imports do not need FontLab:
|
|
348
|
+
|
|
349
|
+
```python
|
|
350
|
+
from fly.ap.plugins import Mark, Reporter
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
class Origin(Reporter):
|
|
354
|
+
name = "origin"
|
|
355
|
+
title = "Origin"
|
|
356
|
+
|
|
357
|
+
def compute(self, snapshot):
|
|
358
|
+
return [Mark("ring", ((0, 0),), diameter_px=12)]
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Publish these App classes through the `fontlabapp.plugmix` entry-point group,
|
|
362
|
+
or place them in Extensions bundles. Fly returns App's exact `Mark` and
|
|
363
|
+
`Reporter` classes. The retained compatibility runtime has a distinct
|
|
364
|
+
`fontlab_plugmix.Reporter` base and discovers its classes only through
|
|
365
|
+
`fontlab_plugmix.plugins`; the two bases and entry-point groups are not
|
|
366
|
+
interchangeable. Names must be unique and titles
|
|
367
|
+
human-readable. Marks support ring, line, polyline, polygon and text; polygon
|
|
368
|
+
fill is RGBA, coordinates are font units, and stroke/text/diameter values are
|
|
369
|
+
view pixels. `layer = "background"` requests painting beneath native glyphs on
|
|
370
|
+
supported builds. Callbacks contain failures; reporter compute/paint must not
|
|
371
|
+
write font data.
|
|
372
|
+
|
|
373
|
+
## Development checks
|
|
374
|
+
|
|
375
|
+
Use arm64 Python 3.11 and owned sibling App, Pens and Fly (>=1.3.0) sources. The exact full recipe is:
|
|
376
|
+
|
|
377
|
+
```sh
|
|
378
|
+
UV_PYTHON_PREFERENCE=only-system PLUGMIX_FONTLABAPP_SOURCE="$PWD/../fontlab-fontlabapp" sh test.sh
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
The runner-layout test requires the sibling App source. The runner explicitly
|
|
382
|
+
installs the selected Pens checkout and selects Fly's `src` on `PYTHONPATH`,
|
|
383
|
+
without installing Fly's full provider cohort. Set `PLUGMIX_PENS_SOURCE` or
|
|
384
|
+
`PLUGMIX_FLY_SOURCE` to select different owned checkouts. The no-selector run
|
|
385
|
+
executes the complete suite, retaining the compatibility package coverage gate
|
|
386
|
+
and requiring at least 80% line coverage and 80% branch coverage separately for
|
|
387
|
+
every Extensions and Scripts module and the startup snippet. Arguments skip the checker; after a selected
|
|
388
|
+
run, use the full suite before invoking `python3 tests/check_coverage.py coverage.json`.
|
|
389
|
+
|
|
390
|
+
Tests use real App bundle discovery, boot, registry and menus with fake host owners
|
|
391
|
+
and temporary preferences. Reporter behavior tests retain the original assertions
|
|
392
|
+
from App, with imports redirected to the bundle modules. Registration tests cover
|
|
393
|
+
repeated enable, menu disable, unknown preferences and failed-save rollback.
|
|
394
|
+
No offline result establishes native rendering, owner installation, published
|
|
395
|
+
artifacts or FontLab menu/toolbar insertion.
|
|
396
|
+
|
|
397
|
+
## Releasing the pack
|
|
398
|
+
|
|
399
|
+
Push the `v*` tag, then within 10 minutes create the release with notes (`gh release create <tag> --verify-tag --notes-file ...`). The Pack workflow's `release` job waits for the release and attaches `fontlab-python-plugmix-extensions.zip`; it never creates releases. If it timed out, create the release and re-run the job, then check `gh release view <tag> --json assets`.
|
|
400
|
+
|
|
401
|
+
## Remaining acceptance
|
|
402
|
+
|
|
403
|
+
Issue 210's source split is implemented in this paired candidate. Qualify native
|
|
404
|
+
Reporters palette/menu synchronization, toolbar and Tools > Tool, Window > Panels,
|
|
405
|
+
startup, teardown, drawing and writer history on the exact installed tuple.
|
|
406
|
+
Issue 211's existing native checks remain separate. Issue 123 remains paused.
|
|
407
|
+
Removing the retained compatibility package requires a consumer, distribution,
|
|
408
|
+
source-recovery and licence audit. The source/build website remains separately
|
|
409
|
+
maintained under `src_docs`; private Pages publication remains owner-held.
|
|
410
|
+
|
|
411
|
+
## Licence and contribution workflow
|
|
412
|
+
|
|
413
|
+
Apache-2.0; retain `LICENSE` and all Apache-2.0/MIT attribution in `NOTICE`.
|
|
414
|
+
Read `AGENTS.md`, `PLAN.md` and `TODO.md` before changes. Qualified source,
|
|
415
|
+
ordinary artifacts, native behavior, canonical adoption and publication have
|
|
416
|
+
separate acceptance gates.
|
|
417
|
+
|
|
418
|
+
## Issue 233 source/build-only documentation
|
|
419
|
+
|
|
420
|
+
Maintained site source is `src_docs/md`, configured by `src_docs/mkdocs.yml`;
|
|
421
|
+
`docs/` is generated output. Use a separate Python 3.13 docs environment, uv
|
|
422
|
+
0.13.7 and the exact hash-locked requirements. Run `sh src_docs/build.sh` and
|
|
423
|
+
`python -m unittest discover -s tests_docs -v` with that environment on PATH.
|
|
424
|
+
Every main push builds exact source X, optionally makes a normal docs-only child
|
|
425
|
+
Y, and independently verifies immutable lineage, source identity, source epoch
|
|
426
|
+
and complete tracked/untracked generated parity. No private Pages permission,
|
|
427
|
+
configuration, deployment or automatic publication request is enabled.
|
|
428
|
+
Source/generated review, actual Actions, owner installation and native acceptance
|
|
429
|
+
remain separate. Do not change runtime dependencies, startup or recovery pins for
|
|
430
|
+
a site build.
|
|
431
|
+
|
|
432
|
+
## Practical outline workflows
|
|
433
|
+
|
|
434
|
+
- [Round Outline to Grid](src_docs/md/plugins/round-outline-to-grid.md) snaps own outline nodes to a grid.
|
|
435
|
+
- [Move Outlines](src_docs/md/plugins/move-outlines.md) translates outlines without changing advance widths.
|
|
436
|
+
- [Scale Outlines](src_docs/md/plugins/scale-outlines.md) scales outlines about a chosen pivot.
|
|
437
|
+
- [Slant Outlines](src_docs/md/plugins/slant-outlines.md) applies geometric shear.
|
|
438
|
+
- [Measurement Ruler](src_docs/md/plugins/measurement-ruler.md) measures a dragged span.
|
|
439
|
+
- [Node Probe](src_docs/md/plugins/node-probe.md) inspects nearby outline nodes.
|
|
440
|
+
- [Contour Picker](src_docs/md/plugins/contour-picker.md) selects a contour by a nearby node.
|
|
441
|
+
|
|
442
|
+
The four coordinate filters preserve components, anchors, advance widths and
|
|
443
|
+
native curve types. Tools do not change geometry. Their pages describe scope,
|
|
444
|
+
parameters and interaction limits; native verification remains open.
|