Skip to content

Commit

Permalink
Switch to Fira Code font for rendering UI, given that we already ship
Browse files Browse the repository at this point in the history
it with Remotery and can guarantee the same rendering across platforms.
  • Loading branch information
dwilliamson committed Jul 1, 2022
1 parent 92d246b commit 8e2bfd4
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions vis/Code/WebGLFont.js
Expand Up @@ -10,8 +10,8 @@ class glFont
// Describe the font
const font_size = 9;
this.fontWidth = 5;
this.fontHeight = 12;
const font_face = "Consolas";
this.fontHeight = 13;
const font_face = "LocalFiraCode";
const font_desc = font_size + "px " + font_face;

// Ensure the CSS font is loaded before we do any work with it
Expand Down Expand Up @@ -58,24 +58,19 @@ class glFont
this.charContext.fillStyle = "black";
this.charContext.clearRect(0, 0, width, height);

// Render the text
this.charContext.font = font;
this.charContext.textAlign = "left";
this.charContext.textBaseline = "top";

// TODO(don): I don't know why this results in the crispest text!
// Every pattern I've checked so far has thrown up no ideas... but it works, so it will do for now
let offset = 0;
if ("#$&0689BCDGHKNOPRSUbdefghknopqstuyz".includes(text))
let offset = 0.25;
if ("AFILMTWijmw4+{};\'#,.?!\"£*()".includes(text))
{
offset = 0.5;
}
else if ("TI".includes(text))
{
offset = 0.25;
offset = 0.0;
}

this.charContext.fillText(text, offset, 0.5);
// Render the text
this.charContext.font = font;
this.charContext.textAlign = "left";
this.charContext.textBaseline = "top";
this.charContext.fillText(text, offset, 2.5);
}
}

Expand Down

0 comments on commit 8e2bfd4

Please sign in to comment.