Skip to content

Commit 04a6f20

Browse files
jiefeng-xuCarlos Cabanero
authored andcommitted
Fix font persistence in Lockdown mode
Keep bundled font selections active in Lockdown mode while still blocking non-bundled custom fonts. Also remove the JS-side unconditional monospace override that was resetting the selected font on tab/app reopen. Fixes #2137.
1 parent d3629ad commit 04a6f20

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

Blink/TermView.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,10 @@ - (WKUserScript *)_termInitScriptWith:(MCPParams *)params;
831831
{
832832
NSMutableArray *script = [[NSMutableArray alloc] init];
833833
BOOL lockdownMode = [[NSUserDefaults.standardUserDefaults objectForKey:@"LDMGlobalEnabled"] boolValue];
834-
BKFont *font = lockdownMode ? nil : [BKFont withName: params.fontName ?: [BLKDefaults selectedFontName]];
835-
NSString *fontFamily = font.name;
834+
BKFont *selectedFont = [BKFont withName: params.fontName ?: [BLKDefaults selectedFontName]];
835+
// In Lockdown mode, keep bundled fonts but disable non-bundled ones.
836+
BKFont *font = (lockdownMode && selectedFont.isCustom) ? nil : selectedFont;
837+
NSString *fontFamily = font.name ?: (lockdownMode ? @"monospace" : nil);
836838
NSString *content = font.content;
837839
if (font && font.isCustom && content) {
838840
[script addObject:term_appendUserCss(content)];

Resources/term.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ function term_init(accessibilityEnabled, lockdownMode) {
154154
// document.body.style.backgroundColor = bgColor;
155155
// document.body.parentNode.style.backgroundColor = bgColor;
156156
if (lockdownMode) {
157-
term_set('font-family', 'monospace');
158157
term_setup(accessibilityEnabled);
159158
} else {
160159
waitForFontFamily(term_setup);

0 commit comments

Comments
 (0)