Update app.js

Fix automatic font sizing.
pull/1612/head
Andrew Gregory 2022-03-24 09:43:32 +08:00 committed by GitHub
parent 77e6bd3a8d
commit dd27b11eb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -119,15 +119,14 @@ var state = {
function sizeFont(id, txt, w) { function sizeFont(id, txt, w) {
let sz = fontszCache[id]; let sz = fontszCache[id];
if (sz) { if (!sz) {
g.setFont("Vector", sz);
} else {
sz = TOKEN_DIGITS_HEIGHT; sz = TOKEN_DIGITS_HEIGHT;
do { do {
g.setFont("Vector", sz--); g.setFont("Vector", sz--);
} while (g.stringWidth(txt) > w); } while (g.stringWidth(txt) > w);
fontszCache[id] = sz + 1; fontszCache[id] = ++sz;
} }
g.setFont("Vector", sz);
} }
tokenY = id => id * TOKEN_HEIGHT + AR.y - state.listy; tokenY = id => id * TOKEN_HEIGHT + AR.y - state.listy;