feat: add Fixel font support
Adds Fixel Text as a new UI font option Allows font sources to load from direct URLs Keeps existing fontsource-based loading working
This commit is contained in:
@@ -4,6 +4,10 @@ const loadedFaces = new Set<string>();
|
|||||||
const pendingFaces = new Map<string, Promise<void>>();
|
const pendingFaces = new Map<string, Promise<void>>();
|
||||||
|
|
||||||
const buildFontUrl = (source: FontFaceSource, weight: number) => {
|
const buildFontUrl = (source: FontFaceSource, weight: number) => {
|
||||||
|
if ('urls' in source) {
|
||||||
|
return source.urls[weight];
|
||||||
|
}
|
||||||
|
|
||||||
const packageName = encodeURIComponent(source.packageName).replace('%40', '@').replace('%2F', '/');
|
const packageName = encodeURIComponent(source.packageName).replace('%40', '@').replace('%2F', '/');
|
||||||
return `https://cdn.jsdelivr.net/npm/${packageName}/files/${source.filePrefix}-latin-${weight}-normal.woff2`;
|
return `https://cdn.jsdelivr.net/npm/${packageName}/files/${source.filePrefix}-latin-${weight}-normal.woff2`;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,14 +1,23 @@
|
|||||||
export type UiFontOption = 'inter' | 'geist-sans' | 'atkinson-hyperlegible' | 'source-sans-3' | 'roboto' | 'noto-sans' | 'dm-sans' | 'manrope' | 'system';
|
export type UiFontOption = 'inter' | 'fixel' | 'geist-sans' | 'atkinson-hyperlegible' | 'source-sans-3' | 'roboto' | 'noto-sans' | 'dm-sans' | 'manrope' | 'system';
|
||||||
|
|
||||||
export type MonoFontOption = 'jetbrains-mono' | 'fira-code' | 'geist-mono' | 'commit-mono' | 'source-code-pro' | 'cascadia-code' | 'roboto-mono' | 'iosevka' | 'system-mono';
|
export type MonoFontOption = 'jetbrains-mono' | 'fira-code' | 'geist-mono' | 'commit-mono' | 'source-code-pro' | 'cascadia-code' | 'roboto-mono' | 'iosevka' | 'system-mono';
|
||||||
|
|
||||||
export interface FontFaceSource {
|
interface FontFaceSourceBase {
|
||||||
family: string;
|
family: string;
|
||||||
packageName: string;
|
|
||||||
filePrefix: string;
|
|
||||||
weights: number[];
|
weights: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface FontsourceFaceSource extends FontFaceSourceBase {
|
||||||
|
packageName: string;
|
||||||
|
filePrefix: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DirectFontFaceSource extends FontFaceSourceBase {
|
||||||
|
urls: Record<number, string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type FontFaceSource = FontsourceFaceSource | DirectFontFaceSource;
|
||||||
|
|
||||||
export interface FontOptionDefinition<T extends string> {
|
export interface FontOptionDefinition<T extends string> {
|
||||||
id: T;
|
id: T;
|
||||||
label: string;
|
label: string;
|
||||||
@@ -26,6 +35,21 @@ export const UI_FONT_OPTIONS: FontOptionDefinition<UiFontOption>[] = [
|
|||||||
stack: '"Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
|
stack: '"Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
|
||||||
source: { family: 'Inter', packageName: '@fontsource/inter', filePrefix: 'inter', weights: [400, 500, 600] }
|
source: { family: 'Inter', packageName: '@fontsource/inter', filePrefix: 'inter', weights: [400, 500, 600] }
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'fixel',
|
||||||
|
label: 'Fixel Text',
|
||||||
|
description: 'Humanist geometric sans-serif with full Ukrainian support.',
|
||||||
|
stack: '"Fixel Text", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
|
||||||
|
source: {
|
||||||
|
family: 'Fixel Text',
|
||||||
|
weights: [400, 500, 600],
|
||||||
|
urls: {
|
||||||
|
400: 'https://cdn.jsdelivr.net/gh/MacPaw/Fixel@f6ee910e98add47e830db87f1a754130506c11a2/fonts/webfonts/FixelText-Regular.woff2',
|
||||||
|
500: 'https://cdn.jsdelivr.net/gh/MacPaw/Fixel@f6ee910e98add47e830db87f1a754130506c11a2/fonts/webfonts/FixelText-Medium.woff2',
|
||||||
|
600: 'https://cdn.jsdelivr.net/gh/MacPaw/Fixel@f6ee910e98add47e830db87f1a754130506c11a2/fonts/webfonts/FixelText-SemiBold.woff2'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'geist-sans',
|
id: 'geist-sans',
|
||||||
label: 'Geist Sans',
|
label: 'Geist Sans',
|
||||||
|
|||||||
Reference in New Issue
Block a user