2017-06-21 08:40:28 +02:00
|
|
|
import { setCharWidth } from 'state/app';
|
2018-04-05 21:13:32 +02:00
|
|
|
import { stringWidth } from 'utils';
|
2017-05-26 08:20:00 +02:00
|
|
|
|
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;
|
2017-05-26 08:20:00 +02:00
|
|
|
if (charWidth) {
|
|
|
|
store.dispatch(setCharWidth(parseFloat(charWidth)));
|
2020-05-19 01:29:22 +02:00
|
|
|
} else {
|
|
|
|
await document.fonts.load('16px Roboto Mono');
|
2017-05-26 08:20:00 +02:00
|
|
|
|
2020-05-19 01:29:22 +02:00
|
|
|
charWidth = stringWidth(' ', '16px Roboto Mono');
|
|
|
|
store.dispatch(setCharWidth(charWidth));
|
|
|
|
localStorage.charWidth = charWidth;
|
|
|
|
}
|
2017-05-26 08:20:00 +02:00
|
|
|
}
|