fix a bug in lettering extensions when the last_font can't be found (#3508)

pull/3509/head
Kaalleen 2025-02-13 18:05:54 +01:00 zatwierdzone przez GitHub
rodzic a1badc255b
commit 942af5acb4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
2 zmienionych plików z 17 dodań i 4 usunięć

Wyświetl plik

@ -230,7 +230,13 @@ class LetteringEditJsonPanel(wx.Panel):
return glyph
def on_font_changed(self, event=None):
self.font = self.fonts.get(self.settings_panel.font_chooser.GetValue(), list(self.fonts.values())[0].marked_custom_font_name)
selected_font = self.settings_panel.font_chooser.GetValue()
if selected_font:
self.font = self.fonts[selected_font]
else:
first = list(self.fonts.values())[0].marked_custom_font_name
self.font = self.fonts[first]
self.settings_panel.font_chooser.SetValue(first)
global_settings['last_font'] = self.font.marked_custom_font_name
self.kerning_pairs = self.font.kerning_pairs
self.font._load_variants()

Wyświetl plik

@ -106,11 +106,12 @@ class FontSampleFrame(wx.Frame):
self.settings.SetSizer(settings_sizer)
self.main_panel.SetSizer(notebook_sizer)
max_line_width = global_settings['font_sampling_max_line_width']
self.max_line_width.SetValue(max_line_width)
self.set_font_list()
select_font = global_settings['last_font']
self.font_chooser.SetValue(select_font)
max_line_width = global_settings['font_sampling_max_line_width']
self.max_line_width.SetValue(max_line_width)
self.on_font_changed()
self.SetSizeHints(notebook_sizer.CalcMin())
@ -132,7 +133,13 @@ class FontSampleFrame(wx.Frame):
self.font_chooser.Append(font.marked_custom_font_name)
def on_font_changed(self, event=None):
self.font = self.fonts.get(self.font_chooser.GetValue(), list(self.fonts.values())[0].marked_custom_font_name)
selected_font = self.font_chooser.GetValue()
if selected_font:
self.font = self.fonts[selected_font]
else:
first = list(self.fonts.values())[0].marked_custom_font_name
self.font = self.fonts[first]
self.font_chooser.SetValue(first)
global_settings['last_font'] = self.font.marked_custom_font_name
self.scale_spinner.SetRange(int(self.font.min_scale * 100), int(self.font.max_scale * 100))
# font._load_variants()