1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-12-25 11:33:35 +03:00

fallback font setting (#324)

This commit is contained in:
Eugene Pankov 2019-08-27 16:45:01 +02:00
parent 2ee336bef8
commit 3ddbb62658
5 changed files with 14 additions and 6 deletions

View File

@ -32,7 +32,11 @@ export class AppearanceSettingsTabComponent {
async ngOnInit () {
if (this.hostApp.platform === Platform.Windows || this.hostApp.platform === Platform.macOS) {
const fonts = await new Promise<any[]>((resolve) => fontManager.findFonts({ monospace: true }, resolve))
this.fonts = fonts.map(x => `${x.family} ${x.style}`.trim())
if (this.hostApp.platform === Platform.Windows) {
this.fonts = fonts.map(x => `${x.family} ${x.style}`.trim())
} else {
this.fonts = fonts.map(x => x.family.trim())
}
this.fonts.sort()
}
if (this.hostApp.platform === Platform.Linux) {
@ -101,6 +105,6 @@ export class AppearanceSettingsTabComponent {
}
getPreviewFontFamily () {
return getCSSFontFamily(this.config.store.terminal.font)
return getCSSFontFamily(this.config.store)
}
}

View File

@ -15,6 +15,7 @@ export class TerminalConfigProvider extends ConfigProvider {
frontend: 'xterm',
autoOpen: false,
fontSize: 14,
fallbackFont: null,
linePadding: 0,
bell: 'off',
bracketedPaste: false,

View File

@ -60,7 +60,7 @@ export class HTermFrontend extends Frontend {
this.configuredLinePadding = config.terminal.linePadding
this.setFontSize()
preferenceManager.set('font-family', getCSSFontFamily(config.terminal.font))
preferenceManager.set('font-family', getCSSFontFamily(config))
preferenceManager.set('enable-bold', true)
// preferenceManager.set('audible-bell-sound', '')
preferenceManager.set('desktop-notification-bell', config.terminal.bell === 'notification')

View File

@ -197,7 +197,7 @@ export class XTermFrontend extends Frontend {
}
})
this.xterm.setOption('fontFamily', getCSSFontFamily(config.terminal.font))
this.xterm.setOption('fontFamily', getCSSFontFamily(config))
this.xterm.setOption('bellStyle', config.terminal.bell)
this.xterm.setOption('cursorStyle', {
beam: 'bar',

View File

@ -8,8 +8,11 @@ export function isWindowsBuild (build: number): boolean {
return process.platform === 'win32' && parseFloat(os.release()) >= 10 && parseInt(os.release().split('.')[2]) >= build
}
export function getCSSFontFamily (fontList: string): string {
let fonts = fontList.split(',').map(x => x.trim().replace(/"/g, ''))
export function getCSSFontFamily (config: any): string {
let fonts = config.terminal.font.split(',').map(x => x.trim().replace(/"/g, ''))
if (config.terminal.fallbackFont) {
fonts.push(config.terminal.fallbackFont)
}
fonts.push('monospace-fallback')
fonts.push('monospace')
fonts = fonts.map(x => `"${x}"`)