NextPreviousHomeHas anyone worked with font centerline generation before?



SamSaam | 5 months ago | 6 comments | 1 like | 300 views

songbaojin likes this!

Hi everyone!
I could not found any SVG fonts in my Language, thus
tried to programming a Python tool that converts TTF fonts to single-line SVG fonts.
It is so difficult that i did not believe!!!

Installation Steps:

Make sure you have Python 3.x installed on your system
Install the required Python packages using pip:

pip install fonttools
pip install numpy
pip install Pillow
pip install tqdm

How to Run:

Save the script as hershey-generator.py

Open terminal/command prompt

Basic usage:

python.exehershey-generator.py input.ttf output_folde

Parameters:
input: Your TTF font file or folder containing TTF files
output: Folder where SVG fonts will be saved
Optional parameters:

--tolerance or -t: Path simplification value (default: 2.0)
--width or -w: Output glyph width (default: 1000)
--glyph-height or -gh: Output glyph height (default: 1000)



Example with all parameters:
python hershey-generator.py input.ttf output_folder --tolerance 1.5 --width 800 --glyph-height 800

What the Tool Does:
Converts TTF fonts to single-line SVG fonts
Simplifies font paths
Normalizes glyph sizes
Creates an SVG font file that can be used for BT.

Help Needed - Centerline Conversion:
I want to generate true centerlines for fonts instead of outlines (tested many methods and algorithms).
Currently, it traces the outline of fonts, but for Artistic Result in BT, I need the centerline of each character instead.

Questions:

Has anyone worked with font centerline generation before?

Are there any existing algorithms or libraries for converting font outlines to centerlines (that work in real)?

Would modifying the StrokeExtractor class to calculate centerlines be the right approach?

Any suggestions for handling varying stroke widths in the original font?

Any help or pointers would be greatly appreciated!
Thanks in advance!


Download media files (3.3 KB)

Share this on FacebookShare this on X

It's difficult because many shapes do not have a correct answer. For example, how would you convert a big square? As a small square? Horizontal lines? Vertical lines? Zigzag lines?

There are also cultural aspects: where do you start drawing? And in which direction? There's no logic in this: it's what you've learned at school.

outerspace-software.com...

michiel, 5 months ago


Dear Michiel, you are right, I wrote many many codes and I could not make an optimized single path, Now can you please take the trouble to add a section for Direct SVG vector input for this part?
Because I can use vector softwares and input a complex text, edit and optimize and outputs (a single line) in SVG format. If you take the trouble to import SVG as path, I think our problem (who speak other languages), will be solved.
Thank you

SamSaam, 5 months ago

maybe this is useful for someone,
I changed my python code to get a simple svg and export Hershey Font and put all Line Data of input SVG to character "A" Glyph.
Now when using character "A" and exported stick font we have it in BT.

SamSaam, 5 months ago

ALFA MEGA, Hershey Text is an extension for Inkscape. It does not work with BluffTitler.

But of course, the SVG files it generates can be used in BluffTitler!

wiki.evilmadscientist.com...

michiel, 5 months ago


maybe an AI can do this?

Filip, 5 months ago

SamSaam, when you convert your SVG shape to EPS you can render it with the sketch layer:

outerspace-software.com...

michiel, 5 months ago


Comment to this article

You must be logged in before you can comment to this article. Login | Register

More by SamSaam