From d2cfc0e33d6749fd10faf00d7a52613ed75f5320 Mon Sep 17 00:00:00 2001 From: Thomas Lin Pedersen Date: Tue, 22 Oct 2024 15:57:44 +0200 Subject: [PATCH] Better flush logic --- src/SvgStream.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/SvgStream.h b/src/SvgStream.h index 88ce99c..ea3b5a0 100644 --- a/src/SvgStream.h +++ b/src/SvgStream.h @@ -125,13 +125,19 @@ class SvgStreamFile : public SvgStream { if (!always_valid) { return; } - - stream_ << "\n"; #ifdef _WIN32 - stream_.seekp(-12, std::ios_base::cur); + int offset = -12; #else - stream_.seekp(-11, std::ios_base::cur); + int offset = -11; #endif + + if (is_clipping()) { + // We don't do newline here just to avoid having to deal with windows + stream_ << ""; + offset -= 4; + } + stream_ << "\n"; + stream_.seekp(offset, std::ios_base::cur); } void finish(bool close) {