16 lines
449 B
JavaScript
Raw Normal View History

import { setCharWidth } from 'state/app';
import { stringWidth } from 'utils';
2020-05-19 01:29:22 +02:00
export default async function fonts({ store }) {
2018-03-25 01:34:41 +01:00
let { charWidth } = localStorage;
if (charWidth) {
store.dispatch(setCharWidth(parseFloat(charWidth)));
2020-05-19 01:29:22 +02:00
} else {
await document.fonts.load('16px Roboto Mono');
2020-05-19 01:29:22 +02:00
charWidth = stringWidth(' ', '16px Roboto Mono');
store.dispatch(setCharWidth(charWidth));
localStorage.charWidth = charWidth;
}
}