summaryrefslogtreecommitdiffstats
path: root/editor
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2024-06-13 09:20:04 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2024-06-13 09:20:04 +0300
commitdb46eac24cb6796f23d5ec19347d2d3a993dde51 (patch)
treed305ee0a28aa4304187973c2c9664921953edcd2 /editor
parent475248d99df89fc29032a42f1d29ad4cef49c8b5 (diff)
downloadredot-engine-db46eac24cb6796f23d5ec19347d2d3a993dde51.tar.gz
[Image Font Importer] Adds support for `\uXXXX` in the kerning config strings.
Diffstat (limited to 'editor')
-rw-r--r--editor/import/resource_importer_imagefont.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/editor/import/resource_importer_imagefont.cpp b/editor/import/resource_importer_imagefont.cpp
index 0c87176a13..22223bda94 100644
--- a/editor/import/resource_importer_imagefont.cpp
+++ b/editor/import/resource_importer_imagefont.cpp
@@ -291,10 +291,29 @@ Error ResourceImporterImageFont::import(const String &p_source_file, const Strin
WARN_PRINT(vformat("Invalid kerning pairs string: \"%s\"", kp));
continue;
}
+ String from_tokens;
+ for (int i = 0; i < kp_tokens[0].length(); i++) {
+ if (i <= kp_tokens[0].length() - 6 && kp_tokens[0][i] == '\\' && kp_tokens[0][i + 1] == 'u') {
+ char32_t charcode = kp_tokens[0].substr(i + 2, 4).hex_to_int();
+ from_tokens += charcode;
+ } else {
+ from_tokens += kp_tokens[0][i];
+ }
+ }
+ String to_tokens;
+ for (int i = 0; i < kp_tokens[1].length(); i++) {
+ if (i <= kp_tokens[1].length() - 6 && kp_tokens[1][i] == '\\' && kp_tokens[1][i + 1] == 'u') {
+ char32_t charcode = kp_tokens[1].substr(i + 2, 4).hex_to_int();
+ to_tokens += charcode;
+ } else {
+ to_tokens += kp_tokens[1][i];
+ }
+ }
int offset = kp_tokens[2].to_int();
- for (int a = 0; a < kp_tokens[0].length(); a++) {
- for (int b = 0; b < kp_tokens[1].length(); b++) {
- font->set_kerning(0, chr_height, Vector2i(kp_tokens[0].unicode_at(a), kp_tokens[1].unicode_at(b)), Vector2(offset, 0));
+
+ for (int a = 0; a < from_tokens.length(); a++) {
+ for (int b = 0; b < to_tokens.length(); b++) {
+ font->set_kerning(0, chr_height, Vector2i(from_tokens.unicode_at(a), to_tokens.unicode_at(b)), Vector2(offset, 0));
}
}
}