Add a text effect

Writes a line or several over its input in a chosen family, weight, size
and colour, optionally on a box filled with a colour or with a picture
from disk. Like the blur and the overlay it needs no sources of its own,
so it can lead a chain; given sources it fills the canvas from a randomly
chosen one first.

Two param types rather than effect-specific branches in the front-ends:
Text, free-form text the user types, and Color, a colour written
"#rrggbb". Both travel as strings, so the interface gets an entry and a
colour button, the command line gets a flag (a colour that does not parse
is refused there rather than drawn as black), and a project keeps them
across a round trip.

The glyphs come from Pango, which draws through Cairo without a display,
so the core stays headless — but they are the one thing here that is not
byte-identical across machines: a machine without the chosen family
renders the substitute its fontconfig picks. Everything the effect is
handed, the rng included, is used exactly as every other effect uses it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Si
2026-09-18 20:31:24 +02:00
co-authored by Claude Opus 5
parent c34bc426fc
commit 1d0343b90a
12 changed files with 725 additions and 6 deletions
+12
View File
@@ -1,6 +1,7 @@
#include "cli/options.hpp"
#include <charconv>
#include <cstdint>
#include <cstring>
#include <sstream>
@@ -111,8 +112,19 @@ Options parseOptions(int argc, char** argv) {
break;
}
case ParamSpec::Type::Path:
case ParamSpec::Type::Text:
options.params[spec->key] = requireValue(argc, argv, i, arg);
break;
case ParamSpec::Type::Color: {
const std::string text = requireValue(argc, argv, i, arg);
std::uint8_t rgb[3];
if (!parseColor(text, rgb)) {
throw EffectError(arg + ": '" + text +
"' is not a colour, expected e.g. #ff8800");
}
options.params[spec->key] = formatColor(rgb);
break;
}
case ParamSpec::Type::Choice: {
const std::string text = requireValue(argc, argv, i, arg);
bool valid = false;