mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 16:26:40 -04:00
Move fontMungeHack()
This commit is contained in:
parent
436d76a81e
commit
423393107d
2 changed files with 8 additions and 18 deletions
|
@ -574,12 +574,6 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too
|
|||
initiator=self
|
||||
)
|
||||
|
||||
def fonts(self) -> list[tuple[str, int, bool]]:
|
||||
return [
|
||||
(gui_hooks.editor_will_use_font_for_field(f["font"]), f["size"], f["rtl"])
|
||||
for f in self.note_type()["flds"]
|
||||
]
|
||||
|
||||
def call_after_note_saved(
|
||||
self, callback: Callable, keepFocus: bool = False
|
||||
) -> None:
|
||||
|
@ -1634,16 +1628,6 @@ class EditorWebView(AnkiWebView):
|
|||
return clipboard
|
||||
|
||||
|
||||
# QFont returns "Kozuka Gothic Pro L" but WebEngine expects "Kozuka Gothic Pro Light"
|
||||
# - there may be other cases like a trailing 'Bold' that need fixing, but will
|
||||
# wait for further reports first.
|
||||
def fontMungeHack(font: str) -> str:
|
||||
return re.sub(" L$", " Light", font)
|
||||
|
||||
|
||||
gui_hooks.editor_will_use_font_for_field.append(fontMungeHack)
|
||||
|
||||
|
||||
def set_cloze_button(editor: Editor) -> None:
|
||||
action = "show" if editor.note_type()["type"] == MODEL_CLOZE else "hide"
|
||||
editor.web.eval(
|
||||
|
|
|
@ -185,6 +185,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
|
||||
const fields = clearableArray<EditorFieldAPI>();
|
||||
|
||||
// QFont returns "Kozuka Gothic Pro L" but WebEngine expects "Kozuka Gothic Pro Light"
|
||||
// - there may be other cases like a trailing 'Bold' that need fixing, but will
|
||||
// wait for further reports first.
|
||||
function mungeFontName(fontName: string): string {
|
||||
return fontName.replace(/ L$/g, " Light");
|
||||
}
|
||||
|
||||
export function setFonts(fs: [string, number, boolean][]): void {
|
||||
fonts = fs;
|
||||
}
|
||||
|
@ -620,10 +627,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
setDescriptions(
|
||||
notetype.fields.map((field) => field.config?.description ?? ""),
|
||||
);
|
||||
// TODO: gui_hooks.editor_will_use_font_for_field
|
||||
setFonts(
|
||||
notetype.fields.map((field) => [
|
||||
field.config?.fontName ?? "",
|
||||
mungeFontName(field.config?.fontName ?? ""),
|
||||
field.config?.fontSize ?? 16,
|
||||
field.config?.rtl ?? false,
|
||||
]),
|
||||
|
|
Loading…
Reference in a new issue