Refactor: BLF Offset from Cursor Position Early Exits #120673
|
@ -1024,10 +1024,18 @@ size_t blf_str_offset_from_cursor_position(FontBLF *font,
|
|||
size_t str_len,
|
||||
int location_x)
|
||||
{
|
||||
if (!str || !str[0] || !str_len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
CursorPositionForeachGlyph_Data data{};
|
||||
data.location_x = location_x;
|
||||
data.r_offset = size_t(-1);
|
||||
|
||||
/* For negative position, don't early exit with 0 but instead test as
|
||||
* if it were zero. First glyph might not be from first character. */
|
||||
location_x = std::max(location_x, 0);
|
||||
|
||||
|
||||
blf_font_boundbox_foreach_glyph(font, str, str_len, blf_cursor_position_foreach_glyph, &data);
|
||||
|
||||
if (data.r_offset == size_t(-1)) {
|
||||
|
|
Loading…
Reference in New Issue
This does nothing, as the value has been assigned to
data.location_x
and is no longer used.