Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Restore global font variants and apply selected weight https://github.com/siyuan-note/siyuan/issues/19148

Daniel4841220625bf
diff --git a/app/src/config/tabs/appearanceTab.ts b/app/src/config/tabs/appearanceTab.ts
index 59c1ab178d..e5a47f9b31 100644
--- a/app/src/config/tabs/appearanceTab.ts
+++ b/app/src/config/tabs/appearanceTab.ts
@@ -37,7 +37,7 @@ import {
unregisterCustomFont
} from "../../util/customFont";
import {showMessage} from "../../dialog/message";
-import {getUniqueFontFamilies, IFontItem, loadSystemFonts} from "../../util/systemFont";
+import {IFontItem, loadSystemFonts} from "../../util/systemFont";
import {
shouldShowBootAppearanceSetting,
type IBootAppearanceListItem,
@@ -337,9 +337,7 @@ const mountAppearanceFontFamily = (root: HTMLElement, configKey: FontFamiliesCon
);
};
bindSelectedFontList(selectedListElement, () => selectedFonts, persistFonts, (chip, index, event) => {
- if (configKey !== "globalFontFamilies") {
- openFontWeightMenu(chip, index, event);
- }
+ openFontWeightMenu(chip, index, event);
});
mountedFontConfigUpdaters.set(fontConfigElement, updateFontInput);
updateFontInput(getFontConfig());
@@ -351,9 +349,7 @@ const mountAppearanceFontFamily = (root: HTMLElement, configKey: FontFamiliesCon
console.warn("load font list failed", error);
return;
}
- const {nativeMobile, customFonts} = availableFonts;
- const fontItems = configKey === "globalFontFamilies" ?
- getUniqueFontFamilies(availableFonts.fontItems) : availableFonts.fontItems;
+ const {nativeMobile, customFonts, fontItems} = availableFonts;
selectedFonts = getConfiguredFonts(getFontConfig(), configKey).map((selectedFont) =>
fontItems.find((font) => font.family === selectedFont.family && font.weight === selectedFont.weight) ||
selectedFont);
diff --git a/app/src/util/globalFont.ts b/app/src/util/globalFont.ts
index 70042457a6..f6cd98f4fe 100644
--- a/app/src/util/globalFont.ts
+++ b/app/src/util/globalFont.ts
@@ -1,4 +1,5 @@
-export const getGlobalFontStyle = (fonts: Array<{family: string}>) => {
+export const getGlobalFontStyle = (fonts: Array<{family: string; weight: number}>) => {
const families = fonts.map((font) => CSS.escape(font.family)).join(", ");
- return families ? `\n:root:root { --b3-font-family: var(--b3-font-family-emoji-reset), ${families}, var(--b3-font-family-default, sans-serif) }` : "";
+ return families ? `\n:root:root { --b3-font-family: var(--b3-font-family-emoji-reset), ${families}, var(--b3-font-family-default, sans-serif) }
+body, button, input, select, textarea { font-weight: ${fonts[0].weight || 400} }` : "";
};