From f4172885428f9849ff29bd09490db8b167a8d705 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Wed, 3 Nov 2021 07:09:16 +0200 Subject: Redo cached document layout if needed Changing the fonts, zoom level, or window width will cause cached documents to be laid out again if they are restored from memory. --- src/ui/documentwidget.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/ui/documentwidget.c') diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 79bfea7b..8c24d4a9 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -1702,6 +1702,7 @@ static void updateDocument_DocumentWidget_(iDocumentWidget *d, } if (cachedDoc) { replaceDocument_DocumentWidget_(d, cachedDoc); + updateWidth_GmDocument(d->doc, documentWidth_DocumentWidget_(d), width_Widget(d)); } else if (setSource) { setSource_DocumentWidget(d, &str); @@ -2498,7 +2499,7 @@ static iBool updateDocumentWidthRetainingScrollPosition_DocumentWidget_(iDocumen /* TODO: First *fully* visible run? */ voffset = visibleRange_DocumentWidget_(d).start - top_Rect(run->visBounds); } - setWidth_GmDocument(d->doc, newWidth, (width_Widget(d) - newWidth) / 2); + setWidth_GmDocument(d->doc, newWidth, width_Widget(d)); setWidth_Banner(d->banner, newWidth); documentRunsInvalidated_DocumentWidget_(d); if (runLoc && !keepCenter) { @@ -2734,6 +2735,9 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) } else if (equal_Command(cmd, "window.resized") || equal_Command(cmd, "font.changed") || equal_Command(cmd, "keyroot.changed")) { + if (equal_Command(cmd, "font.changed")) { + invalidateCachedLayout_History(d->mod.history); + } /* Alt/Option key may be involved in window size changes. */ setLinkNumberMode_DocumentWidget_(d, iFalse); d->phoneToolbar = findWidget_App("toolbar"); -- cgit v1.2.3