mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Quote font family names, except for generic families
Fixes https://forums.ankiweb.net/t/font-script-is-not-changing-in-the-anki-windows/12465
This commit is contained in:
parent
53fe7e574e
commit
20085c9bc4
1 changed files with 9 additions and 1 deletions
|
@ -105,10 +105,18 @@ export class EditingArea extends HTMLDivElement {
|
||||||
firstRule.style.color = color;
|
firstRule.style.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quoteFontFamily(fontFamily: string): string {
|
||||||
|
// generic families (e.g. sans-serif) must not be quoted
|
||||||
|
if (!/^[a-z|-]+$/.test(fontFamily)) {
|
||||||
|
fontFamily = `"${fontFamily}"`;
|
||||||
|
}
|
||||||
|
return fontFamily;
|
||||||
|
}
|
||||||
|
|
||||||
setBaseStyling(fontFamily: string, fontSize: string, direction: string): void {
|
setBaseStyling(fontFamily: string, fontSize: string, direction: string): void {
|
||||||
const styleSheet = this.baseStyle.sheet as CSSStyleSheet;
|
const styleSheet = this.baseStyle.sheet as CSSStyleSheet;
|
||||||
const firstRule = styleSheet.cssRules[0] as CSSStyleRule;
|
const firstRule = styleSheet.cssRules[0] as CSSStyleRule;
|
||||||
firstRule.style.fontFamily = fontFamily;
|
firstRule.style.fontFamily = this.quoteFontFamily(fontFamily);
|
||||||
firstRule.style.fontSize = fontSize;
|
firstRule.style.fontSize = fontSize;
|
||||||
firstRule.style.direction = direction;
|
firstRule.style.direction = direction;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue