Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gerber: convert font glyphs directly #1568

Open
davidperrenoud opened this issue Aug 25, 2014 · 6 comments
Open

gerber: convert font glyphs directly #1568

davidperrenoud opened this issue Aug 25, 2014 · 6 comments

Comments

@davidperrenoud
Copy link
Contributor

From irasc...@gmail.com on July 14, 2011 05:26:41

Instead of rasterizing fonts, figure out how to convert the font glyphs directly, or somehow attach to Qt's font engine...

Original issue: http://code.google.com/p/fritzing/issues/detail?id=1568

@davidperrenoud
Copy link
Contributor Author

From irasc...@gmail.com on July 14, 2011 22:49:57

in general, the more svg elements we can convert directly, rather than going through raster conversion, the better

@davidperrenoud
Copy link
Contributor Author

From irasc...@gmail.com on July 14, 2011 22:50:53

or sticking with rasterizing, would it be possible to do just the fonts at a higher res?

@davidperrenoud
Copy link
Contributor Author

From irasc...@gmail.com on July 16, 2011 14:37:52

an technique called distance-mapping might work as a fast way to convert a given svg vector to a raster: http://labs.qt.nokia.com/2011/07/15/text-rendering-in-the-qml-scene-graph/

@davidperrenoud
Copy link
Contributor Author

From irasc...@gmail.com on July 19, 2011 15:51:35

QPainterPath has an addText function which takes a QFont. The resulting path is composed of moveTo, lineTo, curveTo. One would have to approximate the curves (both cubic and quadratic bezier) with circular arcs.

There is a paper about the cubic bezier approximation at http://itc.ktu.lt/itc354/Riskus354.pdf , also see http://www.cosy.sbg.ac.at/~helmut/Teaching/SEDissertanten/program.pdf , and http://cgcad.thss.tsinghua.edu.cn/~yongjh/papers/cad2000v32n4p253.pdf

@davidperrenoud
Copy link
Contributor Author

From irasc...@gmail.com on July 20, 2011 03:22:49

QPainterPath also has a number of path-to-polygon conversion functions, so depending on how closely these curves are converted, it might be possible to use these directly. This could also be the means for converting elliptical arcs--because QPainterPath's arcTo is elliptical.

@KjellMorgenstern
Copy link
Member

KjellMorgenstern commented Sep 17, 2023

A while ago I made some progress on this.
I have experimented with single line fonts from https://k40lasercutter.com , and was able to render them into svg paths from the Qt font engine.
In a separate experiment, we can turn svg paths into gerber quite reliably, by interpolating Béziers with arcs, usually a few (less than ten) arcs are enough for one Bezier. This is recursive, meaning we just split the Bézier into arcs until we have reached an approximation with a desired maximum error.
In the long term this will benefit gerber formats, and enable CNCed or additive (3d printed) texts.
We have also prepared a custom single line font that can be added to Fritzing under SIL OFL. The ones from k40 are usually commercial, and I was not able to reach anyone there to ask for a cooperation, probably got lost in their inbox.
Still, this is kind of a fun project. Because there are too many mundane (and important) problems in Fritzing, it will take more time and releases until solving this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants