Skip to content

Keep zero-length dashes as points in the C linetype renderer - #1483

Merged
mozman merged 1 commit into
mozman:masterfrom
zzoraemon043:fix/c-linetype-zero-length-dash
Nov 22, 2026
Merged

mozman merged 1 commit into
mozman:masterfrom
zzoraemon043:fix/c-linetype-zero-length-dash

Conversation

@zzoraemon043

Copy link
Copy Markdown
Contributor

The C version of _LineTypeRenderer stores a gap as a negative length and yields only lengths > 0. A dash of length 0 is a point, but the C version drops it. The Python version yields it as a point.

import ezdxf
from ezdxf.addons.drawing import Frontend, RenderContext
from ezdxf.addons.drawing.config import Configuration
from ezdxf.addons.drawing.recorder import Recorder

doc = ezdxf.new(setup=True)
msp = doc.modelspace()
msp.add_line((0, 0), (10, 0), dxfattribs={"linetype": "DOT"})
rec = Recorder()
Frontend(RenderContext(doc), rec, config=Configuration(min_dash_length=0)).draw_layout(msp)
print(sum(len(r.lines) // 2 for r in rec.records if hasattr(r, "lines")))
  • C extension: 0 (the line is not drawn)
  • EZDXF_DISABLE_C_EXT=1: 20 points

The fix stores the dash/gap flag with each length. After the fix, the C version also gives 20.

The new tests run with both versions. Without the fix, 2 tests fail for the C version. pytest tests: all pass.

@mozman

mozman commented Nov 22, 2026

Copy link
Copy Markdown
Owner

But be careful: you should not use min_dash_length = 0; some backends cannot render lines of zero length (e.g., matplotlib), and in practice, true points are often impossible to see anyway.

@mozman
mozman merged commit 36c0dd6 into mozman:master Nov 22, 2026
12 checks passed
@zzoraemon043

Copy link
Copy Markdown
Contributor Author

Noted, the default 0.1 stays. Thanks for merging

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

Successfully merging this pull request may close these issues.

2 participants