fix(dim): keep dim line continuous when text sits above/below it

The dim-line break test used text_half + DIMGAP as its vertical
threshold, but DIMTAD 1/4 places the text exactly text_half + DIMGAP off
the line. The two terms cancel at the same DIMSCALE-scaled value, leaving
the comparison on the knife's edge — so a gap flickered into the line
depending on the DIMGAP/DIMSCALE combination. Drop DIMGAP from the
vertical threshold so above/below text stays strictly clear and the line
stays whole; centred text (DIMTAD 0) still breaks for the DIMTFILL
background. The horizontal half-width keeps DIMGAP so a real break clears
the text. (#94)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-18 21:09:56 +03:00
1 parent 188d310789
commit 23844c137b
1 file changed
+9 -1
+9 -1
View File
@@ -1017,7 +1017,15 @@ fn tessellate_dimension_inner(
.map(|t| t.chars().count() as f32 * dim_txt as f32 * 0.6)
.unwrap_or(0.0);
if tw > 0.0 {
Some((tp, tw * 0.5 + dimgap_local, dim_txt as f32 * 0.5 + dimgap_local))
// Vertical threshold is the bare text half-height (no DIMGAP): the
// line only breaks when it actually passes under the glyphs. Text
// placed above/below the line (DIMTAD 1/4) sits exactly
// `text_half + DIMGAP` away, so excluding the gap here keeps it
// strictly outside and the line continuous — otherwise the two
// terms cancel at the same scaled value and the gap flickers with
// DIMGAP/DIMSCALE. The horizontal half-width keeps DIMGAP so a
// genuine break still clears the text comfortably. (#94)
Some((tp, tw * 0.5 + dimgap_local, dim_txt as f32 * 0.5))
} else {
None
}