|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
| MAYAFLUX_API PenPosition MayaFlux::Portal::Text::x_at | ( | std::string_view | text, |
| GlyphAtlas & | atlas, | ||
| size_t | byte_offset, | ||
| float | pen_x = 0.F, |
||
| float | pen_y = 0.F, |
||
| uint32_t | wrap_w = 0, |
||
| uint32_t | tab_width = 4 |
||
| ) |
Pen position immediately before byte_offset, in lay_out()'s space.
Re-lays-out the text up to byte_offset (clamped to text.size()) with the same pen origin, wrap_w, and tab_width the caller used to produce the original layout, and returns the resulting final_pen_x/final_pen_y. Wrap decisions before a given offset only depend on codepoints before it, so this reproduces the exact pen position lay_out() would have held at that point in the original call - including on a space, tab, newline, wrapped line start, or the very end of the text, none of which index_at()'s quad-based sibling has a quad to answer from.
This re-walks the prefix on every call rather than caching intermediate pen positions; fine for interactive caret placement, not meant for a tight per-frame loop over long text.
| text | Source UTF-8 string to re-lay-out a prefix of. |
| atlas | GlyphAtlas to query (same one the original layout used). |
| byte_offset | Codepoint-boundary byte offset to resolve. |
| pen_x | Pen origin x, matching the original lay_out() call. |
| pen_y | Pen origin y, matching the original lay_out() call. |
| wrap_w | Wrap column, matching the original lay_out() call. |
| tab_width | Tab stop width, matching the original lay_out() call. |
Definition at line 345 of file TypeSetter.cpp.
References MayaFlux::Portal::Text::LayoutResult::final_pen_x, MayaFlux::Portal::Text::LayoutResult::final_pen_y, and lay_out().
Referenced by MayaFlux::Portal::Text::TextRun::caret(), and index_at().
Here is the call graph for this function:
Here is the caller graph for this function: