mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-06-09 17:41:36 +00:00
Merge branch 'clear-font-caches-on-reload' of https://github.com/zzhaolei/kitty
Some checks are pending
CI / Linux (python=3.13 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.11 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Some checks are pending
CI / Linux (python=3.13 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.11 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
This commit is contained in:
commit
cf5c180a01
5 changed files with 30 additions and 0 deletions
|
|
@ -3200,6 +3200,8 @@ class Boss:
|
|||
opts = load_config(*paths, overrides=final_overrides or None, accumulate_bad_lines=bad_lines)
|
||||
if bad_lines:
|
||||
self.show_bad_config_lines(bad_lines)
|
||||
from .fonts.render import clear_font_caches
|
||||
clear_font_caches()
|
||||
self.apply_new_options(opts)
|
||||
from .open_actions import clear_caches
|
||||
clear_caches()
|
||||
|
|
|
|||
|
|
@ -65,6 +65,13 @@ else:
|
|||
|
||||
|
||||
cache_for_variable_data_by_path: dict[str, VariableData] = {}
|
||||
|
||||
|
||||
def clear_caches() -> None:
|
||||
cache_for_variable_data_by_path.clear()
|
||||
actually_variable_cache.clear()
|
||||
|
||||
|
||||
attr_map = {(False, False): 'font_family', (True, False): 'bold_font', (False, True): 'italic_font', (True, True): 'bold_italic_font'}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,11 @@ def create_font_map(all_fonts: Iterable[CoreTextFont]) -> FontMap:
|
|||
return ans
|
||||
|
||||
|
||||
def clear_caches() -> None:
|
||||
all_fonts_map.cache_clear()
|
||||
weight_range_for_family.cache_clear()
|
||||
|
||||
|
||||
@lru_cache(maxsize=2)
|
||||
def all_fonts_map(monospaced: bool = True) -> FontMap:
|
||||
return create_font_map(coretext_all_fonts(monospaced))
|
||||
|
|
|
|||
|
|
@ -44,6 +44,12 @@ def create_font_map(all_fonts: tuple[FontConfigPattern, ...]) -> FontMap:
|
|||
return ans
|
||||
|
||||
|
||||
def clear_caches() -> None:
|
||||
all_fonts_map.cache_clear()
|
||||
fc_match.cache_clear()
|
||||
weight_range_for_family.cache_clear()
|
||||
|
||||
|
||||
@lru_cache(maxsize=2)
|
||||
def all_fonts_map(monospaced: bool = True) -> FontMap:
|
||||
if monospaced:
|
||||
|
|
|
|||
|
|
@ -187,6 +187,16 @@ def dump_font_debug() -> None:
|
|||
log_error(' ' + s.identify_for_debug())
|
||||
|
||||
|
||||
def clear_font_caches() -> None:
|
||||
from .common import clear_caches as clear_common_caches
|
||||
clear_common_caches()
|
||||
if is_macos:
|
||||
from .core_text import clear_caches as clear_platform_caches
|
||||
else:
|
||||
from .fontconfig import clear_caches as clear_platform_caches
|
||||
clear_platform_caches()
|
||||
|
||||
|
||||
def set_font_family(opts: Options | None = None, override_font_size: float | None = None, add_builtin_nerd_font: bool = False) -> None:
|
||||
global current_faces, builtin_nerd_font_descriptor
|
||||
opts = opts or defaults
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue