Refactor Font configuration and import UI, and Font resources.
This commit is contained in:
parent
cf19484746
commit
344ba0ffaf
113 changed files with 5041 additions and 6485 deletions
|
|
@ -2376,7 +2376,10 @@ void TextMesh::_create_mesh_array(Array &p_arr) const {
|
|||
TS->shaped_text_set_direction(text_rid, text_direction);
|
||||
|
||||
String text = (uppercase) ? TS->string_to_upper(xl_text, language) : xl_text;
|
||||
TS->shaped_text_add_string(text_rid, text, font->get_rids(), font_size, opentype_features, language);
|
||||
TS->shaped_text_add_string(text_rid, text, font->get_rids(), font_size, font->get_opentype_features(), language);
|
||||
for (int i = 0; i < TextServer::SPACING_MAX; i++) {
|
||||
TS->shaped_text_set_spacing(text_rid, TextServer::SpacingType(i), font->get_spacing(TextServer::SpacingType(i)));
|
||||
}
|
||||
|
||||
Array stt;
|
||||
if (st_parser == TextServer::STRUCTURED_TEXT_CUSTOM) {
|
||||
|
|
@ -2394,7 +2397,10 @@ void TextMesh::_create_mesh_array(Array &p_arr) const {
|
|||
} else if (dirty_font) {
|
||||
int spans = TS->shaped_get_span_count(text_rid);
|
||||
for (int i = 0; i < spans; i++) {
|
||||
TS->shaped_set_span_update_font(text_rid, i, font->get_rids(), font_size, opentype_features);
|
||||
TS->shaped_set_span_update_font(text_rid, i, font->get_rids(), font_size, font->get_opentype_features());
|
||||
}
|
||||
for (int i = 0; i < TextServer::SPACING_MAX; i++) {
|
||||
TS->shaped_text_set_spacing(text_rid, TextServer::SpacingType(i), font->get_spacing(TextServer::SpacingType(i)));
|
||||
}
|
||||
|
||||
dirty_font = false;
|
||||
|
|
@ -2679,10 +2685,6 @@ void TextMesh::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_text_direction", "direction"), &TextMesh::set_text_direction);
|
||||
ClassDB::bind_method(D_METHOD("get_text_direction"), &TextMesh::get_text_direction);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_opentype_feature", "tag", "value"), &TextMesh::set_opentype_feature);
|
||||
ClassDB::bind_method(D_METHOD("get_opentype_feature", "tag"), &TextMesh::get_opentype_feature);
|
||||
ClassDB::bind_method(D_METHOD("clear_opentype_features"), &TextMesh::clear_opentype_features);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_language", "language"), &TextMesh::set_language);
|
||||
ClassDB::bind_method(D_METHOD("get_language"), &TextMesh::get_language);
|
||||
|
||||
|
|
@ -2701,11 +2703,9 @@ void TextMesh::_bind_methods() {
|
|||
ADD_GROUP("Text", "");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "text"), "set_text", "get_text");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "font", PROPERTY_HINT_RESOURCE_TYPE, "Font"), "set_font", "get_font");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "font_size", PROPERTY_HINT_RANGE, "1,127,1,suffix:px"), "set_font_size", "get_font_size");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "font_size", PROPERTY_HINT_RANGE, "1,256,1,or_greater,suffix:px"), "set_font_size", "get_font_size");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "horizontal_alignment", PROPERTY_HINT_ENUM, "Left,Center,Right,Fill"), "set_horizontal_alignment", "get_horizontal_alignment");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "uppercase"), "set_uppercase", "is_uppercase");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "structured_text_bidi_override", PROPERTY_HINT_ENUM, "Default,URI,File,Email,List,None,Custom"), "set_structured_text_bidi_override", "get_structured_text_bidi_override");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "structured_text_bidi_override_options"), "set_structured_text_bidi_override_options", "get_structured_text_bidi_override_options");
|
||||
|
||||
ADD_GROUP("Mesh", "");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "pixel_size", PROPERTY_HINT_RANGE, "0.0001,128,0.0001,suffix:m"), "set_pixel_size", "get_pixel_size");
|
||||
|
|
@ -2713,9 +2713,11 @@ void TextMesh::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth", PROPERTY_HINT_RANGE, "0.0,100.0,0.001,or_greater,suffix:m"), "set_depth", "get_depth");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "width", PROPERTY_HINT_NONE, "suffix:m"), "set_width", "get_width");
|
||||
|
||||
ADD_GROUP("Locale", "");
|
||||
ADD_GROUP("BiDi", "");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "text_direction", PROPERTY_HINT_ENUM, "Auto,Left-to-Right,Right-to-Left"), "set_text_direction", "get_text_direction");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "language", PROPERTY_HINT_LOCALE_ID, ""), "set_language", "get_language");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "structured_text_bidi_override", PROPERTY_HINT_ENUM, "Default,URI,File,Email,List,None,Custom"), "set_structured_text_bidi_override", "get_structured_text_bidi_override");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "structured_text_bidi_override_options"), "set_structured_text_bidi_override_options", "get_structured_text_bidi_override_options");
|
||||
}
|
||||
|
||||
void TextMesh::_notification(int p_what) {
|
||||
|
|
@ -2732,56 +2734,6 @@ void TextMesh::_notification(int p_what) {
|
|||
}
|
||||
}
|
||||
|
||||
bool TextMesh::_set(const StringName &p_name, const Variant &p_value) {
|
||||
String str = p_name;
|
||||
if (str.begins_with("opentype_features/")) {
|
||||
String name = str.get_slicec('/', 1);
|
||||
int32_t tag = TS->name_to_tag(name);
|
||||
int value = p_value;
|
||||
if (value == -1) {
|
||||
if (opentype_features.has(tag)) {
|
||||
opentype_features.erase(tag);
|
||||
dirty_font = true;
|
||||
_request_update();
|
||||
}
|
||||
} else {
|
||||
if (!opentype_features.has(tag) || (int)opentype_features[tag] != value) {
|
||||
opentype_features[tag] = value;
|
||||
dirty_font = true;
|
||||
_request_update();
|
||||
}
|
||||
}
|
||||
notify_property_list_changed();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TextMesh::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
String str = p_name;
|
||||
if (str.begins_with("opentype_features/")) {
|
||||
String name = str.get_slicec('/', 1);
|
||||
int32_t tag = TS->name_to_tag(name);
|
||||
if (opentype_features.has(tag)) {
|
||||
r_ret = opentype_features[tag];
|
||||
return true;
|
||||
} else {
|
||||
r_ret = -1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void TextMesh::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
for (const Variant *ftr = opentype_features.next(nullptr); ftr != nullptr; ftr = opentype_features.next(ftr)) {
|
||||
String name = TS->tag_to_name(*ftr);
|
||||
p_list->push_back(PropertyInfo(Variant::INT, "opentype_features/" + name));
|
||||
}
|
||||
p_list->push_back(PropertyInfo(Variant::NIL, "opentype_features/_new", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
|
||||
}
|
||||
|
||||
TextMesh::TextMesh() {
|
||||
primitive_type = PRIMITIVE_TRIANGLES;
|
||||
text_rid = TS->create_shaped_text();
|
||||
|
|
@ -2845,7 +2797,7 @@ Ref<Font> TextMesh::get_font() const {
|
|||
}
|
||||
|
||||
Ref<Font> TextMesh::_get_font_or_default() const {
|
||||
if (font_override.is_valid() && font_override->get_data_count() > 0) {
|
||||
if (font_override.is_valid()) {
|
||||
return font_override;
|
||||
}
|
||||
|
||||
|
|
@ -2952,29 +2904,6 @@ TextServer::Direction TextMesh::get_text_direction() const {
|
|||
return text_direction;
|
||||
}
|
||||
|
||||
void TextMesh::clear_opentype_features() {
|
||||
opentype_features.clear();
|
||||
dirty_font = true;
|
||||
_request_update();
|
||||
}
|
||||
|
||||
void TextMesh::set_opentype_feature(const String &p_name, int p_value) {
|
||||
int32_t tag = TS->name_to_tag(p_name);
|
||||
if (!opentype_features.has(tag) || (int)opentype_features[tag] != p_value) {
|
||||
opentype_features[tag] = p_value;
|
||||
dirty_font = true;
|
||||
_request_update();
|
||||
}
|
||||
}
|
||||
|
||||
int TextMesh::get_opentype_feature(const String &p_name) const {
|
||||
int32_t tag = TS->name_to_tag(p_name);
|
||||
if (!opentype_features.has(tag)) {
|
||||
return -1;
|
||||
}
|
||||
return opentype_features[tag];
|
||||
}
|
||||
|
||||
void TextMesh::set_language(const String &p_language) {
|
||||
if (language != p_language) {
|
||||
language = p_language;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue