From 6e8fb894da86f4534faf9d38b25457c8202e532b Mon Sep 17 00:00:00 2001 From: Tal Bereznitskey Date: Sat, 18 Apr 2020 20:33:20 +0300 Subject: [PATCH] Align to project --- src/js/index.jsx | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/js/index.jsx b/src/js/index.jsx index a444e4f..7d12915 100644 --- a/src/js/index.jsx +++ b/src/js/index.jsx @@ -5,7 +5,7 @@ import { createFileTree, createRootElement, getBrowserApi } from './lib' import './style.css' -const { document, MutationObserver, parseInt = Number.parseInt } = window +const { document, MutationObserver, FontFace, parseInt = Number.parseInt } = window let observer const observe = () => { @@ -65,20 +65,24 @@ const renderTree = () => { } const loadFonts = () => { - [ + const fonts = [ { name: 'FontAwesome', fileName: 'fontawesome.woff2' }, { name: 'Mfizz', fileName: 'mfixx.woff2' }, { name: 'Devicons', fileName: 'devopicons.woff2' }, { name: 'file-icons', fileName: 'file-icons.woff2' }, - { name: 'octicons', fileName: 'octicons.woff2' }, + { name: 'octicons', fileName: 'octicons.woff2' } ] - .map(({ name, fileName }) => new FontFace(name, + + fonts + .map(({ name, fileName }) => new FontFace( + name, `url("${getBrowserApi().runtime.getURL(`fonts/${fileName}`)}") format("woff2")`, - { - style: 'normal', - weight: 'normal' - })) - .forEach(async fontFace => await fontFace.load().then(loadedFont => document.fonts.add(loadedFont))) + { style: 'normal', weight: 'normal' } + )) + .forEach(async fontFace => { + const loadedFont = await fontFace.load() + document.fonts.add(loadedFont) + }) } const start = () => {