Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complex MText.text with only a whitespace raises ValueError("invalid width, no usable space left") #830

Closed
jsimomaa opened this issue Feb 9, 2023 · 0 comments

Comments

@jsimomaa
Copy link

jsimomaa commented Feb 9, 2023

Describe the bug
Trying to draw a DXF file fails with a ValueError("invalid width, no usable space left"):

loading file "mtext_empty.dxf"...
findfont: Font family ['dgn000'] not found. Falling back to DejaVu Sans.
Traceback (most recent call last):
  File "/home/vscode/.local/bin/ezdxf", line 8, in <module>
    sys.exit(main())
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/__main__.py", line 98, in main
    run(args)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/commands.py", line 390, in run
    frontend.draw_layout(layout, finalize=True)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/addons/drawing/frontend.py", line 242, in draw_layout
    self.draw_entities(
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/addons/drawing/frontend.py", line 259, in draw_entities
    _draw_entities(self, self.ctx, entities, filter_func=filter_func)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/addons/drawing/frontend.py", line 1030, in _draw_entities
    frontend.draw_entity(entity, properties)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/addons/drawing/frontend.py", line 278, in draw_entity
    draw_method(entity, properties)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/addons/drawing/frontend.py", line 359, in draw_mtext_entity
    self.draw_complex_mtext(mtext, properties)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/addons/drawing/frontend.py", line 372, in draw_complex_mtext
    complex_mtext_renderer(self.ctx, self._designer, mtext, properties)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/addons/drawing/mtext_complex.py", line 185, in complex_mtext_renderer
    layout_engine = cmr.layout_engine(mtext)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/render/abstract_mtext_renderer.py", line 294, in layout_engine
    append_paragraph()
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/render/abstract_mtext_renderer.py", line 245, in append_paragraph
    layout.append_paragraphs([paragraph])
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/tools/text_layout.py", line 1265, in append_paragraphs
    remainder = column.append_paragraphs(remainder)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/tools/text_layout.py", line 1135, in append_paragraphs
    paragraph.set_total_width(self.content_width)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/tools/text_layout.py", line 873, in set_total_width
    raise ValueError("invalid width, no usable space left")
ValueError: invalid width, no usable space left

To Reproduce

ezdxf draw mtext_empty.dxf

Version info:

$ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
$ python -VV
Python 3.10.9 (main, Jan 23 2023, 22:32:48) [GCC 10.2.1 20210110]
$ pip show ezdxf
Name: ezdxf
Version: 1.0.1
Summary: A Python package to create/manipulate DXF drawings.
Home-page: https://ezdxf.mozman.at
Author: Manfred Moitzi
Author-email: me@mozman.at
License: MIT License
Location: /home/vscode/.local/lib/python3.10/site-packages
Requires: pyparsing, typing-extensions
Required-by: 

Please find attached simplified mtext_empty.dxf.zip DXF that triggers the error:
mtext_empty.dxf.zip

Expected behavior
Drawing would appear with empty mtext like with QCAD:
image

@mozman mozman closed this as completed in 4660d67 Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant