Skip to main content
ErisPulse-Takumi

ErisPulse-Takumi

Render images in your Bot — HTML / node trees / SVG / animations, with CJK fonts out of the box.

PyPI Python License Stars Downloads ErisPulse

English | 简体中文


English

Image rendering for ErisPulse, built on takumi-py. Noto Sans SC, Roboto and Source Code Pro are bundled, so Chinese / English / monospace text just works — no extra font setup.

Supports HTML, node trees, Jinja templates, SVG and animations.

Install

epsdk install Takumi

Usage

The module auto-loads. Grab it through the module manager, or use the sdk shortcut:

from ErisPulse import sdk

takumi = sdk.module.get("Takumi")
# equivalent: takumi = sdk.Takumi

Render HTML

png = takumi.render_html(
    """
    <div class="card">
      <h1>Hello, ErisPulse</h1>
      <p>Rendered by Takumi</p>
    </div>
    """,
    stylesheets=["""
    .card {
      width: 800px;
      height: 400px;
      padding: 48px;
      color: white;
      background: #111827;
      font-family: "Noto Sans SC";
    }
    """],
    width=800,
    height=400,
    lang="zh-CN",
)

Render a node tree

png = takumi.render_node(
    {
        "type": "text",
        "text": "中英混排 renders fine",
        "style": {"fontSize": 48, "color": "#111827"},
    },
    width=800,
    height=200,
    lang="zh-CN",
)

Raw Renderer

takumi.renderer is the underlying takumi_py.Renderer. The convenience methods above inject the bundled font fallback automatically; when you call the renderer directly, pass the families yourself:

png = takumi.renderer.render_html(
    "<div>hello</div>",
    font_families=takumi.families,
    lang="zh-CN",
)

Independent Renderer

Need isolated font / image / resource caches? Spin up a fresh Renderer — the bundled fonts are auto-registered:

renderer = takumi.create_renderer(cache_max_bytes=64 * 1024 * 1024)

png = renderer.render_html(
    "<div>isolated renderer</div>",
    font_families=takumi.families,
    width=800,
    height=200,
    lang="zh-CN",
)

create_renderer() takes the takumi_py.Renderer constructor kwargs. It defaults to load_default_fonts=False (bundled fonts only); pass load_default_fonts=True to also load Takumi's own, and fonts=[...] to register custom fonts alongside.

An independent instance bypasses the module proxy, so pass font_families=takumi.families explicitly to keep the same fallback stack.

Bundled resources:

  • takumi.fonts — bundled font filenames
  • takumi.families — registered font families

Pass font_families yourself and the module respects it — no default fallback is injected. RenderOptions(font_families=...) works too.

Config

[Takumi]
enabled = true

简体中文

ErisPulse 的图片渲染模块,基于 takumi-py。内置 Noto Sans SC、Roboto、Source Code Pro,中文 / 英文 / 等宽文本开箱即用,无需额外配置字体。

支持 HTML、节点树、Jinja 模板、SVG 和动画渲染。

安装

epsdk install Takumi

使用

模块会自动加载,通过模块管理器获取,也可以用 sdk 快捷方式:

from ErisPulse import sdk

takumi = sdk.module.get("Takumi")
# 等价写法:takumi = sdk.Takumi

渲染 HTML

png = takumi.render_html(
    """
    <div class="card">
      <h1>你好,ErisPulse</h1>
      <p>由 Takumi 渲染</p>
    </div>
    """,
    stylesheets=["""
    .card {
      width: 800px;
      height: 400px;
      padding: 48px;
      color: white;
      background: #111827;
      font-family: "Noto Sans SC";
    }
    """],
    width=800,
    height=400,
    lang="zh-CN",
)

渲染节点树

png = takumi.render_node(
    {
        "type": "text",
        "text": "中文和 English 都可直接渲染",
        "style": {"fontSize": 48, "color": "#111827"},
    },
    width=800,
    height=200,
    lang="zh-CN",
)

原生 Renderer

takumi.renderer 是原始的 takumi_py.Renderer 实例。上面的便捷方法会自动注入内置字体回退栈;直接调用 renderer 时自行传入 families:

png = takumi.renderer.render_html(
    "<div>你好</div>",
    font_families=takumi.families,
    lang="zh-CN",
)

独立 Renderer

需要隔离字体 / 图片 / 资源缓存时,创建新的 Renderer,内置字体会自动注册:

renderer = takumi.create_renderer(cache_max_bytes=64 * 1024 * 1024)

png = renderer.render_html(
    "<div>独立 Renderer</div>",
    font_families=takumi.families,
    width=800,
    height=200,
    lang="zh-CN",
)

create_renderer() 接受 takumi_py.Renderer 的构造参数。默认 load_default_fonts=False(仅加载内置字体);传入 load_default_fonts=True 可同时加载 Takumi 自带字体,fonts=[...] 可一并注册自定义字体。

独立实例不经过模块代理,因此若要保留统一的内置字体回退栈,需显式传入 font_families=takumi.families

内置资源:

  • takumi.fonts:内置字体文件名
  • takumi.families:已注册的字体 family

若显式传入 font_families,模块会尊重调用方设置,不再注入默认回退栈。RenderOptions(font_families=...) 同样有效。

配置

[Takumi]
enabled = true

Related · ErisPulse · takumi-py · Documentation · Issues

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

erispulse_takumi-1.2.0.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

erispulse_takumi-1.2.0-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file erispulse_takumi-1.2.0.tar.gz.

File metadata

  • Download URL: erispulse_takumi-1.2.0.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for erispulse_takumi-1.2.0.tar.gz
Algorithm Hash digest
SHA256 96f23fb682b20f2fea6cab2ccf72929dc19afbfa51216b3f4d003870c98b23cd
MD5 4639ab380ed152a86f4a37c88c01b9cb
BLAKE2b-256 5bc9829b663311daa3f7745f17b8d816958790d80434852f06ccc4937042eeb9

See more details on using hashes here.

File details

Details for the file erispulse_takumi-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for erispulse_takumi-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c404bd348ff9e1a0ef207acf28bb37425a2000a3b4fa849b70a7ec117316a441
MD5 eba7d039a7479ed132ce2f3a9a360764
BLAKE2b-256 3f17a2efa5e9e5b6c67812fd2b04abb949a9efbc792306e9c15e33b6ed417b41

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page