From bf8589629450852cc8a1f6d96371261e57b7963b Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Sat, 18 Jul 2026 15:23:03 +0300 Subject: [PATCH] fix(mtext): treat the 0x02 background-fill flag as a mask over 0x01 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MTEXT background fill flag 0x02 means "use the drawing-window colour" — a mask that erases geometry behind the text — while 0x01 means "paint background_color". The fill-colour pick tested 0x01 first, so text flagged 0x03 (both bits, e.g. a dimension whose DIMTFILL is the drawing background) painted the stored background_color (a stray grey box) instead of masking. AutoCAD shows no colour there. Test 0x02 first: when set, fill with the drawing-window colour (invisible on a matching canvas) regardless of 0x01; a plain 0x01 fill still paints its colour. Co-Authored-By: Claude Opus 4.8 --- src/scene/convert/tessellate.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/scene/convert/tessellate.rs b/src/scene/convert/tessellate.rs index 265192e3c..7c4245e52 100644 --- a/src/scene/convert/tessellate.rs +++ b/src/scene/convert/tessellate.rs @@ -638,10 +638,17 @@ pub fn tessellate( ); // Fill / mask — two triangles behind the glyphs. if has_fill { - let fill_color = if m.background_fill_flags & 0x01 != 0 { - color_or_inherit(&m.background_color, bg_color) - } else { + // 0x02 (use the drawing-window colour) is a + // MASK — it wins when set, even alongside + // 0x01, so text flagged "drawing background" + // erases what's behind it (a dark box on a + // dark canvas = no visible colour), instead + // of painting the stored background_color. A + // plain 0x01 fill paints that colour. + let fill_color = if m.background_fill_flags & 0x02 != 0 { bg_color + } else { + color_or_inherit(&m.background_color, bg_color) }; let corners = [[l, b], [r, b], [r, t], [l, t]]; let mut ft = Vec::with_capacity(6);