Skip to content

Commit

Permalink
this makes text look . . . good? finally??
Browse files Browse the repository at this point in the history
  • Loading branch information
smolck committed Sep 10, 2021
1 parent c1f1435 commit 0577d46
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/render/font-texture-atlas.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Surface, Canvas, CanvasKit, Paint } from 'canvaskit-wasm'
import { Surface, Canvas, CanvasKit, Paint, Color } from 'canvaskit-wasm'
import Workspace from '../workspace'

export interface AtlasCharBounds {
Expand Down Expand Up @@ -40,13 +40,17 @@ export default class FontTextureAtlas {

private width: number

private bgColorStoredBecauseReasons: Color

constructor(
workspace: Workspace,
canvasKit: CanvasKit,
atlasWidth = 1000,
atlasHeight = 500
) {
this.bgColorStoredBecauseReasons = canvasKit.TRANSPARENT
this.canvasElement = document.createElement('canvas')!

this.setCanvasWidth(atlasWidth, atlasHeight)
this.width = atlasWidth

Expand Down Expand Up @@ -175,7 +179,10 @@ export default class FontTextureAtlas {
}

this.charsQueue.forEach(draw)
if (redrawWithAllCharsInAtlas) this.charsInAtlas.forEach(draw)
if (redrawWithAllCharsInAtlas) {
this.canvas.clear(this.bgColorStoredBecauseReasons)
this.charsInAtlas.forEach(draw)
}

this.surface.flush()

Expand Down

0 comments on commit 0577d46

Please sign in to comment.