vercel / vercel/hyper

Loading custom fonts from disk, using @font-face

Open
#2,887 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🎨 Type: Enhancement
Dominant language
TypeScript
Stars
44.7k
Forks
3.6k
Avg merge
21m
Merged PRs (30d)
1

Description

Issue

With the upgrade to the canvas based renderer in Hyper 2.0, loading custom fonts via css @font-face isn't working that great.

Currently, the first thing I have to do when starting Hyper is to reload the view. Before I do this the font is not displayed properly.

This is because xterm.js is drawing a char atlas to a canvas, and caching the width and height for each char.

The canvas drawText function doesn't wait for the font to be loaded, and thus the cached data (char atlas and char dimensions) becomes that of the fallback font.

Non-ascii characters, which aren't drawn using the char atlas, seems to be using the correct font.

I'm not sure exactly how to solve this. If there is an api to hook into to know when the font has loaded, we could probably expose a method in xterm.js to redraw the cache (which could possibly help solve #2876 as well), and then hook it all up. Suggestions welcome!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Hyper renderer and xterm.js canvas char-atlas path, using the linked .hyper.js configuration to reproduce custom @font-face loading. Determine how font readiness affects cached character dimensions, then verify that a custom font displays correctly on the initial load without requiring a reload.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, typescript
Domain
desktop, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.