Просмотр исходного кода

fixed font loading in the web version

Eugene Pankov 4 лет назад
Родитель
Сommit
08cc19946f

+ 4 - 4
terminus-terminal/src/api/baseTerminalTab.component.ts

@@ -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()
                 })
             }

+ 1 - 1
terminus-terminal/src/frontends/frontend.ts

@@ -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

+ 1 - 1
terminus-terminal/src/frontends/htermFrontend.ts

@@ -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

+ 4 - 1
terminus-terminal/src/frontends/xtermFrontend.ts

@@ -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())
         }