Skip to content

Commit acc7f36

Browse files
committed
Improve web font
Fix the text position and use mononoki just like for non-wasm
1 parent 7c3bcfe commit acc7f36

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

dose-response.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ document.body.append(c);
99

1010
var ctx = c.getContext('2d');
1111
ctx.textAlign = "center";
12-
ctx.font = '16px arial';
12+
ctx.font = '14px mononoki';
1313

1414
var wasm_instance;
1515
var gamestate_ptr;
@@ -150,7 +150,10 @@ fetch('target/wasm32-unknown-unknown/release/dose-response.wasm')
150150
ctx.fillRect(x * squareSize, y * squareSize, squareSize, squareSize);
151151
} else {
152152
ctx.fillStyle = `rgb(${r},${g},${b})`;
153-
ctx.fillText(glyph, x * squareSize + squareSize / 2, y * squareSize + squareSize / 2);
153+
154+
let x_fudge = 8;
155+
let y_fudge = 13;
156+
ctx.fillText(glyph, x * squareSize + x_fudge, y * squareSize + y_fudge);
154157
}
155158
}
156159

style.css

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
@font-face {
2+
font-family: 'mononoki';
3+
font-style: normal;
4+
font-weight: 400;
5+
src: local('mononoki'), url('fonts/mononoki-Regular.ttf') format('truetype');
6+
}
7+
18
canvas {
29
background: black;
310
}

0 commit comments

Comments
 (0)