@@ -21,11 +21,15 @@ export class NumberProvider {
2121 size : [ PERCENTAGE_WIDTH , PERCENTAGE_HEIGHT , PERCENTAGE_COUNT ] ,
2222 format : 'rgba8unorm' ,
2323 } ) . $usage ( 'sampled' , 'render' ) ;
24-
25- this . #fillAtlas( ) ;
2624 }
2725
28- #fillAtlas( ) {
26+ async fillAtlas ( ) {
27+ // Ensure the font is loaded before drawing
28+ await Promise . all ( [
29+ document . fonts . load ( '180px "Reddit Mono"' ) ,
30+ document . fonts . load ( '140px "JetBrains Mono"' ) ,
31+ ] ) ;
32+
2933 const canvas = document . createElement ( 'canvas' ) ;
3034 canvas . width = PERCENTAGE_WIDTH ;
3135 canvas . height = PERCENTAGE_HEIGHT ;
@@ -34,8 +38,8 @@ export class NumberProvider {
3438 throw new Error ( 'Failed to get 2D context' ) ;
3539 }
3640
37- ctx . font =
38- '160px "SF Mono", "Monaco", "Consolas", "Liberation Mono", "Courier New ", monospace';
41+ const regularFont = '180px "Reddit Mono", monospace' ;
42+ const percentageFont = '140px "JetBrains Mono", monospace';
3943 ctx . textAlign = 'right' ;
4044 ctx . textBaseline = 'middle' ;
4145 ctx . fillStyle = 'white' ;
@@ -45,11 +49,14 @@ export class NumberProvider {
4549 for ( let i = 0 ; i <= 100 ; i ++ ) {
4650 ctx . clearRect ( 0 , 0 , PERCENTAGE_WIDTH , PERCENTAGE_HEIGHT ) ;
4751
48- const text = `${ i } %` ;
4952 const x = PERCENTAGE_WIDTH - 20 ;
5053 const y = PERCENTAGE_HEIGHT / 2 ;
5154
52- ctx . fillText ( text , x , y ) ;
55+ ctx . font = regularFont ;
56+ ctx . fillText ( `${ i } ` , x , y ) ;
57+
58+ ctx . font = percentageFont ;
59+ ctx . fillText ( `%` , x , y + 10 ) ;
5360
5461 percentageImages . push (
5562 ctx . getImageData ( 0 , 0 , PERCENTAGE_WIDTH , PERCENTAGE_HEIGHT ) ,
0 commit comments