You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-06 17:25:19 +00:00
Makes FontData importable resource.
Adds multi-channel SDF font texture generation and rendering support. Adds per-font oversampling support. Adds FontData import plugins (for dynamic fonts, BMFonts and monospaced image fonts), font texture cache pre-generation and loading. Adds BMFont binary format and outline support.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user