Skip to content

Commit

Permalink
Windows、MacOS平台下的字体列表取消使用原生方式获取(#1596
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed Oct 7, 2023
1 parent 799b768 commit a786ae2
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 74 deletions.
194 changes: 137 additions & 57 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -163,7 +163,7 @@
"terser": "^5.21.0",
"terser-webpack-plugin": "^5.3.9",
"ts-loader": "^9.4.4",
"typescript": "^5.1.6",
"typescript": "^5.3.0-beta",
"vue-eslint-parser": "^9.3.1",
"vue-loader": "^17.2.2",
"vue-template-compiler": "^2.7.14",
Expand All @@ -179,7 +179,6 @@
"bufferutil": "^4.0.7",
"comlink": "~4.3.1",
"crypto-js": "^4.1.1",
"electron-font-manager": "github:lyswhut/electron-font-manager#6d2f5ecf850c4fe34812b9394913680462ee0dae",
"electron-log": "^5.0.0-rc.1",
"electron-store": "^8.1.0",
"font-list": "^1.5.1",
Expand Down
1 change: 1 addition & 0 deletions publish/changeLog.md
@@ -1,6 +1,7 @@
### 修复

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

### 其他

Expand Down
20 changes: 10 additions & 10 deletions src/main/utils/fontManage.ts
Expand Up @@ -3,18 +3,18 @@

// exports.getAvailableFontFamilies = getAvailableFontFamilies

import { getFonts as getFontsByCommand } from 'font-list'
import { getAvailableFontFamilies } from 'electron-font-manager'
import { getFonts } from 'font-list'
// import { getAvailableFontFamilies } from 'electron-font-manager'


const getFonts = async() => {
switch (process.platform) {
case 'win32':
case 'darwin':
return getAvailableFontFamilies()
default: return getFontsByCommand()
}
}
// const getFonts = async() => {
// switch (process.platform) {
// case 'win32':
// case 'darwin':
// return getAvailableFontFamilies()
// default: return getFontsByCommand()
// }
// }

export {
getFonts,
Expand Down
Expand Up @@ -34,7 +34,7 @@ export default {
return name
})
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',
opacity: setting['desktopLyric.style.opacity'] / 100,
textAlign: setting['desktopLyric.style.align'],
Expand Down
Expand Up @@ -33,7 +33,7 @@ export default {
return name
})
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',
opacity: setting['desktopLyric.style.opacity'] / 100,
textAlign: setting['desktopLyric.style.align'],
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/core/useApp/useSettingSync.ts
Expand Up @@ -27,7 +27,7 @@ export default () => {
})

watch(() => appSetting['common.font'], (val) => {
document.documentElement.style.fontFamily = /\s/.test(val) ? `"${val}"` : val
document.documentElement.style.fontFamily = val
}, {
immediate: true,
})
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Expand Up @@ -4,8 +4,8 @@
"compilerOptions": {
"target": "ESNext",
"allowJs": true,
"module": "esnext",
"moduleResolution": "nodenext",
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"outDir": "./dist",
"baseUrl": "./src", /* Specify the base directory to resolve non-relative module names. */
Expand Down

0 comments on commit a786ae2

Please sign in to comment.