Merge pull request #90647 from Gaktan/master

Fix decimal and hex ranges not working with image fonts
This commit is contained in:
Rémi Verschelde 2024-05-17 11:13:39 +02:00
commit 54b2e5dc78
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 20 additions and 12 deletions

View File

@ -158,17 +158,16 @@ Error ResourceImporterImageFont::import(const String &p_source_file, const Strin
c++; // Skip "+".
continue;
}
} else if (range[c] == '0') {
if ((c <= range.length() - 2) && range[c + 1] == 'x') {
token = String();
if (step == STEP_START_BEGIN) {
step = STEP_START_READ_HEX;
} else {
step = STEP_END_READ_HEX;
}
c++; // Skip "x".
continue;
} else if (range[c] == '0' && (c <= range.length() - 2) && range[c + 1] == 'x') {
// Read hexadecimal value, start.
token = String();
if (step == STEP_START_BEGIN) {
step = STEP_START_READ_HEX;
} else {
step = STEP_END_READ_HEX;
}
c++; // Skip "x".
continue;
} else if (range[c] == '\'' || range[c] == '\"') {
if ((c <= range.length() - 3) && (range[c + 2] == '\'' || range[c + 2] == '\"')) {
token = String();
@ -184,14 +183,13 @@ Error ResourceImporterImageFont::import(const String &p_source_file, const Strin
}
} else if (is_digit(range[c])) {
// Read decimal value, start.
c++;
token = String();
token += range[c];
if (step == STEP_START_BEGIN) {
step = STEP_START_READ_DEC;
} else {
step = STEP_END_READ_DEC;
}
token += range[c];
continue;
}
[[fallthrough]];
@ -254,9 +252,19 @@ Error ResourceImporterImageFont::import(const String &p_source_file, const Strin
} break;
}
}
if (step == STEP_START_READ_HEX) {
start = token.hex_to_int();
} else if (step == STEP_START_READ_DEC) {
start = token.to_int();
} else if (step == STEP_END_READ_HEX) {
end = token.hex_to_int();
} else if (step == STEP_END_READ_DEC) {
end = token.to_int();
}
if (end == -1) {
end = start;
}
if (start == -1) {
WARN_PRINT(vformat("Invalid range: \"%s\"", range));
continue;