Remove fontfaceobserver

This commit is contained in:
Ken-Håvard Lieng 2020-05-19 01:29:22 +02:00
parent e05118a29b
commit 902e4da46f
4 changed files with 173 additions and 185 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,22 +1,15 @@
import FontFaceObserver from 'fontfaceobserver';
import { setCharWidth } from 'state/app'; import { setCharWidth } from 'state/app';
import { stringWidth } from 'utils'; import { stringWidth } from 'utils';
export default function fonts({ store }) { export default async function fonts({ store }) {
let { charWidth } = localStorage; let { charWidth } = localStorage;
if (charWidth) { if (charWidth) {
store.dispatch(setCharWidth(parseFloat(charWidth))); store.dispatch(setCharWidth(parseFloat(charWidth)));
} } else {
await document.fonts.load('16px Roboto Mono');
new FontFaceObserver('Roboto Mono').load().then(() => {
if (!charWidth) {
charWidth = stringWidth(' ', '16px Roboto Mono'); charWidth = stringWidth(' ', '16px Roboto Mono');
store.dispatch(setCharWidth(charWidth)); store.dispatch(setCharWidth(charWidth));
localStorage.charWidth = charWidth; localStorage.charWidth = charWidth;
} }
});
new FontFaceObserver('Montserrat').load();
new FontFaceObserver('Montserrat', { weight: 700 }).load();
new FontFaceObserver('Roboto Mono', { weight: 700 }).load();
} }

View File

@ -5,7 +5,7 @@
"license": "MIT", "license": "MIT",
"main": "index.js", "main": "index.js",
"browserslist": [ "browserslist": [
"Edge >= 16", "Edge >= 79",
"Firefox >= 60", "Firefox >= 60",
"Chrome >= 61", "Chrome >= 61",
"Safari >= 10.1", "Safari >= 10.1",
@ -64,7 +64,6 @@
"autolinker": "^3.14.1", "autolinker": "^3.14.1",
"backo": "^1.1.0", "backo": "^1.1.0",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"fontfaceobserver": "^2.0.9",
"formik": "^2.1.4", "formik": "^2.1.4",
"history": "^5.0.0-beta.8", "history": "^5.0.0-beta.8",
"hsluv": "^0.1.0", "hsluv": "^0.1.0",

View File

@ -3778,10 +3778,6 @@ flush-write-stream@^1.0.0, flush-write-stream@^1.0.2:
inherits "^2.0.3" inherits "^2.0.3"
readable-stream "^2.3.6" readable-stream "^2.3.6"
fontfaceobserver@^2.0.9:
version "2.1.0"
resolved "https://registry.yarnpkg.com/fontfaceobserver/-/fontfaceobserver-2.1.0.tgz#e2705d293e2c585a6531c2a722905657317a2991"
for-in@^1.0.1, for-in@^1.0.2: for-in@^1.0.1, for-in@^1.0.2:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"