Why won't a custom font work with ezdxf on Ubuntu?

53 Views Asked by At

I am running this test program.

import ezdxf

doc = ezdxf.new("AC1032")
doc.styles.add("IAmOnlineWithU", font="IAmOnlineWithU-o96q.ttf")
msp = doc.modelspace()
t = msp.add_text("TEST TEXT", height=1, dxfattribs = {"style": "IAmOnlineWithU"})
t.set_placement((0,0))
with open("out.dxf", "w") as f:
    doc.write(f)

I am hoping to use this single-line connected font I found to draw the text for CNC purposes, but when I do this, the font seems to have no effect. Some default font is used.

I am using Ubuntu 23.10, and I have installed the font which I found here on my system. Here is the output of my font list command fc-list | grep IAm :

/home/mmachenry/.local/share/fonts/IAmOnlineWithU-o96q.ttf: I am online with u:style=line

So it seems like it should be found. I checked ezdxf's docs on where it looks for these fonts and .local/share/fonts was one of them.

I have tried adding this to my code and it had not effect:

from ezdxf.fonts import fonts
fonts.build_system_font_cache()

I'm able to find the font in my system through the ezdxf Python package as well. This is a python REPL sessions showing that:

>>> from ezdxf.fonts.fonts import find_font_face
>>> f = find_font_face("IAmOnlineWithU-o96q.ttf")
>>> f.family
'I am online with u'

I'm wondering if this could actually be made to be a local to the repository search so I don't have to install it on my machine but that's a different question.

edit: I should also add that I am using LibreCAD to view the resultant DXF and I have added my local font directory setup properly in the Application Settings.

0

There are 0 best solutions below