From 2c6db3dd9585eba600d46367fe2099101bdc1216 Mon Sep 17 00:00:00 2001 From: Petru Conduraru Date: Tue, 21 Jul 2026 22:35:07 +0300 Subject: [PATCH] SvgSerializer: emit IfcSpace area as a data-area attribute --print-space-areas already computed the IfcSpace area for the visible text label, but did not expose it as a machine-readable attribute on the SVG group, forcing consumers to parse the label text. Reuse the existing per-element data-name/data-guid attribute convention (also namespaced via --svg-xmlns as ifc:area) to carry it. Also fix the area label text double-escaping its "m²" entity: IfcUtil::escape_xml() unconditionally escapes "&", so the pre-encoded entity was turned into the literal "m&#178;" once the label passed through escaping. Emit the raw UTF-8 bytes for U+00B2 instead, which are not affected by XML escaping. Generated with the assistance of an AI coding tool. --- src/serializers/SvgSerializer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/serializers/SvgSerializer.cpp b/src/serializers/SvgSerializer.cpp index 79101dfb67..e44f7e8a07 100644 --- a/src/serializers/SvgSerializer.cpp +++ b/src/serializers/SvgSerializer.cpp @@ -1933,7 +1933,9 @@ void SvgSerializer::write(const geometry_data& data) { const double area = prop.Mass(); std::stringstream ss; ss << std::setprecision(2) << std::fixed << std::showpoint << area; - labels.push_back(ss.str() + "m²"); + // UTF-8 for U+00B2, not an "²" entity, to avoid double-escaping below. + labels.push_back(ss.str() + "m\xc2\xb2"); + po()->first += " " + namespace_prefix_ + "area=\"" + ss.str() + "\""; } util::string_buffer path;