MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ press()

MAYAFLUX_API std::shared_ptr< Buffers::TextBuffer > MayaFlux::Portal::Text::press ( std::string_view  text,
const PressParams params = {} 
)

Composite a UTF-8 string into a new TextBuffer.

The returned TextBuffer has width == params.render_bounds.x and height equal to either the explicit params.budget_h or the heuristic initial allocation, whichever is larger than the content height.

Parameters
textUTF-8 string to composite.
paramsConstruction parameters. Default produces a growing buffer at 1280x720 render bounds using the default atlas.
Returns
Initialized TextBuffer, or nullptr on failure.

Definition at line 234 of file InkPress.cpp.

237{
238 GlyphAtlas* atlas = resolve_atlas(params.atlas);
239 if (!atlas) {
240 return nullptr;
241 }
242
243 const uint32_t buf_w = params.render_bounds.x;
244
245 const auto result = composite(text, *atlas, params.color, buf_w, params.render_bounds.y,
246 static_cast<float>(atlas->line_height()));
247 if (!result) {
248 MF_WARN(Journal::Component::Portal, Journal::Context::API,
249 "press: no glyphs produced for '{}'", std::string(text));
250 return nullptr;
251 }
252
253 const uint32_t budget_h = params.budget_h > 0
254 ? std::max(params.budget_h, result->h)
255 : std::min(result->h * k_grow_height_multiplier, params.render_bounds.y);
256
257 return make_buffer(*result, buf_w, budget_h, params.render_bounds, text);
258}
#define MF_WARN(comp, ctx,...)
uint32_t h
Definition InkPress.cpp:25
float min
uint32_t line_height() const
Line advance in pixels for this atlas's pixel_size.
Rasterizes and packs glyphs from a FontFace into a TextureContainer.
GlyphAtlas * atlas
Glyph atlas to use. Null selects the TypeFaceFoundry default at call time.
Definition InkPress.hpp:50
glm::vec4 color
RGBA color applied to all glyphs.
Definition InkPress.hpp:53
uint32_t budget_h
Initial vertical budget in pixels. Zero applies the grow heuristic.
Definition InkPress.hpp:60
glm::uvec2 render_bounds
Hard render bounds in pixels.
Definition InkPress.hpp:57

References MayaFlux::Journal::API, MayaFlux::Portal::Text::PressParams::atlas, MayaFlux::Portal::Text::PressParams::budget_h, MayaFlux::Portal::Text::PressParams::color, MayaFlux::Portal::Text::GlyphAtlas::line_height(), MF_WARN, MayaFlux::Journal::Portal, and MayaFlux::Portal::Text::PressParams::render_bounds.

+ Here is the call graph for this function: