fix: filter out some non-free fonts on Android and Linux, closes #994 (#999)

This commit is contained in:
Huang Xin
2025-04-30 02:02:54 +08:00
committed by GitHub
parent 59f0cede39
commit d3eff19ab9
3 changed files with 10 additions and 2 deletions
@@ -12,6 +12,7 @@ import {
LINUX_FONTS,
MACOS_FONTS,
MONOSPACE_FONTS,
NON_FREE_FONTS,
SANS_SERIF_FONTS,
SERIF_FONTS,
WINDOWS_FONTS,
@@ -49,6 +50,10 @@ const handleFontFaceFont = (option: string, family: string) => {
return `'${option}', ${family}`;
};
const filterNonFreeFonts = (font: string) => {
return !['android', 'linux'].includes(getOSPlatform()) || !NON_FREE_FONTS.includes(font);
};
const FontFace = ({
className,
family,
@@ -291,7 +296,7 @@ const FontPanel: React.FC<{ bookKey: string }> = ({ bookKey }) => {
className='config-item-top'
family='serif'
label={_('Serif Font')}
options={[...SERIF_FONTS, ...CJK_SERIF_FONTS]}
options={[...SERIF_FONTS.filter(filterNonFreeFonts), ...CJK_SERIF_FONTS]}
moreOptions={sysFonts}
selected={serifFont}
onSelect={setSerifFont}
@@ -299,7 +304,7 @@ const FontPanel: React.FC<{ bookKey: string }> = ({ bookKey }) => {
<FontFace
family='sans-serif'
label={_('Sans-Serif Font')}
options={[...SANS_SERIF_FONTS, ...CJK_SANS_SERIF_FONTS]}
options={[...SANS_SERIF_FONTS.filter(filterNonFreeFonts), ...CJK_SANS_SERIF_FONTS]}
moreOptions={sysFonts}
selected={sansSerifFont}
onSelect={setSansSerifFont}
@@ -157,6 +157,8 @@ export const SERIF_FONTS = [
'Times New Roman',
];
export const NON_FREE_FONTS = ['Georgia', 'Times New Roman'];
export const CJK_SERIF_FONTS = [
_('LXGW WenKai GB Screen'),
_('LXGW WenKai TC'),
+1
View File
@@ -111,6 +111,7 @@ const getAdditionalFontLinks = () => `
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/misans-webfont@1.0.4/misans-l3/misans-l3/result.min.css" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/cn-fontsource-lxgw-wen-kai-gb-screen@1.0.6/font.min.css" crossorigin="anonymous">
<link rel='stylesheet' href='https://fontsapi.zeoseven.com/431/main/result.css' crossorigin="anonymous"/>
<link rel='stylesheet' href="https://fonts.googleapis.com/css2?family=Vollkorn&display=swap" crossorigin="anonymous">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=LXGW+WenKai+TC&display=swap" crossorigin="anonymous">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC&family=Noto+Sans+TC&display=swap" crossorigin="anonymous">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Noto+Serif+JP&display=swap" crossorigin="anonymous">