Skip to content

Commit

Permalink
wait for the custom fonts to load #892
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Jul 29, 2023
1 parent aa14469 commit 42a081e
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,6 +1,7 @@
## 2.37.0
### Features
* add `rpc` interceptor [#883](https://github.com/jcubic/jquery.terminal/issues/883)
* wait for the custom fonts to load [#892](https://github.com/jcubic/jquery.terminal/issues/892)
### Bugfix
* fix CMD wrapping when prompt is empty [#882](https://github.com/jcubic/jquery.terminal/issues/882)
* fix paused terminal when using array as interpreter and RPC without system describe
Expand Down
15 changes: 14 additions & 1 deletion css/jquery.terminal-2.36.0.css
Expand Up @@ -12,7 +12,7 @@
* Copyright (c) 2011-2023 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
*
* Date: Sat, 29 Jul 2023 12:03:58 +0000
* Date: Sat, 29 Jul 2023 13:03:03 +0000
*/
.terminal .terminal-output .format, .cmd .format,
.cmd-prompt, .cmd-prompt div {
Expand Down Expand Up @@ -267,6 +267,7 @@ body.full-screen-terminal .terminal {
.terminal-output > :not(.raw) span:not(.fas):not(.far):not(.fa),
.terminal-output > :not(.raw) a,
.cmd,
.terminal-font-forcer,
.cmd span:not(.fas):not(.far):not(.fa) {
font-family: monospace;
font-family: var(--font, monospace);
Expand Down Expand Up @@ -1141,6 +1142,18 @@ terminal .terminal-output > div {
scrollbar-color: var(--color, #aaa) var(--background, #000);
scrollbar-width: thin;
}
/* visially hidden */
.terminal-hidden {
position: absolute !important;
width: 1px !important;
height: 1px !important;
padding: 0 !important;
margin: -1px !important;
overflow: hidden !important;
clip: rect(0,0,0,0) !important;
white-space: nowrap !important;
border: 0 !important;
}
/*
* Allow to change scrollbar color
*/
Expand Down
6 changes: 3 additions & 3 deletions css/jquery.terminal-2.36.0.min.css

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions css/jquery.terminal-src.css
Expand Up @@ -267,6 +267,7 @@ body.full-screen-terminal .terminal {
.terminal-output > :not(.raw) span:not(.fas):not(.far):not(.fa),
.terminal-output > :not(.raw) a,
.cmd,
.terminal-font-forcer,
.cmd span:not(.fas):not(.far):not(.fa) {
font-family: monospace;
font-family: var(--font, monospace);
Expand Down Expand Up @@ -1141,6 +1142,18 @@ terminal .terminal-output > div {
scrollbar-color: var(--color, #aaa) var(--background, #000);
scrollbar-width: thin;
}
/* visially hidden */
.terminal-hidden {
position: absolute !important;
width: 1px !important;
height: 1px !important;
padding: 0 !important;
margin: -1px !important;
overflow: hidden !important;
clip: rect(0,0,0,0) !important;
white-space: nowrap !important;
border: 0 !important;
}
/*
* Allow to change scrollbar color
*/
Expand Down
15 changes: 14 additions & 1 deletion css/jquery.terminal.css
Expand Up @@ -12,7 +12,7 @@
* Copyright (c) 2011-2023 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
*
* Date: Sat, 29 Jul 2023 12:03:58 +0000
* Date: Sat, 29 Jul 2023 13:03:03 +0000
*/
.terminal .terminal-output .format, .cmd .format,
.cmd-prompt, .cmd-prompt div {
Expand Down Expand Up @@ -267,6 +267,7 @@ body.full-screen-terminal .terminal {
.terminal-output > :not(.raw) span:not(.fas):not(.far):not(.fa),
.terminal-output > :not(.raw) a,
.cmd,
.terminal-font-forcer,
.cmd span:not(.fas):not(.far):not(.fa) {
font-family: monospace;
font-family: var(--font, monospace);
Expand Down Expand Up @@ -1141,6 +1142,18 @@ terminal .terminal-output > div {
scrollbar-color: var(--color, #aaa) var(--background, #000);
scrollbar-width: thin;
}
/* visially hidden */
.terminal-hidden {
position: absolute !important;
width: 1px !important;
height: 1px !important;
padding: 0 !important;
margin: -1px !important;
overflow: hidden !important;
clip: rect(0,0,0,0) !important;
white-space: nowrap !important;
border: 0 !important;
}
/*
* Allow to change scrollbar color
*/
Expand Down
6 changes: 3 additions & 3 deletions css/jquery.terminal.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/jquery.terminal.min.css.map

Large diffs are not rendered by default.

17 changes: 12 additions & 5 deletions js/jquery.terminal-2.36.0.js
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Sat, 29 Jul 2023 11:57:12 +0000
* Date: Sat, 29 Jul 2023 13:06:55 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -246,9 +246,10 @@
function DelayQueue() {
var callbacks = $.Callbacks();
var resolved = false;
var self = this;
this.resolve = function() {
callbacks.fire();
resolved = true;
self.resolved = resolved = true;
};
this.add = function(fn) {
if (resolved) {
Expand Down Expand Up @@ -5277,7 +5278,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Sat, 29 Jul 2023 11:57:12 +0000',
date: 'Sat, 29 Jul 2023 13:06:55 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -11374,7 +11375,7 @@
}
$(window).off('blur', blur_terminal).
off('focus', focus_terminal);
self.find('.terminal-fill, .terminal-font')
self.find('.terminal-fill, .terminal-font, .terminal-font-forcer')
.remove();
self.stopTime();
terminals.remove(terminal_id);
Expand Down Expand Up @@ -11623,6 +11624,7 @@
requests.push(xhr);
});
var scroller = $('<div class="terminal-scroller"/>').appendTo(self);
$('<div class="terminal-font-forcer terminal-hidden">x<div>').appendTo(self);
var wrapper = $('<div class="terminal-wrapper"/>').appendTo(scroller);
$(broken_image).hide().appendTo(wrapper);
var font_resizer = $('<div class="terminal-font">&nbsp;</div>').appendTo(self);
Expand Down Expand Up @@ -12273,7 +12275,12 @@
// don't make sense
observe_visibility();
}
command_queue.resolve();
// wait for custom font to load #892
if (document.fonts && document.fonts.ready) {
document.fonts.ready.then(command_queue.resolve);
} else {
command_queue.resolve();
}
// touch devices need touch event to get virtual keyboard
if (enabled && self.is(':visible') && !is_mobile) {
self.focus(undefined, true);
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-2.36.0.min.js

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions js/jquery.terminal-src.js
Expand Up @@ -246,9 +246,10 @@
function DelayQueue() {
var callbacks = $.Callbacks();
var resolved = false;
var self = this;
this.resolve = function() {
callbacks.fire();
resolved = true;
self.resolved = resolved = true;
};
this.add = function(fn) {
if (resolved) {
Expand Down Expand Up @@ -11374,7 +11375,7 @@
}
$(window).off('blur', blur_terminal).
off('focus', focus_terminal);
self.find('.terminal-fill, .terminal-font')
self.find('.terminal-fill, .terminal-font, .terminal-font-forcer')
.remove();
self.stopTime();
terminals.remove(terminal_id);
Expand Down Expand Up @@ -11623,6 +11624,7 @@
requests.push(xhr);
});
var scroller = $('<div class="terminal-scroller"/>').appendTo(self);
$('<div class="terminal-font-forcer terminal-hidden">x<div>').appendTo(self);
var wrapper = $('<div class="terminal-wrapper"/>').appendTo(scroller);
$(broken_image).hide().appendTo(wrapper);
var font_resizer = $('<div class="terminal-font">&nbsp;</div>').appendTo(self);
Expand Down Expand Up @@ -12273,7 +12275,12 @@
// don't make sense
observe_visibility();
}
command_queue.resolve();
// wait for custom font to load #892
if (document.fonts && document.fonts.ready) {
document.fonts.ready.then(command_queue.resolve);

Check failure on line 12280 in js/jquery.terminal-src.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 16 spaces but found 17
} else {
command_queue.resolve();
}
// touch devices need touch event to get virtual keyboard
if (enabled && self.is(':visible') && !is_mobile) {
self.focus(undefined, true);
Expand Down
17 changes: 12 additions & 5 deletions js/jquery.terminal.js
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Sat, 29 Jul 2023 11:57:12 +0000
* Date: Sat, 29 Jul 2023 13:06:55 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -246,9 +246,10 @@
function DelayQueue() {
var callbacks = $.Callbacks();
var resolved = false;
var self = this;
this.resolve = function() {
callbacks.fire();
resolved = true;
self.resolved = resolved = true;
};
this.add = function(fn) {
if (resolved) {
Expand Down Expand Up @@ -5277,7 +5278,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Sat, 29 Jul 2023 11:57:12 +0000',
date: 'Sat, 29 Jul 2023 13:06:55 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -11374,7 +11375,7 @@
}
$(window).off('blur', blur_terminal).
off('focus', focus_terminal);
self.find('.terminal-fill, .terminal-font')
self.find('.terminal-fill, .terminal-font, .terminal-font-forcer')
.remove();
self.stopTime();
terminals.remove(terminal_id);
Expand Down Expand Up @@ -11623,6 +11624,7 @@
requests.push(xhr);
});
var scroller = $('<div class="terminal-scroller"/>').appendTo(self);
$('<div class="terminal-font-forcer terminal-hidden">x<div>').appendTo(self);
var wrapper = $('<div class="terminal-wrapper"/>').appendTo(scroller);
$(broken_image).hide().appendTo(wrapper);
var font_resizer = $('<div class="terminal-font">&nbsp;</div>').appendTo(self);
Expand Down Expand Up @@ -12273,7 +12275,12 @@
// don't make sense
observe_visibility();
}
command_queue.resolve();
// wait for custom font to load #892
if (document.fonts && document.fonts.ready) {
document.fonts.ready.then(command_queue.resolve);
} else {
command_queue.resolve();
}
// touch devices need touch event to get virtual keyboard
if (enabled && self.is(':visible') && !is_mobile) {
self.focus(undefined, true);
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/jquery.terminal.min.js.map

Large diffs are not rendered by default.

0 comments on commit 42a081e

Please sign in to comment.