img2bez: Raster-to-Vector Autotracing for Type Design

Eli Heuer
Eli Heuer Posts: 5
edited June 26 in Type Design Software
https://elih.net/blog/img2bez/

I have a new blog post draft explaining the img2bez Rust crate I made for my Runebender forks and the open-source font AI solo startup/project I am working on. This is still a draft I am editing, and I will be running eval loops with AI agents all weekend improving the algorithms. I am posting it here looking for feedback before I publish the final version Monday, any substantial feedback will be credited at the end of the blog post.

I think it is a real breakthrough in this space and gets better results than any existing procedural autotracer, but I am looking for and open to criticism and feedback about why this is not better than existing solutions.

The blog post has an interactive demo of img2bez, compiled from Rust to WASM. So you can try it right in the blog post and even drag your own glyph images into the demo to trace them.

Comments

  • John Hudson
    John Hudson Posts: 3,713
    edited June 26
    Hi Eli. Do you have any recommendations for input image to get best results. I did a quick test with this image:

    and the results are pretty bad:


  • ericlu
    ericlu Posts: 18
    I've tried it on a few glyphs and I'm not sure I'm seeing it significantly improve results over the native potrace. is it trained to work on specific types of fonts? Here is a comparison of the native traced glyphs and then the img2bez traced glyph below:




    Here's also a comparison of the two fonts (first traced with potrace and some cleanup, second traced with img2bez)
    1. https://static.mixfont.com/assets/20260626-184828-gothicgumdrop-regular-blz2sd9n.ttf
    2. https://static.mixfont.com/assets/20260626-184825-gothicgumdrop-regular-img2bez-opl2uqy9.ttf

    I'm personally very interested in this as my recent font submission to Google fonts was denied not due to AI generation policies or the design of the font but rather due to outline tracing quality. If there was a way to improve the tracing so that the submission could be improved, it would be very helpful. 
  • John Hudson
    John Hudson Posts: 3,713
    While neither outline is great, the one produced by Eli’s tool has done a better job placing on curve points at extrema, while the potrace example has long and inflected curves without any on curve points, e.g.


    My impression is that Eli’s approach to structured outlines is heading in the right direction, but still suffering in the shape fidelity department as per my test.

  • Simon Cozens
    Simon Cozens Posts: 850
    Here's GlyphTracy's effort:



    I think img2bez is pretty good - certainly better than potrace/autotrace. Working out what is image noise and what is desirable signal is a tricky problem. (We get a faithful reproduction of the pinch at the top left, but we don't get a faithful reproduction of the blobbyness of the outer curve on the top right. How does a computer know what is wanted and what is unwanted?) Doing so automatically, without having a human in the loop to manually tweak the settings, is extremely tricky.
  • John Hudson
    John Hudson Posts: 3,713
    Instinctively, I think it must be necessary to average out wobbliness over the length of a curve, in order to capture the signal under the noise —, and this means being able to segment beginnings and ends of curves, which is where extrema identification and marking comes in useful at the trace stage and not just as a nicety of final font outlines. This suggests something iterative: first identifying where extrema or inflection points are, which may involve some averaging also to account for noise around those locations, and then averaging of the path between those locations to come up with curves or lines having the minimal number of points.

    It looks like GlyphTracy is doing something like this. Where it is running into difficulties seems to be at corners and flex locations, e.g. fragment points #16 and #15 in your image.
  • Dave Crossland
    Dave Crossland Posts: 1,557
    These seem better than what a rank beginner can do, but far from what a typical person can do after a 5 day, 8h day, "introduction to type design" workshop can do... :) 
  • Ray Larabie
    Ray Larabie Posts: 1,495
    My old Scanfont 3.13 still works in the current version of Windows. I still use it when I need to autotrace something. You have to export 1-bit bmp from Photoshop with the colors inverted.