summaryrefslogtreecommitdiff
path: root/editor/plugins/editor_preview_plugins.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins/editor_preview_plugins.cpp')
-rw-r--r--editor/plugins/editor_preview_plugins.cpp63
1 files changed, 7 insertions, 56 deletions
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 95f68d5f7f..415832ab3b 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -826,55 +826,6 @@ bool EditorFontPreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "FontData") || ClassDB::is_parent_class(p_type, "Font");
}
-struct FSample {
- String script;
- String sample;
-};
-
-static FSample _samples[] = {
- { "hani", U"漢字" },
- { "armn", U"Աբ" },
- { "copt", U"Αα" },
- { "cyrl", U"Аб" },
- { "grek", U"Αα" },
- { "hebr", U"אב" },
- { "arab", U"اب" },
- { "syrc", U"ܐܒ" },
- { "thaa", U"ހށ" },
- { "deva", U"आ" },
- { "beng", U"আ" },
- { "guru", U"ਆ" },
- { "gujr", U"આ" },
- { "orya", U"ଆ" },
- { "taml", U"ஆ" },
- { "telu", U"ఆ" },
- { "knda", U"ಆ" },
- { "mylm", U"ആ" },
- { "sinh", U"ආ" },
- { "thai", U"กิ" },
- { "laoo", U"ກິ" },
- { "tibt", U"ༀ" },
- { "mymr", U"က" },
- { "geor", U"Ⴀა" },
- { "hang", U"한글" },
- { "ethi", U"ሀ" },
- { "cher", U"Ꭳ" },
- { "cans", U"ᐁ" },
- { "ogam", U"ᚁ" },
- { "runr", U"ᚠ" },
- { "tglg", U"ᜀ" },
- { "hano", U"ᜠ" },
- { "buhd", U"ᝀ" },
- { "tagb", U"ᝠ" },
- { "khmr", U"ក" },
- { "mong", U"ᠠ" },
- { "limb", U"ᤁ" },
- { "tale", U"ᥐ" },
- { "latn", U"Ab" },
- { "zyyy", U"😀" },
- { "", U"" }
-};
-
Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const {
RES res = ResourceLoader::load(p_path);
Ref<Font> sampled_font;
@@ -886,15 +837,15 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path,
}
String sample;
- for (int j = 0; j < sampled_font->get_data_count(); j++) {
- for (int i = 0; _samples[i].script != String(); i++) {
- if (sampled_font->get_data(j)->is_script_supported(_samples[i].script)) {
- if (sampled_font->get_data(j)->has_char(_samples[i].sample[0])) {
- sample += _samples[i].sample;
- }
- }
+ static const String sample_base = U"12漢字ԱբΑαАбΑαאבابܐܒހށआআਆઆଆஆఆಆആආกิກິༀကႠა한글ሀᎣᐁᚁᚠᜀᜠᝀᝠកᠠᤁᥐAb😀";
+ for (int i = 0; i < sample_base.length(); i++) {
+ if (sampled_font->has_char(sample_base[i])) {
+ sample += sample_base[i];
}
}
+ if (sample.is_empty()) {
+ sample = sampled_font->get_supported_chars().substr(0, 6);
+ }
Vector2 size = sampled_font->get_string_size(sample, 50);
Vector2 pos;