Skip to content

Commit 50a60f1

Browse files
Fix: Measurement text invisible in SVG export due to white color
Measurements in OpenWebCAD use a default line color of white. When exporting to SVG, the SvgDrawController correctly changes white lines and fills to black for visibility against the SVG's white background. However, the text color for measurements was passed directly to the SVG text element. If the measurement color was white (default), the text would be white on a white background, rendering it invisible. This commit modifies the `SvgDrawController.drawText` method to check if the incoming text color is white. If it is, the color is changed to black ('#000') before rendering the SVG text element. Other colors are unaffected, ensuring they appear as intended in the SVG output.
1 parent 9bd1f8b commit 50a60f1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/drawControllers/svg.drawController.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,17 @@ export class SvgDrawController implements DrawController {
211211
...options,
212212
};
213213

214+
let finalTextColor = textOptions.textColor;
215+
const lowerCaseTextColor = textOptions.textColor.toLowerCase();
216+
if (lowerCaseTextColor === '#fff' || lowerCaseTextColor === '#ffffff' || lowerCaseTextColor === 'white') {
217+
finalTextColor = '#000'; // Change to black if current color is white
218+
}
219+
// No need to handle black to white, as SVG background is white.
220+
// Other colors will remain as they are.
221+
214222
this.svgStrings.push(
215-
`<text x="${canvasBasePoint.x}" y="${canvasBasePoint.y}" fill="${textOptions.textColor}" font-size="${textOptions.fontSize}" font-family="${textOptions.fontFamily}">${label}</text>`
223+
// Use finalTextColor here
224+
`<text x="${canvasBasePoint.x}" y="${canvasBasePoint.y}" fill="${finalTextColor}" font-size="${textOptions.fontSize}" font-family="${textOptions.fontFamily}">${label}</text>`
216225
);
217226
}
218227

0 commit comments

Comments
 (0)