Merge branch 'clear-font-caches-on-reload' of https://github.com/zzhaolei/kitty
This commit is contained in:
commit
cf5c180a01
5 changed files with 30 additions and 0 deletions
|
|
@ -3200,6 +3200,8 @@ def load_config_file(self, *paths: str, apply_overrides: bool = True, overrides:
|
|||
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 @@ def face_from_descriptor(descriptor, font_sz_in_pts = None, dpi_x = None, dpi_y
|
|||
|
||||
|
||||
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…
Reference in a new issue