How can I get the Python ezdxf addon text2path to make a single line for single-line fonts?

40 Views Asked by At

I am using a single-line connected font (found here) for CNC purposes. I'm attempting to convert my text into a path with text2path, the ezdxf add-on so that it's portable to my production CNC machines without fonts. This is my program:

import ezdxf
from ezdxf.fonts.fonts import find_font_face
from ezdxf.path import render_lwpolylines
from ezdxf.addons.text2path import make_path_from_str

doc = ezdxf.new("AC1032")
doc.styles.add("IAmOnlineWithU", font="IAmOnlineWithU-o96q.ttf")
msp = doc.modelspace()

p = make_path_from_str("some text", find_font_face("IAmOnlineWithU-o96q.ttf"))
render_lwpolylines(msp, [p])

with open("out.dxf", "w") as f:
    doc.write(f)

The problem I'm having is that I was expecting one single line to come of this, which is required by our process. It should look something like this path:

enter image description here

But what I'm getting is text2path treating the single line of the font as though it has width and tracing a line around it inside and outside. Notice my DXF has double lines everywhere. It's effectively a single-line loop around the single line I want.

enter image description here

How can I tell ezdxf and text2path to trace just the font's single-line connected font path from left to right?

1

There are 1 best solutions below

2
mozman On

This is not possible. The TTF font contains disconnected characters and that is rendered by the text2path add-on.