Urgent.News

What's breaking now, across thousands of outlets.

Tech

My Mermaid renderer drew tofu boxes instead of labels — the container had no fonts installed

Agents write Mermaid constantly — sequence diagrams for API designs, flowcharts for release flows — but there's rarely anything on the other end that can display it. That gap is why I built a renderer: POST diagram syntax, get back a base64 PNG or SVG. I ended up packaging it as the Mermaid Diagram Renderer API ( https://x402.freeq.one/tools/mermaid.html ) so I could stop maintaining the render…

Mermaid is a tool used to create diagrams like sequence diagrams and flowcharts for APIs and release flows. However, there is rarely an output device capable of displaying these diagrams. To address this issue, the author built a renderer called the Mermaid Diagram Renderer API. This API allows users to post Mermaid syntax and receive a base64 PNG or SVG in return. Yet, the first version of the renderer looked fine in tests but broke when exposed to real input.

Upon investigating, the author discovered that the issue stemmed from the Dockerfile used to build the renderer. A slim base image was employed, and headless Chromium was installed for rendering, but no font packages were included. Without fonts, the renderer was unable to rasterize text, resulting in tofu glyphs appearing instead of labels.

This occurred because Mermaid sizes nodes by measuring text width before drawing it. With no usable font, those measurements collapsed, causing node boxes to shrink to near-nothing and arrows to overlap.

The root cause of the problem was that Mermaid performed measurements using a font for typography, different from the one used for rasterization. To resolve this issue, the author installed the fonts-liberation package along with Noto and added a fc-cache -f layer step. Additionally, a pinned font-family was specified in the render options to ensure that both measurement and rasterization utilized the same font.

To prevent similar issues in the future, the author also added a canary test, a small flowchart with a known label, and compared its pixel histogram on every deployment, halting the process if the label pixels were absent. This example highlights the importance of including fonts as a first-class dependency in headless-browser rendering within containers and emphasizes the need for tests that verify the presence of content pixels within an image, not just its existence.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

I built a zero-dependency CLI to snapshot the remote job market into CSV/JSON/SQLite

I had a recurring need: a reproducible, offline snapshot of the remote-job market I could open in a spreadsheet, load into a database, or feed into a script — without scraping five job boards myself…

  • Developer creates CLI tool remote-jobs-export
  • Tool snapshots remote job market in CSV, JSON, SQLite
  • Offers zero-dependency, honest, and queryable data

Your Backtest Can Pass Every Unit Test and Still Know the Future

A two-timestamp schema and a future-corruption test can catch silent look-ahead leakage in financial feature pipelines. A backtest does not need an obvious bug to cheat.

  • Two-timestamp schema reveals silent look-ahead leakage in financial feature pipelines.
  • Availableat timestamp distinguishes event time from knowledge time in models.
  • SEC company-facts API provides multiple timestamps for accurate feature building.

Pro Sells Time, Not Safety — ELY Agent Input Preflight v0.8.0

ELY Agent Input Preflight v0.8.0 is released. This release introduces an optional paid Pro entitlement, but I made one rule non-negotiable: Pro sells time, not safety.

  • Pro entitlement introduced in ELY Agent Input Preflight v0.8.0
  • Community edition retains verification and safety core
  • Pro focuses on selling time, reducing developer friction

Convert HEIC to JPG on Windows 11 Without Uploading (Free)

You copy a batch of photos from your iPhone to your Windows 11 PC — via USB cable or iCloud — and instead of familiar .jpg files you get a folder full of .heic files that Windows refuses to open.

  • Windows 11 natively supports HEIC files since Windows 11
  • Users can convert HEIC to JPG without uploading via browser-based converters
  • Browser-based converters process files in memory, preserving privacy

More from Monday 5 October →