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

◆ press() [1/2]

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 237 of file InkPress.cpp.

240{
241 GlyphAtlas* atlas = resolve_atlas(params.atlas);
242 if (!atlas) {
243 return nullptr;
244 }
245
246 const uint32_t buf_w = params.render_bounds.x;
247
248 const auto result = composite(text, *atlas, params.color, buf_w, params.render_bounds.y,
249 static_cast<float>(atlas->line_height()));
250 if (!result) {
251 MF_WARN(Journal::Component::Portal, Journal::Context::API,
252 "press: no glyphs produced for '{}'", std::string(text));
253 return nullptr;
254 }
255
256 const uint32_t budget_h = params.budget_h > 0
257 ? std::max(params.budget_h, result->h)
258 : std::min(result->h * k_grow_height_multiplier, params.render_bounds.y);
259
260 return make_buffer(*result, buf_w, budget_h, params.render_bounds, text);
261}
#define MF_WARN(comp, ctx,...)
uint32_t h
Definition InkPress.cpp:28
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.

Referenced by MayaFlux::Portal::Forma::Inspector::make_row_buffer(), and MayaFlux::Portal::Forma::Element::with_text().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: