brsh 2.5.2 → 2.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/Terminal.js CHANGED
@@ -149,15 +149,23 @@ class Terminal {
149
149
  this._screen.style.fontFamily = `'${font}', monospace`;
150
150
  parent.appendChild(this._screen);
151
151
 
152
- // Hidden single-character span for measuring character cell dimensions
152
+ // Hidden single-character span for measuring character cell dimensions.
153
+ // fontFamily must be set explicitly to match _cmdList — without it the span
154
+ // inherits from the page font, giving a wrong character width.
153
155
  this._charMeasure = document.createElement('span');
154
156
  this._charMeasure.className = 'terminal__char-measure';
157
+ this._charMeasure.style.fontFamily = `'${font}', monospace`;
155
158
  this._charMeasure.textContent = 'X';
156
159
  this._charMeasure.setAttribute('aria-hidden', 'true');
157
160
  parent.appendChild(this._charMeasure);
158
161
 
159
- // Measure on first paint, then track container resizes
162
+ // Measure on first paint, then re-measure once the webfont is ready
163
+ // (the setTimeout fires before the Google Font downloads, so the initial
164
+ // measurement uses the fallback font; document.fonts.ready corrects it).
160
165
  setTimeout(() => this._measureAndSetSize(), 0);
166
+ if (document.fonts) {
167
+ document.fonts.ready.then(() => this._measureAndSetSize());
168
+ }
161
169
  if (typeof ResizeObserver !== 'undefined') {
162
170
  new ResizeObserver(() => this._measureAndSetSize()).observe(parent);
163
171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brsh",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "description": "A unix like shell written in javascript",
5
5
  "main": "./dist/shell.min.js",
6
6
  "module": "./dist/shell.es.js",