UI: Path Line Breaking Characters

This PR adds more line breaking opportunities when breaking file paths.
This adds ".-%?&". Some, like "." are moved to the subsequent line, to
keep period with the extension.

Pull Request: https://projects.blender.org/blender/blender/pulls/137972
This commit is contained in:
Harley Acheson
2025-04-24 22:23:22 +02:00
committed by Harley Acheson
parent 9dd4e90136
commit 587a7f877c
2 changed files with 15 additions and 6 deletions

View File

@@ -1336,10 +1336,19 @@ static void blf_font_wrap_apply(FontBLF *font,
wrap.last[1] = i_curr;
clip_bytes = 1;
}
else if (UNLIKELY((int(mode) & int(BLFWrapMode::Path)) && ELEM(codepoint, SEP, ' ', '_'))) {
wrap.last[0] = i;
wrap.last[1] = i;
clip_bytes = 0;
else if (UNLIKELY(int(mode) & int(BLFWrapMode::Path))) {
if (ELEM(codepoint, SEP, ' ', '?', '&', '=')) {
/* Break and leave at the end of line. */
wrap.last[0] = i;
wrap.last[1] = i;
clip_bytes = 0;
}
else if (ELEM(codepoint, '-', '_', '.', '%')) {
/* Break and move to the next line. */
wrap.last[0] = i_curr;
wrap.last[1] = i_curr;
clip_bytes = 0;
}
}
else if (UNLIKELY((int(mode) & int(BLFWrapMode::Typographical)) &&
!BLI_str_utf32_char_is_breaking_space(codepoint) &&

View File

@@ -262,8 +262,8 @@ TEST(blf_wrapping_path, wrap_path_overflow_ascii)
{
/* Do not break, even though over the wrap limit. */
const char sample[] =
"xxxxxxxxxxxxxxxxxxx!\"#$%&\'()*+,-."
"0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^`abcdefghijklmnopqrstuvwxyz{|}~";
"xxxxxxxxxxxxxxxxxxx!\"#$\'()*+,"
"0123456789:;<>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^`abcdefghijklmnopqrstuvwxyz{|}~";
/* Ahem does not contain all the characters included in above string. */
int id = open_font("Roboto.ttf");
BLF_size(id, 10.0f);