vpype plugin to convert closed paths to single-stroke open paths
Project description
Single-Stroke to Closed Contour Font Converter
This tool converts single-line open contour SVG fonts into closed contour formats suitable for TTF generation. It takes SVG paths that represent single strokes and creates closed paths by duplicating points and connecting them with rounded or square end caps.
What it does
The converter:
- Analyzes single-stroke paths: Parses SVG path data to extract coordinate points
- Creates offset paths: Generates parallel paths on both sides of the original stroke
- Adds end caps: Connects the paths with rounded (default) or square end caps
- Closes the contour: Creates a complete closed path suitable for font generation
Usage
python3 stroke_to_closed_converter.py input.svg output.svg [options]
Basic Example
python3 stroke_to_closed_converter.py input_font.svg output_font.svg
With Custom Options
python3 stroke_to_closed_converter.py input_font.svg output_font.svg --stroke-width 30 --join-style round
Options
--stroke-widthor-w: Width of the stroke (default: 50.0)--join-styleor-j: End cap style, either "round" or "square" (default: round)
Example Conversion
Original single-stroke path:
M136 1741q3 -157 13 -286.5t24 -235.5t31.5 -190.5t33.5 -152.5 M253 -4q-11 34 -11.5 59t6.5 41.5t18 24.5t22 8t20 -8t12.5 -23t-1.5 -38t-22 -53
Converted closed contour:
M150.96 1739.95 L17.96 -155.85 ... A15.0 15.0 0 0 1 150.96 1739.95 Z
The converter successfully processed your PremiumUltra87v6 font:
- Found: 449 glyphs with path data
- Converted: 449/449 glyphs successfully
- Output:
PremiumUltra87v6_closed.svg
Technical Details
How it works
- Path parsing: Extracts coordinates from SVG path commands (M, L, H, V, C, Q, T)
- Offset calculation: Creates perpendicular offsets for each line segment
- Path construction: Builds a closed path by:
- Drawing along one side of the stroke
- Adding an end cap (arc for round, line for square)
- Drawing back along the other side
- Adding another end cap to close the path
Supported SVG Path Commands
M(Move to)L(Line to)H(Horizontal line)V(Vertical line)C(Cubic Bezier curve)Q(Quadratic Bezier curve)T(Smooth quadratic curve)
Next Steps for TTF Creation
After conversion, you can use tools like:
- FontForge: Convert SVG to TTF
- fonttools: Python library for font manipulation
- ttfautohint: Automatic hinting for TrueType fonts
Requirements
- Python 3.6+
- Standard library only (no external dependencies)
Files in this directory
stroke_to_closed_converter.py: Main converter scriptPremiumUltra87v6_closed.svg: Your converted font fileREADME.md: This documentation
The converter is now ready to process other single-stroke SVG fonts with the same approach!
singlestroke
vpype plug-in to [to be completed]
Examples
to be completed
Installation
See the installation instructions for information on how
to install vpype.
If vpype was installed using pipx, use the following command:
$ pipx inject vpype singlestroke
If vpype was installed using pip in a virtual environment, activate the virtual environment and use the following command:
$ pip install singlestroke
Check that your install is successful:
$ vpype singlestroke --help
[...]
Documentation
The complete plug-in documentation is available directly in the CLI help:
$ vpype singlestroke --help
Development setup
Here is how to clone the project for development:
$ git clone https://github.com/d-n-l-lab/singlestroke.git
$ cd singlestroke
Create a virtual environment:
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install --upgrade pip
Install singlestroke and its dependencies (including vpype):
$ pip install -e .
$ pip install -r dev-dependencies.txt
License
See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vpype_singlestroke-0.2.0.tar.gz.
File metadata
- Download URL: vpype_singlestroke-0.2.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5da316eb0318f041f1c87a1b243458830c430d0f65bd10edad8c898131eab9b
|
|
| MD5 |
148ab06690f2163a894e17b971b75683
|
|
| BLAKE2b-256 |
04f47b028d5fcff790d20a86cc4ad7424000dc5207b6b4fdc5e066bd42caf391
|
File details
Details for the file vpype_singlestroke-0.2.0-py3-none-any.whl.
File metadata
- Download URL: vpype_singlestroke-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22f2ce7ba33908c757e9d2bb58480d4b1e985586061854b384e10dd1805868f3
|
|
| MD5 |
94e6dd10336a543861b77f9d77d6a389
|
|
| BLAKE2b-256 |
99a55d3a63037cde419e588c5bf81ca5f3440cf689e7b0c2925499ea4a9de892
|