Font: Add Hack Font back so we have consistent and expectable font rendering
This commit is contained in:
@@ -18,7 +18,8 @@ Major dependencies includes:
|
|||||||
- [iconv-lite](https://github.com/ashtuchkin/iconv-lite), Licensed under MIT license
|
- [iconv-lite](https://github.com/ashtuchkin/iconv-lite), Licensed under MIT license
|
||||||
- [buffer](https://github.com/feross/buffer), Licensed under MIT license
|
- [buffer](https://github.com/feross/buffer), Licensed under MIT license
|
||||||
- [fontfaceobserver](https://github.com/bramstein/fontfaceobserver), [View license](https://github.com/bramstein/fontfaceobserver/blob/master/LICENSE)
|
- [fontfaceobserver](https://github.com/bramstein/fontfaceobserver), [View license](https://github.com/bramstein/fontfaceobserver/blob/master/LICENSE)
|
||||||
- [Nerd Font](https://www.nerdfonts.com/), packaged by [@azurity/pure-nerd-font](http://github.com/azurity/pure-nerd-font)
|
- [Hack Font](https://github.com/source-foundry/Hack), [View license](https://github.com/source-foundry/Hack/blob/master/LICENSE.md)
|
||||||
|
- [Nerd Fonts](https://www.nerdfonts.com/), packaged by [@azurity/pure-nerd-font](http://github.com/azurity/pure-nerd-font)
|
||||||
includes icons from following fonts:
|
includes icons from following fonts:
|
||||||
- [Powerline Extra Symbols](https://github.com/ryanoasis/powerline-extra-symbols), Licensed under MIT license
|
- [Powerline Extra Symbols](https://github.com/ryanoasis/powerline-extra-symbols), Licensed under MIT license
|
||||||
- [Font Awesome](https://github.com/FortAwesome/Font-Awesome), [View license](https://github.com/FortAwesome/Font-Awesome/blob/6.x/LICENSE.txt)
|
- [Font Awesome](https://github.com/FortAwesome/Font-Awesome), [View license](https://github.com/FortAwesome/Font-Awesome/blob/6.x/LICENSE.txt)
|
||||||
|
|||||||
@@ -19,19 +19,20 @@
|
|||||||
|
|
||||||
@charset "utf-8";
|
@charset "utf-8";
|
||||||
|
|
||||||
|
@import "~hack-font/build/web/hack.css";
|
||||||
@import "~@azurity/pure-nerd-font/pure-nerd-font.css";
|
@import "~@azurity/pure-nerd-font/pure-nerd-font.css";
|
||||||
|
|
||||||
#connector-resource-preload-control-console {
|
#connector-resource-preload-control-console {
|
||||||
font-family: PureNerdFont;
|
font-family: PureNerdFont, Hack;
|
||||||
}
|
}
|
||||||
#connector-resource-preload-control-console::after {
|
#connector-resource-preload-control-console::after {
|
||||||
content: " ";
|
content: " ";
|
||||||
font-family: PureNerdFont;
|
font-family: PureNerdFont, Hack;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
#connector-resource-preload-control-console::before {
|
#connector-resource-preload-control-console::before {
|
||||||
content: " ";
|
content: " ";
|
||||||
font-family: PureNerdFont;
|
font-family: PureNerdFont, Hack;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<div class="screen-console">
|
<div class="screen-console">
|
||||||
<div
|
<div
|
||||||
class="console-console"
|
class="console-console"
|
||||||
:style="'font-family: ' + typeface + ', inherit'"
|
:style="'font-family: ' + typefaces + ', inherit'"
|
||||||
>
|
>
|
||||||
<h2 style="display: none">Console</h2>
|
<h2 style="display: none">Console</h2>
|
||||||
|
|
||||||
@@ -117,15 +117,15 @@ import { consoleScreenKeys } from "./screen_console_keys.js";
|
|||||||
import "./screen_console.css";
|
import "./screen_console.css";
|
||||||
import "xterm/css/xterm.css";
|
import "xterm/css/xterm.css";
|
||||||
|
|
||||||
const termTypeFace = "PureNerdFont";
|
const termTypeFaces = "PureNerdFont, Hack";
|
||||||
const termFallbackTypeFace = "monospace";
|
const termFallbackTypeFace = "\"Cascadia Code\" , monospace";
|
||||||
const termTypeFaceLoadTimeout = 3000;
|
const termTypeFaceLoadTimeout = 3000;
|
||||||
const termTypeFaceLoadError =
|
const termTypeFaceLoadError =
|
||||||
'Remote font "' +
|
'Remote font ' +
|
||||||
termTypeFace +
|
termTypeFaces +
|
||||||
'" is unavailable, using "' +
|
' is unavailable, using ' +
|
||||||
termFallbackTypeFace +
|
termFallbackTypeFace +
|
||||||
'" instead until the remote font is loaded';
|
' instead until the remote font is loaded';
|
||||||
const termDefaultFontSize = 16;
|
const termDefaultFontSize = 16;
|
||||||
const termMinFontSize = 8;
|
const termMinFontSize = 8;
|
||||||
const termMaxFontSize = 36;
|
const termMaxFontSize = 36;
|
||||||
@@ -142,7 +142,7 @@ class Term {
|
|||||||
allowTransparency: false,
|
allowTransparency: false,
|
||||||
cursorBlink: true,
|
cursorBlink: true,
|
||||||
cursorStyle: "block",
|
cursorStyle: "block",
|
||||||
fontFamily: termTypeFace + ", " + termFallbackTypeFace,
|
fontFamily: termTypeFaces + ", " + termFallbackTypeFace,
|
||||||
fontSize: this.fontSize,
|
fontSize: this.fontSize,
|
||||||
logLevel: process.env.NODE_ENV === "development" ? "info" : "off",
|
logLevel: process.env.NODE_ENV === "development" ? "info" : "off",
|
||||||
theme: {
|
theme: {
|
||||||
@@ -416,7 +416,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
screenKeys: consoleScreenKeys,
|
screenKeys: consoleScreenKeys,
|
||||||
term: new Term(this.control),
|
term: new Term(this.control),
|
||||||
typeface: termTypeFace,
|
typefaces: termTypeFaces,
|
||||||
runner: null,
|
runner: null,
|
||||||
eventHandlers: {
|
eventHandlers: {
|
||||||
keydown: null,
|
keydown: null,
|
||||||
@@ -456,25 +456,22 @@ export default {
|
|||||||
this.deinit();
|
this.deinit();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadRemoteFont(typeface, timeout) {
|
loadRemoteFont(typefaces, timeout) {
|
||||||
return Promise.all([
|
const tfs = typefaces.split(",");
|
||||||
new FontFaceObserver(typeface).load(null, timeout),
|
let observers = [];
|
||||||
new FontFaceObserver(typeface, {
|
for (let v in tfs) {
|
||||||
|
observers.push(new FontFaceObserver(tfs[v].trim()).load(null, timeout))
|
||||||
|
observers.push(new FontFaceObserver(tfs[v].trim(), {
|
||||||
weight: "bold",
|
weight: "bold",
|
||||||
}).load(null, timeout),
|
}).load(null, timeout))
|
||||||
]);
|
}
|
||||||
|
return Promise.all(observers);
|
||||||
},
|
},
|
||||||
async retryLoadRemoteFont(typeface, timeout, onSuccess) {
|
async retryLoadRemoteFont(typefaces, timeout, onSuccess) {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (self.term.destroyed()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
onSuccess(await self.loadRemoteFont(typeface, timeout));
|
onSuccess(await self.loadRemoteFont(typefaces, timeout));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Retry
|
// Retry
|
||||||
@@ -483,41 +480,29 @@ export default {
|
|||||||
},
|
},
|
||||||
async openTerm(root, callbacks) {
|
async openTerm(root, callbacks) {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await self.loadRemoteFont(termTypeFace, termTypeFaceLoadTimeout);
|
await self.loadRemoteFont(termTypeFaces, termTypeFaceLoadTimeout);
|
||||||
|
|
||||||
if (self.term.destroyed()) {
|
if (self.term.destroyed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
root.innerHTML = "";
|
root.innerHTML = "";
|
||||||
|
|
||||||
self.term.init(root);
|
self.term.init(root);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.term.destroyed()) {
|
if (self.term.destroyed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
root.innerHTML = "";
|
root.innerHTML = "";
|
||||||
|
|
||||||
callbacks.warn(termTypeFaceLoadError, false);
|
callbacks.warn(termTypeFaceLoadError, false);
|
||||||
|
|
||||||
self.term.setFont(termFallbackTypeFace);
|
self.term.setFont(termFallbackTypeFace);
|
||||||
self.term.init(root);
|
self.term.init(root);
|
||||||
|
self.retryLoadRemoteFont(termTypeFaces, termTypeFaceLoadTimeout, () => {
|
||||||
self.retryLoadRemoteFont(termTypeFace, termTypeFaceLoadTimeout, () => {
|
|
||||||
if (self.term.destroyed()) {
|
if (self.term.destroyed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
self.term.setFont(termTypeFaces);
|
||||||
self.term.setFont(termTypeFace);
|
|
||||||
|
|
||||||
callbacks.warn(termTypeFaceLoadError, true);
|
callbacks.warn(termTypeFaceLoadError, true);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user