fix: address CodeRabbit findings on the style-editor/font-selector PR

- Fix _load_font_sized double-wrapping the (font, size) tuple on the
  missing-font path, which handed callers a tuple instead of a font.
- Fix _set_nested_value skipping an explicit None when the key already
  existed, which silently kept stale overrides when a user cleared a
  nullable per-mode field or blanked all channels of an indexed color.
- Preserve BDF scalable/native_size metadata through fetchFontCatalog's
  catalog-format mapping so maxFixedSize filtering actually applies.
- Stop caching an empty array on a failed font-catalog fetch so a later
  call can retry instead of being stuck with the failed result.
- Keep a saved font selected in the style editor even when it no longer
  fits a newly declared maxFixedSize, instead of silently deselecting it.
- Don't drop in-progress user edits to fallback fields when a plugin
  widget finishes loading asynchronously and takes over the form.
- Tighten the removed font-override endpoint test to assert 405, not
  just != 200.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-09-13 05:34:27 +00:00
parent a5342939af
commit f9e9eeba00
8 changed files with 76 additions and 15 deletions
+13
View File
@@ -359,6 +359,19 @@ class TestDegradation:
# The override IS honored as forced, but the face degrades safely.
assert style.user_forced
assert style.font is not None
assert not isinstance(style.font, tuple)
def test_missing_font_load_returns_a_font_not_a_nested_tuple(self):
# Regression: the missing-font path in _load_font_sized used to wrap
# _load_fallback_font's own (font, size) tuple a second time, so
# load_font() returned a (font, size) tuple where callers (draw.text,
# layout math) expect a font object.
font, size = _load_font_sized("definitely-not-a-real-font.ttf", 8)
assert not isinstance(font, tuple)
assert size == 8
single = load_font("definitely-not-a-real-font.ttf", 8)
assert not isinstance(single, tuple)
def test_empty_defaults_treats_config_as_reference_to_classic(self):
# No schema defaults at all: a config value equal to the classic