2017-05-26 06:20:00 +00:00
|
|
|
import FontFaceObserver from 'fontfaceobserver';
|
2017-06-21 06:40:28 +00:00
|
|
|
import { setCharWidth } from 'state/app';
|
2018-04-05 19:13:32 +00:00
|
|
|
import { stringWidth } from 'utils';
|
2017-05-26 06:20:00 +00:00
|
|
|
|
|
|
|
export default function fonts({ store }) {
|
2018-03-25 00:34:41 +00:00
|
|
|
let { charWidth } = localStorage;
|
2017-05-26 06:20:00 +00:00
|
|
|
if (charWidth) {
|
|
|
|
store.dispatch(setCharWidth(parseFloat(charWidth)));
|
|
|
|
}
|
|
|
|
|
|
|
|
new FontFaceObserver('Roboto Mono').load().then(() => {
|
|
|
|
if (!charWidth) {
|
|
|
|
charWidth = stringWidth(' ', '16px Roboto Mono');
|
|
|
|
store.dispatch(setCharWidth(charWidth));
|
|
|
|
localStorage.charWidth = charWidth;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
new FontFaceObserver('Montserrat').load();
|
|
|
|
new FontFaceObserver('Montserrat', { weight: 700 }).load();
|
|
|
|
new FontFaceObserver('Roboto Mono', { weight: 700 }).load();
|
|
|
|
}
|