From 7fac22da88b373af31a6a9cf256d2bb59884bbc7 Mon Sep 17 00:00:00 2001 From: Louis Vignier Date: Thu, 15 Jan 2026 18:01:14 +0100 Subject: [PATCH] IJPL-224591 ui: restore selected variants when changing font #IJPL-224591 Fixed GitOrigin-RevId: c89e2c4f35e0731ad9a0282567e30dd131baa46e --- .../options/editor/fonts/AppFontOptionsPanel.kt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/application/options/editor/fonts/AppFontOptionsPanel.kt b/platform/platform-impl/src/com/intellij/application/options/editor/fonts/AppFontOptionsPanel.kt index e9997db45b78..fda22058f51f 100644 --- a/platform/platform-impl/src/com/intellij/application/options/editor/fonts/AppFontOptionsPanel.kt +++ b/platform/platform-impl/src/com/intellij/application/options/editor/fonts/AppFontOptionsPanel.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.application.options.editor.fonts import com.intellij.application.options.colors.AbstractFontOptionsPanel @@ -37,11 +37,13 @@ open class AppFontOptionsPanel(private val scheme: EditorColorsScheme) : Abstrac private var variantsPlaceholder: Placeholder? = null private var currentFont: String? = null private val currentFeatures: MutableMap = mutableMapOf() + private val recentFeatures: MutableMap> = mutableMapOf() private val fontGlyphCache: FontGlyphHashCache = FontGlyphHashCache() init { addListener(object : ColorAndFontSettingsListener.Abstract() { override fun fontChanged() { + restoreSelectedVariants() updateFontPreferences() } }) @@ -174,6 +176,16 @@ open class AppFontOptionsPanel(private val scheme: EditorColorsScheme) : Abstrac } } + private fun restoreSelectedVariants() { + // Save previous variants + currentFont?.let { font -> recentFeatures[font] = currentFeatures.filter { (_, value) -> value.isSelected }.keys.toSet() } + // Restore variants for fontPreferences.fontFamily + val previousFeatures = recentFeatures[fontPreferences.fontFamily] + if (previousFeatures != null && fontPreferences.characterVariants != previousFeatures) { + (fontPreferences as ModifiableFontPreferences).characterVariants = previousFeatures + } + } + protected open fun createCustomComponent() : JComponent? = null private fun Panel.createTypographySettings() {