mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* Cleanup loading terminal fonts - Make list of possible fonts fully OCP - Only mark the loading of a font as 'causesSideEffects' - Make a view model for the terminal font preferences component - Move the TTF files next to where they are registered to help with finding them Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix tests Signed-off-by: Sebastian Malton <sebastian@malton.name> * Cleanup formatting and change model to presenter Signed-off-by: Sebastian Malton <sebastian@malton.name> Signed-off-by: Sebastian Malton <sebastian@malton.name>
28 lines
774 B
TypeScript
28 lines
774 B
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import { getInjectable } from "@ogre-tools/injectable";
|
|
import type { TerminalFont } from "./token";
|
|
|
|
export type LoadTerminalFont = (font: TerminalFont) => Promise<void>;
|
|
|
|
const loadTerminalFontInjectable = getInjectable({
|
|
id: "load-terminal-font",
|
|
instantiate: (): LoadTerminalFont => async (font) => {
|
|
const fontLoaded = document.fonts.check(`10px ${font.name}`);
|
|
|
|
if (fontLoaded) {
|
|
return;
|
|
}
|
|
|
|
const fontFace = new FontFace(font.name, `url(${font.url})`);
|
|
|
|
document.fonts.add(fontFace);
|
|
await fontFace.load();
|
|
},
|
|
causesSideEffects: true,
|
|
});
|
|
|
|
export default loadTerminalFontInjectable;
|