From ae382f6b120c5a54a4662d658102f89caba61566 Mon Sep 17 00:00:00 2001 From: Shane Ringrose Date: Fri, 12 Jun 2026 23:00:20 +1200 Subject: [PATCH] parttext: re-anchor on font change so text position is stable across save/reopen (#158) --- sources/editor/graphicspart/parttext.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sources/editor/graphicspart/parttext.cpp b/sources/editor/graphicspart/parttext.cpp index 1aeac81cf..4b2134443 100644 --- a/sources/editor/graphicspart/parttext.cpp +++ b/sources/editor/graphicspart/parttext.cpp @@ -313,6 +313,12 @@ void PartText::setPlainText(const QString &text) { void PartText::setFont(const QFont &font) { if (font != this -> font()) { QGraphicsTextItem::setFont(font); + // Re-anchor: the item's position transform is -margin(), and margin() + // depends on the font ascent. Without re-running this on a font change, + // the transform keeps the previous font's ascent — so the text renders + // at a different spot after save/reopen (the position recomputes from + // the saved font on load). See #158. + adjustItemPosition(); emit fontChanged(font); } }