mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-06-13 16:23:14 +02:00
Merge pull request #501 from ispyisail/fix-parttext-position-158
PartText: keep text position stable across save/reopen on font-size change (#158)
This commit is contained in:
@@ -313,6 +313,12 @@ void PartText::setPlainText(const QString &text) {
|
|||||||
void PartText::setFont(const QFont &font) {
|
void PartText::setFont(const QFont &font) {
|
||||||
if (font != this -> font()) {
|
if (font != this -> font()) {
|
||||||
QGraphicsTextItem::setFont(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);
|
emit fontChanged(font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user