forked from 1b-agent/opencadstudio-upstream
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:
1 parent
fc0aa8698b
commit
c5c5ba1b60
2 files changed
+11
-4
No files matched your search
@@ -206,10 +206,14 @@ pub fn strip_mtext_codes(s: &str) -> String {
|
||||
}
|
||||
|
||||
pub fn split_mtext_lines(s: &str) -> Vec<String> {
|
||||
s.split('\n')
|
||||
let lines: Vec<String> = s.split('\n')
|
||||
.map(|l| l.trim().to_string())
|
||||
.filter(|l| !l.is_empty())
|
||||
.collect()
|
||||
.collect();
|
||||
// Drop leading and trailing blank lines, but preserve blank lines in the
|
||||
// middle — they are intentional paragraph separators (\\P\\P in MTEXT).
|
||||
let start = lines.iter().position(|l| !l.is_empty()).unwrap_or(0);
|
||||
let end = lines.iter().rposition(|l| !l.is_empty()).map(|i| i + 1).unwrap_or(0);
|
||||
lines[start..end].to_vec()
|
||||
}
|
||||
|
||||
/// Measure the advance width of an MText line (after strip_mtext_codes), correctly
|
||||
|
||||
Reference in new issue
Block a user