forked from Blendman974/faceclaw
Refactor font handling; add image-compression estimation debug option
This commit is contained in:
1 parent
5a92637537
commit
964cd11785
15 files changed
+389
-130
No files matched your search
+22
-16
@@ -130,22 +130,6 @@ export class BdfFont {
|
||||
|
||||
const cachedEmbeddedFonts = new Map<string, BdfFont>();
|
||||
|
||||
export function loadEmbeddedTerminus12(): BdfFont {
|
||||
return loadEmbeddedFont("fonts/terminus/ter-u12n.bdf");
|
||||
}
|
||||
|
||||
export function loadEmbeddedTerminus16(): BdfFont {
|
||||
return loadEmbeddedFont("fonts/terminus/ter-u16n.bdf");
|
||||
}
|
||||
|
||||
export function loadEmbeddedTerminus24(): BdfFont {
|
||||
return loadEmbeddedFont("fonts/terminus/ter-u24n.bdf");
|
||||
}
|
||||
|
||||
export function loadEmbeddedTerminus32(): BdfFont {
|
||||
return loadEmbeddedFont("fonts/terminus/ter-u32n.bdf");
|
||||
}
|
||||
|
||||
function loadEmbeddedFont(path: string): BdfFont {
|
||||
const cached = cachedEmbeddedFonts.get(path);
|
||||
if (cached) {
|
||||
@@ -157,3 +141,25 @@ function loadEmbeddedFont(path: string): BdfFont {
|
||||
cachedEmbeddedFonts.set(path, font);
|
||||
return font;
|
||||
}
|
||||
|
||||
const embeddedFonts = {
|
||||
"terminus12": "fonts/terminus/ter-u12n.bdf",
|
||||
"terminus16": "fonts/terminus/ter-u16n.bdf",
|
||||
"terminus24": "fonts/terminus/ter-u24n.bdf",
|
||||
"terminus32": "fonts/terminus/ter-u32n.bdf",
|
||||
}
|
||||
type EmbeddedFontName = keyof typeof embeddedFonts;
|
||||
|
||||
export function getFont(font: EmbeddedFontName): BdfFont {
|
||||
return loadEmbeddedFont(embeddedFonts[font]);
|
||||
}
|
||||
|
||||
export function getDefaultSmallFont(): BdfFont {
|
||||
return getFont("terminus12");
|
||||
}
|
||||
export function getDefaultMediumFont(): BdfFont {
|
||||
return getFont("terminus16");
|
||||
}
|
||||
export function getDefaultLargeFont(): BdfFont {
|
||||
return getFont("terminus24");
|
||||
}
|
||||
Reference in new issue
Block a user