Windows、MacOS平台下的字体列表取消使用原生方式获取(#1596)

pull/1686/head
lyswhut 2023-10-07 11:17:04 +08:00
parent 799b768367
commit a786ae24e9
8 changed files with 154 additions and 74 deletions

194
package-lock.json generated
View File

@ -15,7 +15,6 @@
"bufferutil": "^4.0.7", "bufferutil": "^4.0.7",
"comlink": "~4.3.1", "comlink": "~4.3.1",
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
"electron-font-manager": "github:lyswhut/electron-font-manager#6d2f5ecf850c4fe34812b9394913680462ee0dae",
"electron-log": "^5.0.0-rc.1", "electron-log": "^5.0.0-rc.1",
"electron-store": "^8.1.0", "electron-store": "^8.1.0",
"font-list": "^1.5.1", "font-list": "^1.5.1",
@ -92,7 +91,7 @@
"terser": "^5.21.0", "terser": "^5.21.0",
"terser-webpack-plugin": "^5.3.9", "terser-webpack-plugin": "^5.3.9",
"ts-loader": "^9.4.4", "ts-loader": "^9.4.4",
"typescript": "^5.1.6", "typescript": "^5.3.0-beta",
"vue-eslint-parser": "^9.3.1", "vue-eslint-parser": "^9.3.1",
"vue-loader": "^17.2.2", "vue-loader": "^17.2.2",
"vue-template-compiler": "^2.7.14", "vue-template-compiler": "^2.7.14",
@ -3190,6 +3189,33 @@
} }
} }
}, },
"node_modules/@typescript-eslint/eslint-plugin/node_modules/ts-api-utils": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.3.tgz",
"integrity": "sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==",
"dev": true,
"peer": true,
"engines": {
"node": ">=16.13.0"
},
"peerDependencies": {
"typescript": ">=4.2.0"
}
},
"node_modules/@typescript-eslint/eslint-plugin/node_modules/typescript": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
"dev": true,
"peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/@typescript-eslint/parser": { "node_modules/@typescript-eslint/parser": {
"version": "6.4.1", "version": "6.4.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.4.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.4.1.tgz",
@ -3263,6 +3289,33 @@
} }
} }
}, },
"node_modules/@typescript-eslint/type-utils/node_modules/ts-api-utils": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.3.tgz",
"integrity": "sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==",
"dev": true,
"peer": true,
"engines": {
"node": ">=16.13.0"
},
"peerDependencies": {
"typescript": ">=4.2.0"
}
},
"node_modules/@typescript-eslint/type-utils/node_modules/typescript": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
"dev": true,
"peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/@typescript-eslint/types": { "node_modules/@typescript-eslint/types": {
"version": "6.4.1", "version": "6.4.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.4.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.4.1.tgz",
@ -3303,6 +3356,32 @@
} }
} }
}, },
"node_modules/@typescript-eslint/typescript-estree/node_modules/ts-api-utils": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.3.tgz",
"integrity": "sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==",
"dev": true,
"engines": {
"node": ">=16.13.0"
},
"peerDependencies": {
"typescript": ">=4.2.0"
}
},
"node_modules/@typescript-eslint/typescript-estree/node_modules/typescript": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
"dev": true,
"peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/@typescript-eslint/utils": { "node_modules/@typescript-eslint/utils": {
"version": "6.4.1", "version": "6.4.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.4.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.4.1.tgz",
@ -6965,21 +7044,6 @@
"url": "https://github.com/sponsors/isaacs" "url": "https://github.com/sponsors/isaacs"
} }
}, },
"node_modules/electron-font-manager": {
"version": "0.0.1",
"resolved": "git+ssh://git@github.com/lyswhut/electron-font-manager.git#6d2f5ecf850c4fe34812b9394913680462ee0dae",
"integrity": "sha512-hEiPAsKf3dAplHQ6cuS2PE1ScWeK7UtcqWnK59IXz2D/HrC0ZSwUzIp0ovSxmqYpFHZGFtQ9JiW3p24p7YALOw==",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
"node-addon-api": "^6.1.0"
}
},
"node_modules/electron-font-manager/node_modules/node-addon-api": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz",
"integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA=="
},
"node_modules/electron-is-accelerator": { "node_modules/electron-is-accelerator": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://registry.npmjs.org/electron-is-accelerator/-/electron-is-accelerator-0.1.2.tgz", "resolved": "https://registry.npmjs.org/electron-is-accelerator/-/electron-is-accelerator-0.1.2.tgz",
@ -16253,18 +16317,6 @@
"utf8-byte-length": "^1.0.1" "utf8-byte-length": "^1.0.1"
} }
}, },
"node_modules/ts-api-utils": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.2.tgz",
"integrity": "sha512-Cbu4nIqnEdd+THNEsBdkolnOXhg0I8XteoHaEKgvsxpsbWda4IsUut2c187HxywQCvveojow0Dgw/amxtSKVkQ==",
"dev": true,
"engines": {
"node": ">=16.13.0"
},
"peerDependencies": {
"typescript": ">=4.2.0"
}
},
"node_modules/ts-loader": { "node_modules/ts-loader": {
"version": "9.4.4", "version": "9.4.4",
"resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.4.4.tgz", "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.4.4.tgz",
@ -16437,9 +16489,9 @@
} }
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "5.1.6", "version": "5.3.0-beta",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.0-beta.tgz",
"integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", "integrity": "sha512-SiTeC1C8wAS6v2SD05iyfojeuIkUZIbb8suZz0d4BR+RErwpG+05iolat+VjM9hqXSrjb3xutEBzh4X3NJ7Jgw==",
"dev": true, "dev": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
@ -19896,6 +19948,23 @@
"natural-compare": "^1.4.0", "natural-compare": "^1.4.0",
"semver": "latest", "semver": "latest",
"ts-api-utils": "^1.0.1" "ts-api-utils": "^1.0.1"
},
"dependencies": {
"ts-api-utils": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.3.tgz",
"integrity": "sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==",
"dev": true,
"peer": true,
"requires": {}
},
"typescript": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
"dev": true,
"peer": true
}
} }
}, },
"@typescript-eslint/parser": { "@typescript-eslint/parser": {
@ -19932,6 +20001,23 @@
"@typescript-eslint/utils": "6.4.1", "@typescript-eslint/utils": "6.4.1",
"debug": "^4.3.4", "debug": "^4.3.4",
"ts-api-utils": "^1.0.1" "ts-api-utils": "^1.0.1"
},
"dependencies": {
"ts-api-utils": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.3.tgz",
"integrity": "sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==",
"dev": true,
"peer": true,
"requires": {}
},
"typescript": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
"dev": true,
"peer": true
}
} }
}, },
"@typescript-eslint/types": { "@typescript-eslint/types": {
@ -19953,6 +20039,22 @@
"is-glob": "^4.0.3", "is-glob": "^4.0.3",
"semver": "latest", "semver": "latest",
"ts-api-utils": "^1.0.1" "ts-api-utils": "^1.0.1"
},
"dependencies": {
"ts-api-utils": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.3.tgz",
"integrity": "sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==",
"dev": true,
"requires": {}
},
"typescript": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
"dev": true,
"peer": true
}
} }
}, },
"@typescript-eslint/utils": { "@typescript-eslint/utils": {
@ -22771,21 +22873,6 @@
} }
} }
}, },
"electron-font-manager": {
"version": "git+ssh://git@github.com/lyswhut/electron-font-manager.git#6d2f5ecf850c4fe34812b9394913680462ee0dae",
"integrity": "sha512-hEiPAsKf3dAplHQ6cuS2PE1ScWeK7UtcqWnK59IXz2D/HrC0ZSwUzIp0ovSxmqYpFHZGFtQ9JiW3p24p7YALOw==",
"from": "electron-font-manager@github:lyswhut/electron-font-manager#6d2f5ecf850c4fe34812b9394913680462ee0dae",
"requires": {
"node-addon-api": "^6.1.0"
},
"dependencies": {
"node-addon-api": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz",
"integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA=="
}
}
},
"electron-is-accelerator": { "electron-is-accelerator": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://registry.npmjs.org/electron-is-accelerator/-/electron-is-accelerator-0.1.2.tgz", "resolved": "https://registry.npmjs.org/electron-is-accelerator/-/electron-is-accelerator-0.1.2.tgz",
@ -29845,13 +29932,6 @@
"utf8-byte-length": "^1.0.1" "utf8-byte-length": "^1.0.1"
} }
}, },
"ts-api-utils": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.2.tgz",
"integrity": "sha512-Cbu4nIqnEdd+THNEsBdkolnOXhg0I8XteoHaEKgvsxpsbWda4IsUut2c187HxywQCvveojow0Dgw/amxtSKVkQ==",
"dev": true,
"requires": {}
},
"ts-loader": { "ts-loader": {
"version": "9.4.4", "version": "9.4.4",
"resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.4.4.tgz", "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.4.4.tgz",
@ -29980,9 +30060,9 @@
} }
}, },
"typescript": { "typescript": {
"version": "5.1.6", "version": "5.3.0-beta",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.0-beta.tgz",
"integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", "integrity": "sha512-SiTeC1C8wAS6v2SD05iyfojeuIkUZIbb8suZz0d4BR+RErwpG+05iolat+VjM9hqXSrjb3xutEBzh4X3NJ7Jgw==",
"dev": true "dev": true
}, },
"typescript-auto-import-cache": { "typescript-auto-import-cache": {

View File

@ -163,7 +163,7 @@
"terser": "^5.21.0", "terser": "^5.21.0",
"terser-webpack-plugin": "^5.3.9", "terser-webpack-plugin": "^5.3.9",
"ts-loader": "^9.4.4", "ts-loader": "^9.4.4",
"typescript": "^5.1.6", "typescript": "^5.3.0-beta",
"vue-eslint-parser": "^9.3.1", "vue-eslint-parser": "^9.3.1",
"vue-loader": "^17.2.2", "vue-loader": "^17.2.2",
"vue-template-compiler": "^2.7.14", "vue-template-compiler": "^2.7.14",
@ -179,7 +179,6 @@
"bufferutil": "^4.0.7", "bufferutil": "^4.0.7",
"comlink": "~4.3.1", "comlink": "~4.3.1",
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
"electron-font-manager": "github:lyswhut/electron-font-manager#6d2f5ecf850c4fe34812b9394913680462ee0dae",
"electron-log": "^5.0.0-rc.1", "electron-log": "^5.0.0-rc.1",
"electron-store": "^8.1.0", "electron-store": "^8.1.0",
"font-list": "^1.5.1", "font-list": "^1.5.1",

View File

@ -1,6 +1,7 @@
### 修复 ### 修复
- 修复备份文件无法导入json格式的问题 - 修复备份文件无法导入json格式的问题
- Windows、MacOS平台下的字体列表取消使用原生方式获取以修复某些字体应用后无效的问题#1596
### 其他 ### 其他

View File

@ -3,18 +3,18 @@
// exports.getAvailableFontFamilies = getAvailableFontFamilies // exports.getAvailableFontFamilies = getAvailableFontFamilies
import { getFonts as getFontsByCommand } from 'font-list' import { getFonts } from 'font-list'
import { getAvailableFontFamilies } from 'electron-font-manager' // import { getAvailableFontFamilies } from 'electron-font-manager'
const getFonts = async() => { // const getFonts = async() => {
switch (process.platform) { // switch (process.platform) {
case 'win32': // case 'win32':
case 'darwin': // case 'darwin':
return getAvailableFontFamilies() // return getAvailableFontFamilies()
default: return getFontsByCommand() // default: return getFontsByCommand()
} // }
} // }
export { export {
getFonts, getFonts,

View File

@ -34,7 +34,7 @@ export default {
return name return name
}) })
const lrcStyles = computed(() => ({ const lrcStyles = computed(() => ({
fontFamily: /\s/.test(setting['desktopLyric.style.font']) ? `"${setting['desktopLyric.style.font']}"` : setting['desktopLyric.style.font'], fontFamily: setting['desktopLyric.style.font'],
fontSize: Math.trunc(setting['desktopLyric.style.fontSize']) + 'px', fontSize: Math.trunc(setting['desktopLyric.style.fontSize']) + 'px',
opacity: setting['desktopLyric.style.opacity'] / 100, opacity: setting['desktopLyric.style.opacity'] / 100,
textAlign: setting['desktopLyric.style.align'], textAlign: setting['desktopLyric.style.align'],

View File

@ -33,7 +33,7 @@ export default {
return name return name
}) })
const lrcStyles = computed(() => ({ const lrcStyles = computed(() => ({
fontFamily: /\s/.test(setting['desktopLyric.style.font']) ? `"${setting['desktopLyric.style.font']}"` : setting['desktopLyric.style.font'], fontFamily: setting['desktopLyric.style.font'],
fontSize: Math.trunc(setting['desktopLyric.style.fontSize']) + 'px', fontSize: Math.trunc(setting['desktopLyric.style.fontSize']) + 'px',
opacity: setting['desktopLyric.style.opacity'] / 100, opacity: setting['desktopLyric.style.opacity'] / 100,
textAlign: setting['desktopLyric.style.align'], textAlign: setting['desktopLyric.style.align'],

View File

@ -27,7 +27,7 @@ export default () => {
}) })
watch(() => appSetting['common.font'], (val) => { watch(() => appSetting['common.font'], (val) => {
document.documentElement.style.fontFamily = /\s/.test(val) ? `"${val}"` : val document.documentElement.style.fontFamily = val
}, { }, {
immediate: true, immediate: true,
}) })

View File

@ -4,8 +4,8 @@
"compilerOptions": { "compilerOptions": {
"target": "ESNext", "target": "ESNext",
"allowJs": true, "allowJs": true,
"module": "esnext", "module": "ESNext",
"moduleResolution": "nodenext", "moduleResolution": "Node",
"resolveJsonModule": true, "resolveJsonModule": true,
"outDir": "./dist", "outDir": "./dist",
"baseUrl": "./src", /* Specify the base directory to resolve non-relative module names. */ "baseUrl": "./src", /* Specify the base directory to resolve non-relative module names. */