Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
text_run_planner.hpp
Go to the documentation of this file.
1// text_run_planner.hpp
2//
3// `TextRunPlanner` is the entry point that converts an input string +
4// `FontOptions` into a `ShapedText` artifact. Both measurement and paint
5// pipelines are intended to consume the same artifact, keeping text metrics,
6// run segmentation, and cluster boundaries aligned across layout and rendering.
7// The planner resolves the font cascade, splits text into bidi/script runs when
8// ICU-backed SkShaper iterators are available, builds grapheme-cluster and
9// Unicode index maps, and falls back to a single compatible run on non-Skia
10// builds.
11
12#pragma once
13
16
17#include <memory>
18#include <string>
19#include <string_view>
20#include <utility>
21#include <vector>
22
23namespace pulp::canvas {
24
25class TextRunPlanner {
26public:
28 static TextRunPlanner& instance();
29
43 ShapedText shape(std::string_view text, const FontOptions& options);
44
63 std::vector<ShapedText> shape_batch(
64 const std::vector<std::pair<std::string, FontOptions>>& inputs);
65
70
71private:
72 TextRunPlanner();
73 ~TextRunPlanner();
74 TextRunPlanner(const TextRunPlanner&) = delete;
75 TextRunPlanner& operator=(const TextRunPlanner&) = delete;
76
77 struct Impl;
78 std::unique_ptr<Impl> impl_;
79};
80
81} // namespace pulp::canvas
ShapedText shape(std::string_view text, const FontOptions &options)
Produce a ShapedText for text under options.
std::vector< ShapedText > shape_batch(const std::vector< std::pair< std::string, FontOptions > > &inputs)
Shape N independent inputs in parallel and return the artifacts in input order.
static TextRunPlanner & instance()
Process-wide singleton. Thread-safe.
void clear_cache()
Test-only: discard the internal cache.
Definition affine_transform.hpp:24
@ text
Definition scene_node.hpp:96
The typed, hashable contract that replaces (family_string, size) throughout the font subsystem.
Definition font_options.hpp:190
The canonical output of TextRunPlanner::shape(text, FontOptions).
Definition shaped_text.hpp:132