Permalink
Browse files

Improve web font

Fix the text position and use mononoki just like for non-wasm
  • Loading branch information...
tomassedovic committed Dec 22, 2017
1 parent 7c3bcfe commit acc7f3688b6f7abc728db0d2d7534fcc90d39d9b
Showing with 12 additions and 2 deletions.
  1. +5 −2 dose-response.js
  2. +7 −0 style.css
@@ -9,7 +9,7 @@ document.body.append(c);

var ctx = c.getContext('2d');
ctx.textAlign = "center";
ctx.font = '16px arial';
ctx.font = '14px mononoki';

var wasm_instance;
var gamestate_ptr;
@@ -150,7 +150,10 @@ fetch('target/wasm32-unknown-unknown/release/dose-response.wasm')
ctx.fillRect(x * squareSize, y * squareSize, squareSize, squareSize);
} else {
ctx.fillStyle = `rgb(${r},${g},${b})`;
ctx.fillText(glyph, x * squareSize + squareSize / 2, y * squareSize + squareSize / 2);

let x_fudge = 8;
let y_fudge = 13;
ctx.fillText(glyph, x * squareSize + x_fudge, y * squareSize + y_fudge);
}
}

@@ -1,3 +1,10 @@
@font-face {
font-family: 'mononoki';
font-style: normal;
font-weight: 400;
src: local('mononoki'), url('fonts/mononoki-Regular.ttf') format('truetype');
}

canvas {
background: black;
}

0 comments on commit acc7f36

Please sign in to comment.