Skip to content

Read error in dxf_input.py when DXF text entity has only one newline at the end of line

Steps to reproduce:

  • open Inkscape
  • read attached dxffile which contains a text entity
  • The snapshot below is from when I opened it in TurboCad-Japanese.
  • open_dxf_turbocad

What happened?

Read error in dxf_input.py when DXF text entity has only one newline at the end of line.

  • the following read error occurs
 Traceback (most recent call last):
  File "C:\Program Files\Inkscape\share\inkscape\extensions\dxf_input.py", line 1636, in <module>
    DxfInput().run()
  File "C:\Program Files\Inkscape\share\inkscape\extensions\inkex\base.py", line 231, in run
    self.save_raw(self.effect())
  File "C:\Program Files\Inkscape\share\inkscape\extensions\dxf_input.py", line 1550, in effect
    exporter(vals)
  File "C:\Program Files\Inkscape\share\inkscape\extensions\dxf_input.py", line 553, in export_mtext
    mtext_separate(node, tspan, text1)
  File "C:\Program Files\Inkscape\share\inkscape\extensions\dxf_input.py", line 594, in mtext_separate
    mtext_ctrl(tspan, text1)
  File "C:\Program Files\Inkscape\share\inkscape\extensions\dxf_input.py", line 619, in mtext_ctrl
    if phrase[0] != "\\":
 IndexError: string index out of range

It seems to me that the constructor of mtext on line 619 of dxf_input.py is causing an error.

This DXF file contains the following contents:

----dxf Line 1501-1518 ----
100
 AcDbMText
  10
 11.0343887787
  20
 8.8307648232
  30
 0.0
  40
 3.90625
  41
 55.027183913
  71
      1
  72
      1
   1
 {next line is a blank line\P}
----

This error only occurs when there is "one" "\P" at the end of the last line.

It didn't happen when there were "two" "\P" at the end of the sentence, even when it was at the beginning or in the middle of the sentence.

What should have happened?

I want the text to be displayed.

Inkscape Version and Operating System:

  • Inkscape Version: Inkscape 1.2.1 (9c6d41e410, 2022-07-14)

    GLib version: 2.72.2 GTK version: 3.24.34 glibmm version: 2.66.4 gtkmm version: 3.24.6 libxml2 version: 2.9.14 libxslt version: 1.1.35 Cairo version: 1.17.6 Pango version: 1.50.7 HarfBuzz version: 4.4.1

    OS version: Windows 10 21H2

one_blankline_at_the_end.dxf

Edited by tamon kobayashi
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information