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 () { async ngOnInit () {
if (this.hostApp.platform === Platform.Windows || this.hostApp.platform === Platform.macOS) { if (this.hostApp.platform === Platform.Windows || this.hostApp.platform === Platform.macOS) {
const fonts = await new Promise<any[]>((resolve) => fontManager.findFonts({ monospace: true }, resolve)) const fonts = await new Promise<any[]>((resolve) => fontManager.findFonts({ monospace: true }, resolve))
if (this.hostApp.platform === Platform.Windows) {
this.fonts = fonts.map(x => `${x.family} ${x.style}`.trim()) this.fonts = fonts.map(x => `${x.family} ${x.style}`.trim())
} else {
this.fonts = fonts.map(x => x.family.trim())
}
this.fonts.sort() this.fonts.sort()
} }
if (this.hostApp.platform === Platform.Linux) { if (this.hostApp.platform === Platform.Linux) {
@ -101,6 +105,6 @@ export class AppearanceSettingsTabComponent {
} }
getPreviewFontFamily () { 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', frontend: 'xterm',
autoOpen: false, autoOpen: false,
fontSize: 14, fontSize: 14,
fallbackFont: null,
linePadding: 0, linePadding: 0,
bell: 'off', bell: 'off',
bracketedPaste: false, bracketedPaste: false,

View File

@ -60,7 +60,7 @@ export class HTermFrontend extends Frontend {
this.configuredLinePadding = config.terminal.linePadding this.configuredLinePadding = config.terminal.linePadding
this.setFontSize() this.setFontSize()
preferenceManager.set('font-family', getCSSFontFamily(config.terminal.font)) preferenceManager.set('font-family', getCSSFontFamily(config))
preferenceManager.set('enable-bold', true) preferenceManager.set('enable-bold', true)
// preferenceManager.set('audible-bell-sound', '') // preferenceManager.set('audible-bell-sound', '')
preferenceManager.set('desktop-notification-bell', config.terminal.bell === 'notification') 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('bellStyle', config.terminal.bell)
this.xterm.setOption('cursorStyle', { this.xterm.setOption('cursorStyle', {
beam: 'bar', 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 return process.platform === 'win32' && parseFloat(os.release()) >= 10 && parseInt(os.release().split('.')[2]) >= build
} }
export function getCSSFontFamily (fontList: string): string { export function getCSSFontFamily (config: any): string {
let fonts = fontList.split(',').map(x => x.trim().replace(/"/g, '')) 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-fallback')
fonts.push('monospace') fonts.push('monospace')
fonts = fonts.map(x => `"${x}"`) fonts = fonts.map(x => `"${x}"`)