Skip to content

Commit

Permalink
Move TODO about the FONT_SCALE_MAGIC
Browse files Browse the repository at this point in the history
  • Loading branch information
rexim committed Feb 9, 2024
1 parent e6ca50c commit 2ce95df
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions raylib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2ce95df

Please sign in to comment.