Skip to content

Commit

Permalink
fix wrong calculation of characters with custom font #892
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Aug 1, 2023
1 parent 20e06c9 commit 8bf0733
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 39 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## 2.37.1
### Bugfix
* fix wrong calculation of characters with custom font [#892](https://github.com/jcubic/jquery.terminal/issues/892)

## 2.37.0
### Features
* add `rpc` interceptor [#883](https://github.com/jcubic/jquery.terminal/issues/883)
Expand Down
22 changes: 11 additions & 11 deletions README.md
@@ -1,14 +1,14 @@
<h1 align="center">
<img src="https://github.com/jcubic/jquery.terminal/blob/master/assets/ascii_art.svg?raw=true&ver=2.37.0"
<img src="https://github.com/jcubic/jquery.terminal/blob/devel/assets/ascii_art.svg?raw=true&ver=DEV"
alt="ASCII Art that represent text jQuery Terminal - JavaScript Library for Web Based Terminal Emulators" />
</h1>

[JavaScript Library for Web Based Terminal Emulators](https://terminal.jcubic.pl)

[![npm](https://img.shields.io/badge/npm-2.37.0-blue.svg)](https://www.npmjs.com/package/jquery.terminal)
![bower](https://img.shields.io/badge/bower-2.37.0-yellow.svg)
[![Build and test](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml/badge.svg?branch=master&event=push)](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=master&75da0f6ae07388cf17379f7dcd13e04f)](https://coveralls.io/github/jcubic/jquery.terminal?branch=master)
[![npm](https://img.shields.io/badge/npm-DEV-blue.svg)](https://www.npmjs.com/package/jquery.terminal)
![bower](https://img.shields.io/badge/bower-DEV-yellow.svg)
[![Build and test](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml/badge.svg?branch=devel&event=push)](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&75da0f6ae07388cf17379f7dcd13e04f)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
![NPM Downloads](https://img.shields.io/npm/dm/jquery.terminal.svg?style=flat)
[![jsDelivr Downloads](https://data.jsdelivr.com/v1/package/npm/jquery.terminal/badge?style=rounded&n=1)](https://www.jsdelivr.com/package/npm/jquery.terminal)
[![Paid Support](https://img.shields.io/badge/paid-support-354465.svg)](https://support.jcubic.pl/)
Expand Down Expand Up @@ -87,7 +87,7 @@ You can test current version at this URL:

or if it doesn't use latest version (because of jsDelivr cache) you can force it with this URL:

* [https://jcubic.github.io/jquery.terminal/?ver=2.37.0](https://jcubic.github.io/jquery.terminal/?ver=2.37.0)
* [https://jcubic.github.io/jquery.terminal/?ver=DEV](https://jcubic.github.io/jquery.terminal/?ver=DEV)

And development version using:

Expand All @@ -106,20 +106,20 @@ or use jsDelivr:

```

Then include js/jquery.terminal-2.37.0.min.js and css/jquery.terminal-2.37.0.min.css
Then include js/jquery.terminal-DEV.min.js and css/jquery.terminal-DEV.min.css

You can grab the files from CDN:

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.37.0/js/jquery.terminal.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.37.0/css/jquery.terminal.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/DEV/js/jquery.terminal.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/DEV/css/jquery.terminal.min.css" rel="stylesheet"/>
```

or

```html
<script src="https://cdn.jsdelivr.net/npm/jquery.terminal@2.37.0/js/jquery.terminal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery.terminal@2.37.0/css/jquery.terminal.min.css">
<script src="https://cdn.jsdelivr.net/npm/jquery.terminal@DEV/js/jquery.terminal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery.terminal@DEV/css/jquery.terminal.min.css">
```

If you always want latest version, you can get it from [unpkg](https://unpkg.com/) without specifying version,
Expand Down
2 changes: 1 addition & 1 deletion css/emoji.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions css/jquery.terminal-2.37.0.css
Expand Up @@ -4,15 +4,15 @@
* __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ /
* / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__
* \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
* \/ /____/ version 2.37.0
* \/ /____/ version DEV
* http://terminal.jcubic.pl
*
* This file is part of jQuery Terminal.
*
* Copyright (c) 2011-2023 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
*
* Date: Sun, 30 Jul 2023 18:29:44 +0000
* Date: Tue, 01 Aug 2023 21:24:16 +0000
*/
.terminal .terminal-output .format, .cmd .format,
.cmd-prompt, .cmd-prompt div {
Expand Down
4 changes: 2 additions & 2 deletions css/jquery.terminal-2.37.0.min.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions css/jquery.terminal.css
Expand Up @@ -4,15 +4,15 @@
* __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ /
* / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__
* \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
* \/ /____/ version 2.37.0
* \/ /____/ version DEV
* http://terminal.jcubic.pl
*
* This file is part of jQuery Terminal.
*
* Copyright (c) 2011-2023 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
*
* Date: Sun, 30 Jul 2023 18:29:44 +0000
* Date: Tue, 01 Aug 2023 21:24:16 +0000
*/
.terminal .terminal-output .format, .cmd .format,
.cmd-prompt, .cmd-prompt div {
Expand Down
4 changes: 2 additions & 2 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.

23 changes: 18 additions & 5 deletions js/jquery.terminal-2.37.0.js
Expand Up @@ -4,7 +4,7 @@
* __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ /
* / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__
* \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
* \/ /____/ version 2.37.0
* \/ /____/ version DEV
*
* This file is part of jQuery Terminal. https://terminal.jcubic.pl
*
Expand Down Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Sun, 30 Jul 2023 18:29:43 +0000
* Date: Tue, 01 Aug 2023 21:24:15 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -5277,8 +5277,8 @@
}
// -------------------------------------------------------------------------
$.terminal = {
version: '2.37.0',
date: 'Sun, 30 Jul 2023 18:29:43 +0000',
version: 'DEV',
date: 'Tue, 01 Aug 2023 21:24:15 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -11624,7 +11624,6 @@
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 @@ -12180,6 +12179,8 @@
pixel_density = get_pixel_size();
self.resize();
}, options);
$('<div class="terminal-font-forcer terminal-hidden">x<div>')
.appendTo(self);
}
function bottom_detect(intersections) {
is_bottom_detected = intersections[0].intersectionRatio >= 0.9;
Expand Down Expand Up @@ -12275,9 +12276,21 @@
// don't make sense
observe_visibility();
}
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;
}
// wait for custom font to load #892
if (document.fonts && document.fonts.ready) {
document.fonts.ready.then(command_queue.resolve);
calculate_char_size()
} else {
command_queue.resolve();
}
Expand Down
6 changes: 3 additions & 3 deletions js/jquery.terminal-2.37.0.min.js

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion js/jquery.terminal-src.js
Expand Up @@ -11624,7 +11624,6 @@
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 @@ -12180,6 +12179,8 @@
pixel_density = get_pixel_size();
self.resize();
}, options);
$('<div class="terminal-font-forcer terminal-hidden">x<div>')
.appendTo(self);
}
function bottom_detect(intersections) {
is_bottom_detected = intersections[0].intersectionRatio >= 0.9;
Expand Down Expand Up @@ -12275,9 +12276,21 @@
// don't make sense
observe_visibility();
}
function have_custom_font(term) {

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

View workflow job for this annotation

GitHub Actions / build

'have_custom_font' is defined but never used
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 12285 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;
}
// wait for custom font to load #892
if (document.fonts && document.fonts.ready) {
document.fonts.ready.then(command_queue.resolve);
calculate_char_size()

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

View workflow job for this annotation

GitHub Actions / build

Missing semicolon
} else {
command_queue.resolve();
}
Expand Down
23 changes: 18 additions & 5 deletions js/jquery.terminal.js
Expand Up @@ -4,7 +4,7 @@
* __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ /
* / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__
* \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
* \/ /____/ version 2.37.0
* \/ /____/ version DEV
*
* This file is part of jQuery Terminal. https://terminal.jcubic.pl
*
Expand Down Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Sun, 30 Jul 2023 18:29:43 +0000
* Date: Tue, 01 Aug 2023 21:24:15 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -5277,8 +5277,8 @@
}
// -------------------------------------------------------------------------
$.terminal = {
version: '2.37.0',
date: 'Sun, 30 Jul 2023 18:29:43 +0000',
version: 'DEV',
date: 'Tue, 01 Aug 2023 21:24:15 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -11624,7 +11624,6 @@
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 @@ -12180,6 +12179,8 @@
pixel_density = get_pixel_size();
self.resize();
}, options);
$('<div class="terminal-font-forcer terminal-hidden">x<div>')
.appendTo(self);
}
function bottom_detect(intersections) {
is_bottom_detected = intersections[0].intersectionRatio >= 0.9;
Expand Down Expand Up @@ -12275,9 +12276,21 @@
// don't make sense
observe_visibility();
}
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;
}
// wait for custom font to load #892
if (document.fonts && document.fonts.ready) {
document.fonts.ready.then(command_queue.resolve);
calculate_char_size()
} else {
command_queue.resolve();
}
Expand Down
6 changes: 3 additions & 3 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 8bf0733

Please sign in to comment.