mozman / ezdxf

Python interface to DXF
https://ezdxf.mozman.at
MIT License
927 stars 190 forks source link

shx files are not loaded when configured in support_dirs config in ./ezdxf.ini #899

Closed kishok closed 1 year ago

kishok commented 1 year ago

Description:

I tried to load shx files used in AutoCAD downloaded from a free shx fonts website placed in my working directory (shx-fonts), as per doc i configured in ezdxf.ini config file in current working directory but it didn't load the shape font files for converting dxf file to svg it throws error and stuck in the terminal

findfont: Font family 'ScriptC' not found. findfont: Font family 'romand' not found. findfont: Font family 'romanc' not found.

#ezdxf.ini
[core]
support_dirs = ~/shx-fonts     
#dxf2svg.py
import os
import matplotlib.pyplot as plt
import ezdxf 
from ezdxf.addons.drawing import RenderContext, Frontend
from ezdxf.addons.drawing.matplotlib import MatplotlibBackend

doc = ezdxf.readfile('sample.dxf')
fig = plt.figure()
out = MatplotlibBackend(fig.add_axes([0, 0, 1, 1]))
Frontend(RenderContext(doc), out).draw_layout(doc.modelspace(), finalize=True)
fig.savefig(os.path.join("." , "output.svg")) 

Expected Behaviour:

It should load shx-fonts dir on edzdxf initialize and render the dxf file.

mozman commented 1 year ago
  1. There exists no free SHX fonts files, they are all copyrighted and all those websites have no license to distribute them. For some reasons they just don't get sued by Autodesk. Example "scriptx.shx" from the provided "fonts.zip": SCRIPTC Copyright 1996 by Autodesk, Inc.. Therefore I removed the link to this website from your post - I don't want any troubles with Autodesk!
  2. SHX fonts are only supported in the upcoming v1.1 release
  3. When you add new fonts to your system you have to rebuild the font-cache. I will clarify this in the documentation of the fonts module.
import ezdxf
from ezdxf.tools import fonts

fonts.build_system_font_cache()

or call the ezdxf launcher:

C:\> ezdxf -f