Skip to content

Commit

Permalink
force recalcualte char size after custom font load #892
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Aug 2, 2023
1 parent b2e040c commit f962b55
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 17 deletions.
2 changes: 1 addition & 1 deletion css/jquery.terminal-2.37.0.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Copyright (c) 2011-2023 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
*
* Date: Tue, 01 Aug 2023 21:24:16 +0000
* Date: Wed, 02 Aug 2023 15:54:42 +0000
*/
.terminal .terminal-output .format, .cmd .format,
.cmd-prompt, .cmd-prompt div {
Expand Down
2 changes: 1 addition & 1 deletion css/jquery.terminal-2.37.0.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/jquery.terminal.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Copyright (c) 2011-2023 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
*
* Date: Tue, 01 Aug 2023 21:24:16 +0000
* Date: Wed, 02 Aug 2023 15:54:42 +0000
*/
.terminal .terminal-output .format, .cmd .format,
.cmd-prompt, .cmd-prompt div {
Expand Down
2 changes: 1 addition & 1 deletion 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.

24 changes: 21 additions & 3 deletions js/jquery.terminal-2.37.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Tue, 01 Aug 2023 21:31:01 +0000
* Date: Wed, 02 Aug 2023 15:54:41 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -5278,7 +5278,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Tue, 01 Aug 2023 21:31:01 +0000',
date: 'Wed, 02 Aug 2023 15:54:41 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -7320,6 +7320,18 @@
return Array.isArray(object);
}
// -----------------------------------------------------------------------
function have_custom_font(term) {
var font = $(term).css('--font');
if (!font) {
return false;
}
var fonts = Array.from(document.fonts.keys());
var font = fonts.find(function(face) {
return face.family === font;
});
return !!font;
}
// -----------------------------------------------------------------------
function get_type(object) {
if (typeof object === 'function') {
return 'function';
Expand Down Expand Up @@ -12278,7 +12290,13 @@
}
// wait for custom font to load #892
if (document.fonts && document.fonts.ready) {
document.fonts.ready.then(command_queue.resolve);
document.fonts.ready.then(function() {
if (have_custom_font(self)) {
calculate_char_size();
self.resize();
}
command_queue.resolve();
});
} else {
command_queue.resolve();
}
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-2.37.0.min.js

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion js/jquery.terminal-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -7320,6 +7320,18 @@
return Array.isArray(object);
}
// -----------------------------------------------------------------------
function have_custom_font(term) {
var font = $(term).css('--font');
if (!font) {
return false;
}
var fonts = Array.from(document.fonts.keys());
var font = fonts.find(function(face) {

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

View workflow job for this annotation

GitHub Actions / build

'font' is already defined
return face.family === font;
});
return !!font;
}
// -----------------------------------------------------------------------
function get_type(object) {
if (typeof object === 'function') {
return 'function';
Expand Down Expand Up @@ -12278,7 +12290,13 @@
}
// wait for custom font to load #892
if (document.fonts && document.fonts.ready) {
document.fonts.ready.then(command_queue.resolve);
document.fonts.ready.then(function() {
if (have_custom_font(self)) {
calculate_char_size();
self.resize();
}
command_queue.resolve();
});
} else {
command_queue.resolve();
}
Expand Down
24 changes: 21 additions & 3 deletions js/jquery.terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Tue, 01 Aug 2023 21:31:01 +0000
* Date: Wed, 02 Aug 2023 15:54:41 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -5278,7 +5278,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Tue, 01 Aug 2023 21:31:01 +0000',
date: 'Wed, 02 Aug 2023 15:54:41 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -7320,6 +7320,18 @@
return Array.isArray(object);
}
// -----------------------------------------------------------------------
function have_custom_font(term) {
var font = $(term).css('--font');
if (!font) {
return false;
}
var fonts = Array.from(document.fonts.keys());
var font = fonts.find(function(face) {
return face.family === font;
});
return !!font;
}
// -----------------------------------------------------------------------
function get_type(object) {
if (typeof object === 'function') {
return 'function';
Expand Down Expand Up @@ -12278,7 +12290,13 @@
}
// wait for custom font to load #892
if (document.fonts && document.fonts.ready) {
document.fonts.ready.then(command_queue.resolve);
document.fonts.ready.then(function() {
if (have_custom_font(self)) {
calculate_char_size();
self.resize();
}
command_queue.resolve();
});
} else {
command_queue.resolve();
}
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 f962b55

Please sign in to comment.