Typography & Fonts
font management and advanced text rendering.
Takumi does not use system fonts. All fonts must be explicitly loaded to be available for rendering.
For @takumi-rs/core (napi-rs version), full axis (which means 100-900 weights available) Geist and Geist Mono are embedded by default.
Font
import { } from "@takumi-rs/image-response";
import type { } from "@takumi-rs/core";
const = await ("/path-to-inter.woff2").(() => .());
const : [] = [
{
: "Inter",
:
}
];
export function () {
return new (< />, {
,
});
}Variations & Features
Thanks to underlying engine support, you can control font axes using the font-variation-settings CSS property, or font-feature-settings for OpenType features.
For variable fonts, font-weight has the same effect as font-variation-settings: "wght" <weight>.
<div style={{
fontFamily: "Geist",
fontVariationSettings: "'wght' 700, 'wdth' 150",
fontFeatureSettings: "ss01"
}}>
Variable Font Text
</div>Render Emojis
Dynamic fetching
This is not in stable release yet, available since 1.0.0-beta.3.
If you are using ImageResponse API, theres a satori compatible emoji option.
import { } from "@takumi-rs/image-response";
export function () {
return new (
< ="flex justify-center items-center text-3xl">Hello 👋😁</>,
{
: "twemoji",
}
);
}Under the hood it calls extractEmojis helper function, which separates the emoji segments from the text and modifies the text node.
import { } from "@takumi-rs/helpers/emoji";
import { } from "@takumi-rs/helpers/jsx";
import { } from "@takumi-rs/helpers";
import { , } from "@takumi-rs/core";
let { } = await (
< ="flex justify-center items-center text-3xl">Hello 👋😁</>
);
= (, "twemoji");
const = ();
const = await ();
const = new ();
const = await .(, {
,
});COLR/Bitmap Font File
Takumi supports the COLR font format, which is commonly used for emojis like Twemoji-COLR.
The file size is much smaller than rasterized emoji fonts like Noto Color Emoji.
Typography
Overflow Ellipsis
When text-overflow is set to ellipsis, Takumi tries to match the expected line-clamp constraint or maximum container height.
Setting white-space: nowrap is not required, which enables multiline ellipsis handling.
<div style={{
textOverflow: "ellipsis",
lineClamp: 3,
}}>
Super Long Text
</div>RTL & Bidirectional Text
Support for Right-to-Left (RTL) languages like Arabic or Hebrew is handled automatically by the underlying Parley engine.
But currently there's no manual control over the direction of the text (see issue #330).
Wrapping
Takumi supports both balance and pretty text wrapping. The algorithm is modified from satori's implementation.
<div style={{ textWrap: "balance" }}>
Super Long Text
</div>Last updated on