fixed font loading in the web version

This commit is contained in:
Eugene Pankov 2021-03-14 14:40:36 +01:00
parent f6d4a51239
commit 08cc19946f
No known key found for this signature in database
GPG key ID: 5896FCBBDD1CF4F4
4 changed files with 10 additions and 7 deletions

View file

@ -260,13 +260,13 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
this.frontend.write('\r\n\r\n')
}
setImmediate(() => {
setImmediate(async () => {
if (this.hasFocus) {
this.frontend!.attach(this.content.nativeElement)
await this.frontend!.attach(this.content.nativeElement)
this.frontend!.configure()
} else {
this.focused$.pipe(first()).subscribe(() => {
this.frontend!.attach(this.content.nativeElement)
this.focused$.pipe(first()).subscribe(async () => {
await this.frontend!.attach(this.content.nativeElement)
this.frontend!.configure()
})
}

View file

@ -57,7 +57,7 @@ export abstract class Frontend {
}
}
abstract attach (host: HTMLElement): void
abstract async attach (host: HTMLElement): Promise<void>
detach (host: HTMLElement): void { } // eslint-disable-line
abstract getSelection (): string

View file

@ -13,7 +13,7 @@ export class HTermFrontend extends Frontend {
private configuredBackgroundColor = 'transparent'
private zoom = 0
attach (host: HTMLElement): void {
async attach (host: HTMLElement): Promise<void> {
if (!this.initialized) {
this.init()
this.initialized = true

View file

@ -131,12 +131,15 @@ export class XTermFrontend extends Frontend {
})
}
attach (host: HTMLElement): void {
async attach (host: HTMLElement): Promise<void> {
this.configure()
this.xterm.open(host)
this.opened = true
// Work around font loading bugs
await new Promise(resolve => setTimeout(resolve, process.env.XWEB ? 1000 : 0))
if (this.enableWebGL) {
this.xterm.loadAddon(new WebglAddon())
}