fix: correct MTEXT line spacing and preserve blank paragraph separators

Line spacing: DXF code 44 (line_spacing_factor) is a multiplier on
AutoCAD's default baseline-to-baseline distance of 5/3 × text_height.
The renderer was using factor × 1.0 instead of factor × 1.667, making
all MTEXT appear cramped.

Blank paragraphs: split_mtext_lines was filtering out empty strings, so
\\P\\P (double paragraph break used to separate sections) was silently
collapsed. Empty lines in the middle of the block are now preserved;
only leading/trailing blank lines are stripped.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-05-01 11:48:06 +03:00
commit c5c5ba1b60
2 changed files with 11 additions and 4 deletions

View file

@ -99,7 +99,10 @@ fn to_truck(t: &MText, document: &acadrust::CadDocument) -> TruckEntity {
} else {
1.0
};
let line_h = t.height as f32 * ls_factor * font.line_spacing;
// AutoCAD DXF code 44 is a multiplier on the *default* baseline-to-baseline
// distance, which is 5/3 × text_height (≈ 1.667). factor = 1.0 → single
// spacing, factor = 2.0 → double spacing, etc.
let line_h = t.height as f32 * ls_factor * (5.0 / 3.0) * font.line_spacing;
let total_h = line_h * n_lines;
let v_offset = match t.attachment_point {
AttachmentPoint::TopLeft | AttachmentPoint::TopCenter | AttachmentPoint::TopRight => 0.0,