|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
| MAYAFLUX_API size_t MayaFlux::Portal::Text::index_at | ( | std::string_view | text, |
| const LayoutResult & | layout, | ||
| GlyphAtlas & | atlas, | ||
| float | x, | ||
| float | y, | ||
| float | pen_x = 0.F, |
||
| float | pen_y = 0.F, |
||
| uint32_t | wrap_w = 0, |
||
| uint32_t | tab_width = 4 |
||
| ) |
Byte offset of the codepoint boundary nearest a screen-space point.
Scans layout.quads for the line whose quads sit closest to y, then within that line for the ink quad x falls into (resolving to its left or right half), or, failing that, for the two quads bracketing x. lay_out() never emits a quad for a space, tab, or newline, so a point landing in the gap between two quads - or before the first / after the last quad on a line - has no ink to test against directly: that gap is resolved exactly by walking its few codepoint boundaries through x_at() (same pen_x/pen_y/wrap_w/tab_width as the original lay_out() call) and keeping whichever pen position lands closest to x, rather than guessing from ink edges that were never meant to mark it.
A line with no quads at all (blank, or entirely whitespace) has nothing for the first scan to anchor on and is still not distinguishable from an adjacent line by this function - a real, if narrower, residual gap. Empty layout.quads (the whole text is blank or all-whitespace) returns 0.
| text | Source UTF-8 string layout was produced from. |
| layout | LayoutResult to hit-test against. |
| atlas | GlyphAtlas layout was produced with. |
| x | Screen-space x coordinate, same space as layout's quads. |
| y | Screen-space y coordinate, same space as layout's quads. |
| 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 242 of file TypeSetter.cpp.
References MayaFlux::Portal::Text::GlyphQuad::byte_offset, MayaFlux::Portal::Text::GlyphAtlas::line_height(), next_codepoint_offset(), offset, previous_codepoint_offset(), q, MayaFlux::Portal::Text::LayoutResult::quads, MayaFlux::Portal::Text::GlyphQuad::x0, MayaFlux::Portal::Text::GlyphQuad::x1, x_at(), and MayaFlux::Portal::Text::PenPosition::y.
Referenced by MayaFlux::Portal::Text::TextRun::index_at().
Here is the call graph for this function:
Here is the caller graph for this function: