Spaces:
Sleeping
Sleeping
File size: 3,067 Bytes
391a73c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | import * as fontkit from 'fontkit';
type Font = Omit<fontkit.Font, 'type'> & {
type: 'TTF' | 'WOFF' | 'WOFF2' | 'STANDARD';
encode?: (string: string) => number[];
};
type FontStyle = 'normal' | 'italic' | 'oblique';
type FontWeight = number | 'thin' | 'hairline' | 'ultralight' | 'extralight' | 'light' | 'normal' | 'medium' | 'semibold' | 'demibold' | 'bold' | 'ultrabold' | 'extrabold' | 'heavy' | 'black';
type FontDescriptor = {
fontFamily: string;
fontStyle?: FontStyle;
fontWeight?: FontWeight;
};
type RemoteOptions = {
method?: 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
headers?: Record<string, string>;
body?: any;
};
type FontSourceOptions = {
postscriptName?: string;
} & RemoteOptions;
type FontSource$1 = {
src: string;
fontStyle?: FontStyle;
fontWeight?: FontWeight;
} & FontSourceOptions;
type SingleLoad = {
family: string;
} & FontSource$1;
type BulkLoad = {
family: string;
fonts: FontSource$1[];
};
interface EmojiSourceUrl {
url: string;
format?: string;
withVariationSelectors?: boolean;
}
interface EmojiSourceBuilder {
builder: (code: string) => string;
withVariationSelectors?: boolean;
}
type EmojiSource = EmojiSourceUrl | EmojiSourceBuilder;
type HyphenationCallback = (word: string) => string[];
declare class FontSource {
src: string;
fontFamily: string;
fontStyle: FontStyle;
fontWeight: number;
data: Font | null;
options: FontSourceOptions;
loadResultPromise: Promise<void> | null;
constructor(src: string, fontFamily: string, fontStyle?: FontStyle, fontWeight?: number, options?: FontSourceOptions);
_load(): Promise<void>;
load(): Promise<void>;
}
declare class FontFamily {
family: string;
sources: FontSource[];
static create(family: string): FontFamily;
constructor(family: string);
register({ src, fontWeight, fontStyle, ...options }: Omit<SingleLoad, 'family'>): void;
resolve(descriptor: FontDescriptor): FontSource;
}
declare class FontStore {
fontFamilies: Record<string, FontFamily>;
emojiSource: EmojiSource | null;
constructor();
hyphenationCallback: HyphenationCallback | null;
register: (data: SingleLoad | BulkLoad) => void;
registerEmojiSource: (emojiSource: EmojiSource) => void;
registerHyphenationCallback: (callback: HyphenationCallback) => void;
getFont: (descriptor: FontDescriptor) => FontSource;
load: (descriptor: FontDescriptor) => Promise<void>;
reset: () => void;
clear: () => void;
getRegisteredFonts: () => Record<string, FontFamily>;
getEmojiSource: () => EmojiSource | null;
getHyphenationCallback: () => HyphenationCallback | null;
getRegisteredFontFamilies: () => string[];
}
type FontStoreType = FontStore;
export { type BulkLoad, type EmojiSource, type Font, type FontDescriptor, type FontSource$1 as FontSource, type FontSourceOptions, type FontStoreType, type FontStyle, type FontWeight, type HyphenationCallback, type RemoteOptions, type SingleLoad, FontStore as default };
|