Skip to main content

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-width or -w: Width of the stroke (default: 50.0)
  • --join-style or -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

  1. Path parsing: Extracts coordinates from SVG path commands (M, L, H, V, C, Q, T)
  2. Offset calculation: Creates perpendicular offsets for each line segment
  3. 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 script
  • PremiumUltra87v6_closed.svg: Your converted font file
  • README.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.

Metadata

Release files for vpype-singlestroke 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vpype-singlestroke 0.2.0
File Size Uploaded
vpype_singlestroke-0.2.0.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vpype-singlestroke 0.2.0
File Interpreter ABI Platform
vpype_singlestroke-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.7 kB

Release files / vpype_singlestroke-0.2.0.tar.gz

Download URL vpype_singlestroke-0.2.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c5da316eb0318f041f1c87a1b243458830c430d0f65bd10edad8c898131eab9b
BLAKE2b-256 checksum
How to use checksums
04f47b028d5fcff790d20a86cc4ad7424000dc5207b6b4fdc5e066bd42caf391
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.6

Release files / vpype_singlestroke-0.2.0-py3-none-any.whl

Download URL vpype_singlestroke-0.2.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22f2ce7ba33908c757e9d2bb58480d4b1e985586061854b384e10dd1805868f3
BLAKE2b-256 checksum
How to use checksums
99a55d3a63037cde419e588c5bf81ca5f3440cf689e7b0c2925499ea4a9de892
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page