{"size": 2046, "ext": "js", "max_stars_repo_path": "src/utils/loaded.js", "max_stars_repo_name": "Doodle3D/Doodle3D-Core", "max_stars_repo_stars_event_min_datetime": "2021-06-01T14:22:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-11T17:17:41.000Z", "max_issues_repo_path": "src/utils/loaded.js", "max_issues_repo_name": "GreaZeY/Doodle3D-Core", "max_issues_repo_issues_event_min_datetime": "2022-01-27T16:15:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T16:15:44.000Z", "max_forks_repo_path": "src/utils/loaded.js", "max_forks_repo_name": "GreaZeY/Doodle3D-Core", "max_forks_repo_forks_event_min_datetime": "2021-06-22T21:59:37.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-21T09:50:33.000Z"}
{"max_stars_count": 4, "max_issues_count": 1, "max_forks_count": 3, "avg_line_length": 44.4782608696, "max_line_length": 104, "alphanum_fraction": 0.6915933529}
import { FONT_FACE } from '../constants/general.js';
import * as contextTools from '../constants/contextTools.js';
import FontLoaded from 'font-loaded';
import { load as loadPattern } from '../d2/Shape.js';
import { load as loadMatcapMaterial } from '../d3/MatcapMaterial.js';
import jss from 'jss';
import abril_url from '../../fonts/abril-fatface-v12-latin-regular.woff';
import bellefair_url from '../../fonts/bellefair-v6-latin-regular.woff';
import fascinate_url from '../../fonts/fascinate-v11-latin-regular.woff';
import joti_url from '../../fonts/joti-one-v11-latin-regular.woff';
import lobster_url from '../../fonts/lobster-v23-latin-regular.woff';
import oswald_url from '../../fonts/oswald-v36-latin-regular.woff';
import play_url from '../../fonts/play-v12-latin-regular.woff';
import ranga_url from '../../fonts/ranga-v8-latin-regular.woff';

const fontFaces = [
  { url: abril_url,     family: FONT_FACE[contextTools.ABRIL_FATFACE], },
  { url: bellefair_url, family: FONT_FACE[contextTools.BELLEFAIR], },
  { url: fascinate_url, family: FONT_FACE[contextTools.FASCINATE], },
  { url: joti_url,      family: FONT_FACE[contextTools.JOTI_ONE], },
  { url: lobster_url,   family: FONT_FACE[contextTools.LOBSTER], },
  { url: oswald_url,    family: FONT_FACE[contextTools.OSWALD], },
  { url: play_url,      family: FONT_FACE[contextTools.PLAY], },
  { url: ranga_url,     family: FONT_FACE[contextTools.RANGA], },
];

jss.createStyleSheet({
    '@font-face': fontFaces.map(({ url, family }) => ({
        'font-family': family,
        'src': `url("${url}") format("woff")`
    })),
}).attach();

const loadFont = font => {
  const fontLoaded = new FontLoaded(font);
  return new Promise((resolve, reject) => {
    fontLoaded.on('load', resolve);
    fontLoaded.on('error', reject);
  });
};
export const loadFonts = Promise.all(Object.values(FONT_FACE).map(loadFont));

let loaded = false;
export const load = Promise.all([loadFonts, loadPattern, loadMatcapMaterial]).then(() => loaded = true);
export const isLoaded = () => loaded;
