I am using matplotlib and ezdxf to convert a dxf to a png file.
When viewing AutoCAD (viewer.autodesk.com) i get this result:
When i call my python fn i get this:

Python code
import matplotlib as mpl
import matplotlib.pyplot as plt
from ezdxf.addons.drawing import RenderContext, Frontend
from ezdxf.addons.drawing.matplotlib import MatplotlibBackend
import matplotlib.font_manager as font_manager
import re
mpl.use('Agg')
default_img_format = '.png'
default_img_res = 300
default_bg_color = '#FFFFFF'
def convert_dxf2img(dxfFile, imgFormat=default_img_format, imgRes=default_img_res, clr=default_bg_color):
doc = ezdxf.readfile(dxfFile)
msp = doc.modelspace()
auditor = doc.audit()
if len(auditor.errors) != 0:
raise Exception("This DXF document is damaged and can't be converted! --> ", dxfFile)
else :
fig = plt.figure()
ax = fig.add_axes([0, 0, 1, 1])
ctx = RenderContext(doc)
ctx.set_current_layout(msp)
ezdxf.addons.drawing.properties.MODEL_SPACE_BG_COLOR = clr
out = MatplotlibBackend(ax)
Frontend(ctx, out).draw_layout(msp, finalize=True)
imgName = re.findall("(\S+)\.",dxfFile)
fullPath = ''.join(imgName) + imgFormat
fig.savefig(fullPath, dpi=imgRes)
return fullPath
font_manager.get_font_names() includes 'Arial' or 'Comic Sans MS'
