From 2ce95dff1447e0a28340fef63abd3f6088e21c7c Mon Sep 17 00:00:00 2001 From: rexim Date: Fri, 9 Feb 2024 19:57:36 +0700 Subject: [PATCH] Move TODO about the FONT_SCALE_MAGIC --- raylib.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/raylib.js b/raylib.js index fea52dc..07f81db 100644 --- a/raylib.js +++ b/raylib.js @@ -12,6 +12,13 @@ function make_environment(env) { } class RaylibJs { + // TODO: We stole the font from the website + // (https://raylib.com/) and it's slightly different than + // the one that is "baked" into Raylib library itself. To + // account for the differences we scale the size with a + // magical factor. + // + // It would be nice to have a better approach... #FONT_SCALE_MAGIC = 0.65; #reset() { @@ -142,13 +149,6 @@ class RaylibJs { const buffer = this.wasm.instance.exports.memory.buffer; const text = cstr_by_ptr(buffer, text_ptr); const color = getColorFromMemory(buffer, color_ptr); - // TODO: We stole the font from the website - // (https://raylib.com/) and it's slightly different than - // the one that is "baked" into Raylib library itself. To - // account for the differences we scale the size with a - // magical factor. - // - // It would be nice to have a better approach... fontSize *= this.#FONT_SCALE_MAGIC; this.ctx.fillStyle = color; // TODO: since the default font is part of Raylib the css that defines it should be located in raylib.js and not in index.html @@ -218,8 +218,6 @@ class RaylibJs { MeasureText(text_ptr, fontSize) { const buffer = this.wasm.instance.exports.memory.buffer; const text = cstr_by_ptr(buffer, text_ptr); - - // TODO: fontSize *= this.#FONT_SCALE_MAGIC; this.ctx.font = `${fontSize}px grixel`; return this.ctx.measureText(text).width;