tests.FontTable
The fonts a test measures text with, so its layouts come out the same on every machine or match a device's.
Usage
Configure font measurements for tests.
// Configure font measurements for tests.
import { Text, VStack } from 'kuito';
import { assert, render, screen, test, type FontTable } from 'kuito/tests';
// Regular and bold faces of the system font, as a device measured them.
const fonts: FontTable = {
faces: [
{ weight: 400, size: 17, lineHeight: 22, advances: { ' ': 4.3 }, fallback: 9.5 },
{ weight: 700, size: 17, lineHeight: 22, advances: { ' ': 4.5 }, fallback: 10.2 },
],
};
test('a bold title wraps onto two lines', async () => {
await render(
<VStack width={160}>
<Text fontWeight="bold">Weekly summary report</Text>
</VStack>,
{ fonts },
);
assert.equal(screen.getByText('Weekly summary report').frame.height, 44);
});Type declaration
export interface FontTable {
faces: readonly FontFace[];
}Members 1
| Name | Type | Required | Description |
|---|---|---|---|
faces | readonly FontFace[] | Yes | — |
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.