fix(mtext): treat the 0x02 background-fill flag as a mask over 0x01

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 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-07-18 15:23:03 +03:00
1 parent 958c06ffe0
commit bf85896294
1 file changed
+10 -3
+10 -3
View File
@@ -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);