@pmndrs/uikit
Version:
Build performant 3D user interfaces with Three.js and yoga.
135 lines (134 loc) • 4.58 kB
TypeScript
import type { z } from 'zod';
import type { Signal } from '@preact/signals-core';
import type { Texture, TypedArray } from 'three';
import type { Properties } from '../properties/index.js';
import type { Container } from '../components/container.js';
export declare const fontWeightNames: {
readonly thin: 100;
readonly 'extra-light': 200;
readonly light: 300;
readonly normal: 400;
readonly medium: 500;
readonly 'semi-bold': 600;
readonly bold: 700;
readonly 'extra-bold': 800;
readonly black: 900;
readonly 'extra-black': 950;
};
export declare const FontWeightSchema: z.ZodUnion<readonly [z.ZodNumber, z.ZodEnum<{
bold: "bold";
thin: "thin";
"extra-light": "extra-light";
light: "light";
normal: "normal";
medium: "medium";
"semi-bold": "semi-bold";
"extra-bold": "extra-bold";
black: "black";
"extra-black": "extra-black";
}>, z.ZodCustom<`${number}`, `${number}`>]>;
export type FontWeight = z.input<typeof FontWeightSchema>;
export type GlyphInfo = {
id: number;
index: number;
char: string;
width: number;
height: number;
x: number;
y: number;
xoffset: number;
yoffset: number;
xadvance: number;
chnl: number;
page: number;
uvWidth?: number;
uvHeight?: number;
uvX?: number;
uvY?: number;
renderSolid?: boolean;
};
export type FontInfo = {
pages: Array<string>;
chars: Array<GlyphInfo>;
info: {
face: string;
size: number;
bold: number;
italic: number;
charset: Array<string>;
unicode: number;
stretchH: number;
smooth: number;
aa: number;
padding: Array<number>;
spacing: Array<number>;
outline: number;
};
common: {
lineHeight: number;
base: number;
scaleW: number;
scaleH: number;
pages: number;
packed: number;
alphaChnl: number;
redChnl: number;
greenChnl: number;
blueChnl: number;
};
distanceField: {
fieldType: string;
distanceRange: number;
};
kernings: Array<{
first: number;
second: number;
amount: number;
}>;
};
export type FontInfoSource = string | FontInfo | (() => string | FontInfo | Promise<string | FontInfo>);
export declare const FontFamilyWeightMapSchema: z.ZodRecord<z.ZodUnion<readonly [z.ZodEnum<{
bold: "bold";
thin: "thin";
"extra-light": "extra-light";
light: "light";
normal: "normal";
medium: "medium";
"semi-bold": "semi-bold";
"extra-bold": "extra-bold";
black: "black";
"extra-black": "extra-black";
}>, z.ZodCustom<`${number}`, `${number}`>]> & z.core.$partial, z.ZodType<FontInfoSource, FontInfoSource, z.core.$ZodTypeInternals<FontInfoSource, FontInfoSource>>>;
export type FontFamilyWeightMap = z.input<typeof FontFamilyWeightMapSchema>;
export declare const FontFamiliesSchema: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodUnion<readonly [z.ZodEnum<{
bold: "bold";
thin: "thin";
"extra-light": "extra-light";
light: "light";
normal: "normal";
medium: "medium";
"semi-bold": "semi-bold";
"extra-bold": "extra-bold";
black: "black";
"extra-black": "extra-black";
}>, z.ZodCustom<`${number}`, `${number}`>]> & z.core.$partial, z.ZodType<FontInfoSource, FontInfoSource, z.core.$ZodTypeInternals<FontInfoSource, FontInfoSource>>>>;
export type FontFamilies = z.input<typeof FontFamiliesSchema>;
export type FontFamilyProperties = {
fontFamily?: string;
fontWeight?: FontWeight;
fontFamilies?: FontFamilies;
};
export declare function computedFontFamilies(properties: Properties, parent: Signal<Container | undefined>): import("@preact/signals-core").ReadonlySignal<Record<string, Partial<Record<`${number}` | "bold" | "thin" | "extra-light" | "light" | "normal" | "medium" | "semi-bold" | "extra-bold" | "black" | "extra-black", FontInfoSource>>> | undefined>;
export declare function computedFont(properties: Properties, fontFamiliesSignal: Signal<FontFamilies | undefined>): Signal<Font | undefined>;
export declare class Font {
page: Texture;
private glyphInfoMap;
private kerningMap;
readonly pageWidth: number;
readonly pageHeight: number;
readonly distanceRange: number;
constructor(info: FontInfo, page: Texture);
getGlyphInfo(char: string): GlyphInfo;
getKerning(firstId: number, secondId: number): number;
}
export declare function glyphIntoToUV(info: GlyphInfo, target: TypedArray, offset: number): void;