Skip to content

Instantly share code, notes, and snippets.

@subzey
Created March 2, 2022 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save subzey/8e5dd776cb7b3b8741c4bce7975df451 to your computer and use it in GitHub Desktop.
Save subzey/8e5dd776cb7b3b8741c4bce7975df451 to your computer and use it in GitHub Desktop.
<!doctype html>
<canvas id="a" width="500" height="500"></canvas>
<script>
const ctx = document.querySelector('canvas').getContext('2d');
const font = new FontFace('Charting', 'local("SF Pro Display")', {featureSettings: '"tnum" on, "lnum" on'});
document.fonts.add(font);
ctx.font = '42px Charting, sans-serif';
ctx.fillText('11111|', 0, 50);
ctx.fillText('88888|', 0, 90);
ctx.font = '42px SF Pro Display, sans-serif';
ctx.fillText('11111|', 0, 150);
ctx.fillText('88888|', 0, 190);
font.loaded.then(console.log, console.error);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment