2020-12-27 14:30:33 +01:00
/**************************************************************************/
2022-02-14 14:00:03 +01:00
/* dynamic_font_import_settings.cpp */
2020-12-27 14:30:33 +01:00
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
2022-02-14 14:00:03 +01:00
# include "dynamic_font_import_settings.h"
2020-12-27 14:30:33 +01:00
2022-11-09 13:45:21 +01:00
# include "core/config/project_settings.h"
2022-02-12 02:46:22 +01:00
# include "editor/editor_file_system.h"
# include "editor/editor_inspector.h"
# include "editor/editor_locale_dialog.h"
2020-12-27 14:30:33 +01:00
# include "editor/editor_node.h"
2023-02-09 17:24:52 +01:00
# include "editor/editor_property_name_processor.h"
# include "editor/editor_settings.h"
2023-08-13 02:33:39 +02:00
# include "editor/editor_string_names.h"
2023-04-07 18:59:49 +02:00
# include "editor/gui/editor_file_dialog.h"
2024-01-15 13:14:55 +01:00
# include "editor/themes/editor_scale.h"
2020-12-27 14:30:33 +01:00
/*************************************************************************/
/* Settings data */
/*************************************************************************/
2022-05-09 11:47:10 +02:00
bool DynamicFontImportSettingsData : : _set ( const StringName & p_name , const Variant & p_value ) {
if ( defaults . has ( p_name ) & & defaults [ p_name ] = = p_value ) {
settings . erase ( p_name ) ;
} else {
settings [ p_name ] = p_value ;
2020-12-27 14:30:33 +01:00
}
2022-05-09 11:47:10 +02:00
return true ;
}
2020-12-27 14:30:33 +01:00
2022-05-09 11:47:10 +02:00
bool DynamicFontImportSettingsData : : _get ( const StringName & p_name , Variant & r_ret ) const {
if ( settings . has ( p_name ) ) {
r_ret = settings [ p_name ] ;
return true ;
}
if ( defaults . has ( p_name ) ) {
r_ret = defaults [ p_name ] ;
return true ;
2020-12-27 14:30:33 +01:00
}
2022-05-09 11:47:10 +02:00
return false ;
}
2020-12-27 14:30:33 +01:00
2022-05-09 11:47:10 +02:00
void DynamicFontImportSettingsData : : _get_property_list ( List < PropertyInfo > * p_list ) const {
for ( const List < ResourceImporter : : ImportOption > : : Element * E = options . front ( ) ; E ; E = E - > next ( ) ) {
if ( owner & & owner - > import_settings_data . is_valid ( ) ) {
if ( owner - > import_settings_data - > get ( " multichannel_signed_distance_field " ) & & ( E - > get ( ) . option . name = = " size " | | E - > get ( ) . option . name = = " outline_size " | | E - > get ( ) . option . name = = " oversampling " ) ) {
continue ;
}
if ( ! owner - > import_settings_data - > get ( " multichannel_signed_distance_field " ) & & ( E - > get ( ) . option . name = = " msdf_pixel_range " | | E - > get ( ) . option . name = = " msdf_size " ) ) {
continue ;
2020-12-27 14:30:33 +01:00
}
}
2022-05-09 11:47:10 +02:00
p_list - > push_back ( E - > get ( ) . option ) ;
2020-12-27 14:30:33 +01:00
}
2022-05-09 11:47:10 +02:00
}
Ref < FontFile > DynamicFontImportSettingsData : : get_font ( ) const {
return fd ;
}
2020-12-27 14:30:33 +01:00
/*************************************************************************/
/* Glyph ranges */
/*************************************************************************/
struct UniRange {
int32_t start ;
int32_t end ;
String name ;
} ;
2021-09-22 15:55:39 +02:00
// Unicode Character Blocks
// Source: https://www.unicode.org/Public/14.0.0/ucd/Blocks.txt
2020-12-27 14:30:33 +01:00
static UniRange unicode_ranges [ ] = {
{ 0x0000 , 0x007F , U " Basic Latin " } ,
{ 0x0080 , 0x00FF , U " Latin-1 Supplement " } ,
{ 0x0100 , 0x017F , U " Latin Extended-A " } ,
{ 0x0180 , 0x024F , U " Latin Extended-B " } ,
{ 0x0250 , 0x02AF , U " IPA Extensions " } ,
{ 0x02B0 , 0x02FF , U " Spacing Modifier Letters " } ,
{ 0x0300 , 0x036F , U " Combining Diacritical Marks " } ,
{ 0x0370 , 0x03FF , U " Greek and Coptic " } ,
{ 0x0400 , 0x04FF , U " Cyrillic " } ,
{ 0x0500 , 0x052F , U " Cyrillic Supplement " } ,
{ 0x0530 , 0x058F , U " Armenian " } ,
{ 0x0590 , 0x05FF , U " Hebrew " } ,
{ 0x0600 , 0x06FF , U " Arabic " } ,
{ 0x0700 , 0x074F , U " Syriac " } ,
{ 0x0750 , 0x077F , U " Arabic Supplement " } ,
{ 0x0780 , 0x07BF , U " Thaana " } ,
2021-09-22 15:55:39 +02:00
{ 0x07C0 , 0x07FF , U " NKo " } ,
2020-12-27 14:30:33 +01:00
{ 0x0800 , 0x083F , U " Samaritan " } ,
{ 0x0840 , 0x085F , U " Mandaic " } ,
{ 0x0860 , 0x086F , U " Syriac Supplement " } ,
2021-09-22 15:55:39 +02:00
{ 0x0870 , 0x089F , U " Arabic Extended-B " } ,
2020-12-27 14:30:33 +01:00
{ 0x08A0 , 0x08FF , U " Arabic Extended-A " } ,
{ 0x0900 , 0x097F , U " Devanagari " } ,
{ 0x0980 , 0x09FF , U " Bengali " } ,
{ 0x0A00 , 0x0A7F , U " Gurmukhi " } ,
{ 0x0A80 , 0x0AFF , U " Gujarati " } ,
{ 0x0B00 , 0x0B7F , U " Oriya " } ,
{ 0x0B80 , 0x0BFF , U " Tamil " } ,
{ 0x0C00 , 0x0C7F , U " Telugu " } ,
{ 0x0C80 , 0x0CFF , U " Kannada " } ,
{ 0x0D00 , 0x0D7F , U " Malayalam " } ,
{ 0x0D80 , 0x0DFF , U " Sinhala " } ,
{ 0x0E00 , 0x0E7F , U " Thai " } ,
{ 0x0E80 , 0x0EFF , U " Lao " } ,
{ 0x0F00 , 0x0FFF , U " Tibetan " } ,
{ 0x1000 , 0x109F , U " Myanmar " } ,
{ 0x10A0 , 0x10FF , U " Georgian " } ,
{ 0x1100 , 0x11FF , U " Hangul Jamo " } ,
{ 0x1200 , 0x137F , U " Ethiopic " } ,
{ 0x1380 , 0x139F , U " Ethiopic Supplement " } ,
{ 0x13A0 , 0x13FF , U " Cherokee " } ,
{ 0x1400 , 0x167F , U " Unified Canadian Aboriginal Syllabics " } ,
{ 0x1680 , 0x169F , U " Ogham " } ,
{ 0x16A0 , 0x16FF , U " Runic " } ,
{ 0x1700 , 0x171F , U " Tagalog " } ,
{ 0x1720 , 0x173F , U " Hanunoo " } ,
{ 0x1740 , 0x175F , U " Buhid " } ,
{ 0x1760 , 0x177F , U " Tagbanwa " } ,
{ 0x1780 , 0x17FF , U " Khmer " } ,
{ 0x1800 , 0x18AF , U " Mongolian " } ,
{ 0x18B0 , 0x18FF , U " Unified Canadian Aboriginal Syllabics Extended " } ,
{ 0x1900 , 0x194F , U " Limbu " } ,
{ 0x1950 , 0x197F , U " Tai Le " } ,
{ 0x1980 , 0x19DF , U " New Tai Lue " } ,
{ 0x19E0 , 0x19FF , U " Khmer Symbols " } ,
{ 0x1A00 , 0x1A1F , U " Buginese " } ,
{ 0x1A20 , 0x1AAF , U " Tai Tham " } ,
{ 0x1AB0 , 0x1AFF , U " Combining Diacritical Marks Extended " } ,
{ 0x1B00 , 0x1B7F , U " Balinese " } ,
{ 0x1B80 , 0x1BBF , U " Sundanese " } ,
{ 0x1BC0 , 0x1BFF , U " Batak " } ,
{ 0x1C00 , 0x1C4F , U " Lepcha " } ,
{ 0x1C50 , 0x1C7F , U " Ol Chiki " } ,
{ 0x1C80 , 0x1C8F , U " Cyrillic Extended-C " } ,
{ 0x1C90 , 0x1CBF , U " Georgian Extended " } ,
{ 0x1CC0 , 0x1CCF , U " Sundanese Supplement " } ,
{ 0x1CD0 , 0x1CFF , U " Vedic Extensions " } ,
{ 0x1D00 , 0x1D7F , U " Phonetic Extensions " } ,
{ 0x1D80 , 0x1DBF , U " Phonetic Extensions Supplement " } ,
{ 0x1DC0 , 0x1DFF , U " Combining Diacritical Marks Supplement " } ,
{ 0x1E00 , 0x1EFF , U " Latin Extended Additional " } ,
{ 0x1F00 , 0x1FFF , U " Greek Extended " } ,
{ 0x2000 , 0x206F , U " General Punctuation " } ,
{ 0x2070 , 0x209F , U " Superscripts and Subscripts " } ,
{ 0x20A0 , 0x20CF , U " Currency Symbols " } ,
{ 0x20D0 , 0x20FF , U " Combining Diacritical Marks for Symbols " } ,
{ 0x2100 , 0x214F , U " Letterlike Symbols " } ,
{ 0x2150 , 0x218F , U " Number Forms " } ,
{ 0x2190 , 0x21FF , U " Arrows " } ,
{ 0x2200 , 0x22FF , U " Mathematical Operators " } ,
{ 0x2300 , 0x23FF , U " Miscellaneous Technical " } ,
{ 0x2400 , 0x243F , U " Control Pictures " } ,
{ 0x2440 , 0x245F , U " Optical Character Recognition " } ,
{ 0x2460 , 0x24FF , U " Enclosed Alphanumerics " } ,
{ 0x2500 , 0x257F , U " Box Drawing " } ,
{ 0x2580 , 0x259F , U " Block Elements " } ,
{ 0x25A0 , 0x25FF , U " Geometric Shapes " } ,
{ 0x2600 , 0x26FF , U " Miscellaneous Symbols " } ,
{ 0x2700 , 0x27BF , U " Dingbats " } ,
{ 0x27C0 , 0x27EF , U " Miscellaneous Mathematical Symbols-A " } ,
{ 0x27F0 , 0x27FF , U " Supplemental Arrows-A " } ,
{ 0x2800 , 0x28FF , U " Braille Patterns " } ,
{ 0x2900 , 0x297F , U " Supplemental Arrows-B " } ,
{ 0x2980 , 0x29FF , U " Miscellaneous Mathematical Symbols-B " } ,
{ 0x2A00 , 0x2AFF , U " Supplemental Mathematical Operators " } ,
{ 0x2B00 , 0x2BFF , U " Miscellaneous Symbols and Arrows " } ,
{ 0x2C00 , 0x2C5F , U " Glagolitic " } ,
{ 0x2C60 , 0x2C7F , U " Latin Extended-C " } ,
{ 0x2C80 , 0x2CFF , U " Coptic " } ,
{ 0x2D00 , 0x2D2F , U " Georgian Supplement " } ,
{ 0x2D30 , 0x2D7F , U " Tifinagh " } ,
{ 0x2D80 , 0x2DDF , U " Ethiopic Extended " } ,
{ 0x2DE0 , 0x2DFF , U " Cyrillic Extended-A " } ,
{ 0x2E00 , 0x2E7F , U " Supplemental Punctuation " } ,
{ 0x2E80 , 0x2EFF , U " CJK Radicals Supplement " } ,
{ 0x2F00 , 0x2FDF , U " Kangxi Radicals " } ,
{ 0x2FF0 , 0x2FFF , U " Ideographic Description Characters " } ,
{ 0x3000 , 0x303F , U " CJK Symbols and Punctuation " } ,
{ 0x3040 , 0x309F , U " Hiragana " } ,
{ 0x30A0 , 0x30FF , U " Katakana " } ,
{ 0x3100 , 0x312F , U " Bopomofo " } ,
{ 0x3130 , 0x318F , U " Hangul Compatibility Jamo " } ,
{ 0x3190 , 0x319F , U " Kanbun " } ,
{ 0x31A0 , 0x31BF , U " Bopomofo Extended " } ,
{ 0x31C0 , 0x31EF , U " CJK Strokes " } ,
{ 0x31F0 , 0x31FF , U " Katakana Phonetic Extensions " } ,
{ 0x3200 , 0x32FF , U " Enclosed CJK Letters and Months " } ,
{ 0x3300 , 0x33FF , U " CJK Compatibility " } ,
{ 0x3400 , 0x4DBF , U " CJK Unified Ideographs Extension A " } ,
{ 0x4DC0 , 0x4DFF , U " Yijing Hexagram Symbols " } ,
{ 0x4E00 , 0x9FFF , U " CJK Unified Ideographs " } ,
{ 0xA000 , 0xA48F , U " Yi Syllables " } ,
{ 0xA490 , 0xA4CF , U " Yi Radicals " } ,
{ 0xA4D0 , 0xA4FF , U " Lisu " } ,
{ 0xA500 , 0xA63F , U " Vai " } ,
{ 0xA640 , 0xA69F , U " Cyrillic Extended-B " } ,
{ 0xA6A0 , 0xA6FF , U " Bamum " } ,
{ 0xA700 , 0xA71F , U " Modifier Tone Letters " } ,
{ 0xA720 , 0xA7FF , U " Latin Extended-D " } ,
{ 0xA800 , 0xA82F , U " Syloti Nagri " } ,
{ 0xA830 , 0xA83F , U " Common Indic Number Forms " } ,
{ 0xA840 , 0xA87F , U " Phags-pa " } ,
{ 0xA880 , 0xA8DF , U " Saurashtra " } ,
{ 0xA8E0 , 0xA8FF , U " Devanagari Extended " } ,
{ 0xA900 , 0xA92F , U " Kayah Li " } ,
{ 0xA930 , 0xA95F , U " Rejang " } ,
{ 0xA960 , 0xA97F , U " Hangul Jamo Extended-A " } ,
{ 0xA980 , 0xA9DF , U " Javanese " } ,
{ 0xA9E0 , 0xA9FF , U " Myanmar Extended-B " } ,
{ 0xAA00 , 0xAA5F , U " Cham " } ,
{ 0xAA60 , 0xAA7F , U " Myanmar Extended-A " } ,
{ 0xAA80 , 0xAADF , U " Tai Viet " } ,
{ 0xAAE0 , 0xAAFF , U " Meetei Mayek Extensions " } ,
{ 0xAB00 , 0xAB2F , U " Ethiopic Extended-A " } ,
{ 0xAB30 , 0xAB6F , U " Latin Extended-E " } ,
{ 0xAB70 , 0xABBF , U " Cherokee Supplement " } ,
{ 0xABC0 , 0xABFF , U " Meetei Mayek " } ,
2021-09-22 15:55:39 +02:00
{ 0xAC00 , 0xD7AF , U " Hangul Syllables " } ,
2020-12-27 14:30:33 +01:00
{ 0xD7B0 , 0xD7FF , U " Hangul Jamo Extended-B " } ,
2021-09-22 15:55:39 +02:00
//{ 0xD800, 0xDB7F, U"High Surrogates" },
//{ 0xDB80, 0xDBFF, U"High Private Use Surrogates" },
//{ 0xDC00, 0xDFFF, U"Low Surrogates" },
{ 0xE000 , 0xF8FF , U " Private Use Area " } ,
2020-12-27 14:30:33 +01:00
{ 0xF900 , 0xFAFF , U " CJK Compatibility Ideographs " } ,
{ 0xFB00 , 0xFB4F , U " Alphabetic Presentation Forms " } ,
{ 0xFB50 , 0xFDFF , U " Arabic Presentation Forms-A " } ,
//{ 0xFE00, 0xFE0F, U"Variation Selectors" },
{ 0xFE10 , 0xFE1F , U " Vertical Forms " } ,
{ 0xFE20 , 0xFE2F , U " Combining Half Marks " } ,
{ 0xFE30 , 0xFE4F , U " CJK Compatibility Forms " } ,
{ 0xFE50 , 0xFE6F , U " Small Form Variants " } ,
{ 0xFE70 , 0xFEFF , U " Arabic Presentation Forms-B " } ,
{ 0xFF00 , 0xFFEF , U " Halfwidth and Fullwidth Forms " } ,
//{ 0xFFF0, 0xFFFF, U"Specials" },
{ 0x10000 , 0x1007F , U " Linear B Syllabary " } ,
{ 0x10080 , 0x100FF , U " Linear B Ideograms " } ,
{ 0x10100 , 0x1013F , U " Aegean Numbers " } ,
{ 0x10140 , 0x1018F , U " Ancient Greek Numbers " } ,
{ 0x10190 , 0x101CF , U " Ancient Symbols " } ,
{ 0x101D0 , 0x101FF , U " Phaistos Disc " } ,
{ 0x10280 , 0x1029F , U " Lycian " } ,
{ 0x102A0 , 0x102DF , U " Carian " } ,
{ 0x102E0 , 0x102FF , U " Coptic Epact Numbers " } ,
{ 0x10300 , 0x1032F , U " Old Italic " } ,
{ 0x10330 , 0x1034F , U " Gothic " } ,
{ 0x10350 , 0x1037F , U " Old Permic " } ,
{ 0x10380 , 0x1039F , U " Ugaritic " } ,
{ 0x103A0 , 0x103DF , U " Old Persian " } ,
{ 0x10400 , 0x1044F , U " Deseret " } ,
{ 0x10450 , 0x1047F , U " Shavian " } ,
{ 0x10480 , 0x104AF , U " Osmanya " } ,
{ 0x104B0 , 0x104FF , U " Osage " } ,
{ 0x10500 , 0x1052F , U " Elbasan " } ,
{ 0x10530 , 0x1056F , U " Caucasian Albanian " } ,
2021-09-22 15:55:39 +02:00
{ 0x10570 , 0x105BF , U " Vithkuqi " } ,
2020-12-27 14:30:33 +01:00
{ 0x10600 , 0x1077F , U " Linear A " } ,
2021-09-22 15:55:39 +02:00
{ 0x10780 , 0x107BF , U " Latin Extended-F " } ,
2020-12-27 14:30:33 +01:00
{ 0x10800 , 0x1083F , U " Cypriot Syllabary " } ,
{ 0x10840 , 0x1085F , U " Imperial Aramaic " } ,
{ 0x10860 , 0x1087F , U " Palmyrene " } ,
{ 0x10880 , 0x108AF , U " Nabataean " } ,
{ 0x108E0 , 0x108FF , U " Hatran " } ,
{ 0x10900 , 0x1091F , U " Phoenician " } ,
{ 0x10920 , 0x1093F , U " Lydian " } ,
{ 0x10980 , 0x1099F , U " Meroitic Hieroglyphs " } ,
{ 0x109A0 , 0x109FF , U " Meroitic Cursive " } ,
{ 0x10A00 , 0x10A5F , U " Kharoshthi " } ,
{ 0x10A60 , 0x10A7F , U " Old South Arabian " } ,
{ 0x10A80 , 0x10A9F , U " Old North Arabian " } ,
{ 0x10AC0 , 0x10AFF , U " Manichaean " } ,
{ 0x10B00 , 0x10B3F , U " Avestan " } ,
{ 0x10B40 , 0x10B5F , U " Inscriptional Parthian " } ,
{ 0x10B60 , 0x10B7F , U " Inscriptional Pahlavi " } ,
{ 0x10B80 , 0x10BAF , U " Psalter Pahlavi " } ,
{ 0x10C00 , 0x10C4F , U " Old Turkic " } ,
{ 0x10C80 , 0x10CFF , U " Old Hungarian " } ,
{ 0x10D00 , 0x10D3F , U " Hanifi Rohingya " } ,
{ 0x10E60 , 0x10E7F , U " Rumi Numeral Symbols " } ,
{ 0x10E80 , 0x10EBF , U " Yezidi " } ,
2022-09-17 22:19:11 +02:00
{ 0x10EC0 , 0x10EFF , U " Arabic Extended-C " } ,
2020-12-27 14:30:33 +01:00
{ 0x10F00 , 0x10F2F , U " Old Sogdian " } ,
{ 0x10F30 , 0x10F6F , U " Sogdian " } ,
2021-09-22 15:55:39 +02:00
{ 0x10F70 , 0x10FAF , U " Old Uyghur " } ,
2020-12-27 14:30:33 +01:00
{ 0x10FB0 , 0x10FDF , U " Chorasmian " } ,
{ 0x10FE0 , 0x10FFF , U " Elymaic " } ,
{ 0x11000 , 0x1107F , U " Brahmi " } ,
{ 0x11080 , 0x110CF , U " Kaithi " } ,
{ 0x110D0 , 0x110FF , U " Sora Sompeng " } ,
{ 0x11100 , 0x1114F , U " Chakma " } ,
{ 0x11150 , 0x1117F , U " Mahajani " } ,
{ 0x11180 , 0x111DF , U " Sharada " } ,
{ 0x111E0 , 0x111FF , U " Sinhala Archaic Numbers " } ,
{ 0x11200 , 0x1124F , U " Khojki " } ,
{ 0x11280 , 0x112AF , U " Multani " } ,
{ 0x112B0 , 0x112FF , U " Khudawadi " } ,
{ 0x11300 , 0x1137F , U " Grantha " } ,
{ 0x11400 , 0x1147F , U " Newa " } ,
{ 0x11480 , 0x114DF , U " Tirhuta " } ,
{ 0x11580 , 0x115FF , U " Siddham " } ,
{ 0x11600 , 0x1165F , U " Modi " } ,
{ 0x11660 , 0x1167F , U " Mongolian Supplement " } ,
{ 0x11680 , 0x116CF , U " Takri " } ,
2021-09-22 15:55:39 +02:00
{ 0x11700 , 0x1174F , U " Ahom " } ,
2020-12-27 14:30:33 +01:00
{ 0x11800 , 0x1184F , U " Dogra " } ,
{ 0x118A0 , 0x118FF , U " Warang Citi " } ,
{ 0x11900 , 0x1195F , U " Dives Akuru " } ,
{ 0x119A0 , 0x119FF , U " Nandinagari " } ,
{ 0x11A00 , 0x11A4F , U " Zanabazar Square " } ,
{ 0x11A50 , 0x11AAF , U " Soyombo " } ,
2021-09-22 15:55:39 +02:00
{ 0x11AB0 , 0x11ABF , U " Unified Canadian Aboriginal Syllabics Extended-A " } ,
2020-12-27 14:30:33 +01:00
{ 0x11AC0 , 0x11AFF , U " Pau Cin Hau " } ,
2022-09-17 22:19:11 +02:00
{ 0x11B00 , 0x11B5F , U " Devanagari Extended-A " } ,
2020-12-27 14:30:33 +01:00
{ 0x11C00 , 0x11C6F , U " Bhaiksuki " } ,
{ 0x11C70 , 0x11CBF , U " Marchen " } ,
{ 0x11D00 , 0x11D5F , U " Masaram Gondi " } ,
{ 0x11D60 , 0x11DAF , U " Gunjala Gondi " } ,
{ 0x11EE0 , 0x11EFF , U " Makasar " } ,
2022-09-17 22:19:11 +02:00
{ 0x11F00 , 0x11F5F , U " Kawi " } ,
2020-12-27 14:30:33 +01:00
{ 0x11FB0 , 0x11FBF , U " Lisu Supplement " } ,
{ 0x11FC0 , 0x11FFF , U " Tamil Supplement " } ,
{ 0x12000 , 0x123FF , U " Cuneiform " } ,
{ 0x12400 , 0x1247F , U " Cuneiform Numbers and Punctuation " } ,
{ 0x12480 , 0x1254F , U " Early Dynastic Cuneiform " } ,
2021-09-22 15:55:39 +02:00
{ 0x12F90 , 0x12FFF , U " Cypro-Minoan " } ,
2020-12-27 14:30:33 +01:00
{ 0x13000 , 0x1342F , U " Egyptian Hieroglyphs " } ,
{ 0x13430 , 0x1343F , U " Egyptian Hieroglyph Format Controls " } ,
{ 0x14400 , 0x1467F , U " Anatolian Hieroglyphs " } ,
{ 0x16800 , 0x16A3F , U " Bamum Supplement " } ,
{ 0x16A40 , 0x16A6F , U " Mro " } ,
2021-09-22 15:55:39 +02:00
{ 0x16A70 , 0x16ACF , U " Tangsa " } ,
2020-12-27 14:30:33 +01:00
{ 0x16AD0 , 0x16AFF , U " Bassa Vah " } ,
{ 0x16B00 , 0x16B8F , U " Pahawh Hmong " } ,
{ 0x16E40 , 0x16E9F , U " Medefaidrin " } ,
{ 0x16F00 , 0x16F9F , U " Miao " } ,
{ 0x16FE0 , 0x16FFF , U " Ideographic Symbols and Punctuation " } ,
{ 0x17000 , 0x187FF , U " Tangut " } ,
{ 0x18800 , 0x18AFF , U " Tangut Components " } ,
{ 0x18B00 , 0x18CFF , U " Khitan Small Script " } ,
2021-09-22 15:55:39 +02:00
{ 0x18D00 , 0x18D7F , U " Tangut Supplement " } ,
{ 0x1AFF0 , 0x1AFFF , U " Kana Extended-B " } ,
2020-12-27 14:30:33 +01:00
{ 0x1B000 , 0x1B0FF , U " Kana Supplement " } ,
{ 0x1B100 , 0x1B12F , U " Kana Extended-A " } ,
{ 0x1B130 , 0x1B16F , U " Small Kana Extension " } ,
{ 0x1B170 , 0x1B2FF , U " Nushu " } ,
{ 0x1BC00 , 0x1BC9F , U " Duployan " } ,
{ 0x1BCA0 , 0x1BCAF , U " Shorthand Format Controls " } ,
2021-09-22 15:55:39 +02:00
{ 0x1CF00 , 0x1CFCF , U " Znamenny Musical Notation " } ,
2020-12-27 14:30:33 +01:00
{ 0x1D000 , 0x1D0FF , U " Byzantine Musical Symbols " } ,
{ 0x1D100 , 0x1D1FF , U " Musical Symbols " } ,
{ 0x1D200 , 0x1D24F , U " Ancient Greek Musical Notation " } ,
2022-09-17 22:19:11 +02:00
{ 0x1D2C0 , 0x1D2DF , U " Kaktovik Numerals " } ,
2020-12-27 14:30:33 +01:00
{ 0x1D2E0 , 0x1D2FF , U " Mayan Numerals " } ,
{ 0x1D300 , 0x1D35F , U " Tai Xuan Jing Symbols " } ,
{ 0x1D360 , 0x1D37F , U " Counting Rod Numerals " } ,
{ 0x1D400 , 0x1D7FF , U " Mathematical Alphanumeric Symbols " } ,
{ 0x1D800 , 0x1DAAF , U " Sutton SignWriting " } ,
2021-09-22 15:55:39 +02:00
{ 0x1DF00 , 0x1DFFF , U " Latin Extended-G " } ,
2020-12-27 14:30:33 +01:00
{ 0x1E000 , 0x1E02F , U " Glagolitic Supplement " } ,
2022-09-17 22:19:11 +02:00
{ 0x1E030 , 0x1E08F , U " Cyrillic Extended-D " } ,
2020-12-27 14:30:33 +01:00
{ 0x1E100 , 0x1E14F , U " Nyiakeng Puachue Hmong " } ,
2021-09-22 15:55:39 +02:00
{ 0x1E290 , 0x1E2BF , U " Toto " } ,
2020-12-27 14:30:33 +01:00
{ 0x1E2C0 , 0x1E2FF , U " Wancho " } ,
2022-09-17 22:19:11 +02:00
{ 0x1E4D0 , 0x1E4FF , U " Nag Mundari " } ,
2021-09-22 15:55:39 +02:00
{ 0x1E7E0 , 0x1E7FF , U " Ethiopic Extended-B " } ,
2020-12-27 14:30:33 +01:00
{ 0x1E800 , 0x1E8DF , U " Mende Kikakui " } ,
{ 0x1E900 , 0x1E95F , U " Adlam " } ,
{ 0x1EC70 , 0x1ECBF , U " Indic Siyaq Numbers " } ,
{ 0x1ED00 , 0x1ED4F , U " Ottoman Siyaq Numbers " } ,
{ 0x1EE00 , 0x1EEFF , U " Arabic Mathematical Alphabetic Symbols " } ,
{ 0x1F000 , 0x1F02F , U " Mahjong Tiles " } ,
{ 0x1F030 , 0x1F09F , U " Domino Tiles " } ,
{ 0x1F0A0 , 0x1F0FF , U " Playing Cards " } ,
{ 0x1F100 , 0x1F1FF , U " Enclosed Alphanumeric Supplement " } ,
{ 0x1F200 , 0x1F2FF , U " Enclosed Ideographic Supplement " } ,
{ 0x1F300 , 0x1F5FF , U " Miscellaneous Symbols and Pictographs " } ,
{ 0x1F600 , 0x1F64F , U " Emoticons " } ,
{ 0x1F650 , 0x1F67F , U " Ornamental Dingbats " } ,
{ 0x1F680 , 0x1F6FF , U " Transport and Map Symbols " } ,
{ 0x1F700 , 0x1F77F , U " Alchemical Symbols " } ,
{ 0x1F780 , 0x1F7FF , U " Geometric Shapes Extended " } ,
{ 0x1F800 , 0x1F8FF , U " Supplemental Arrows-C " } ,
{ 0x1F900 , 0x1F9FF , U " Supplemental Symbols and Pictographs " } ,
{ 0x1FA00 , 0x1FA6F , U " Chess Symbols " } ,
{ 0x1FA70 , 0x1FAFF , U " Symbols and Pictographs Extended-A " } ,
{ 0x1FB00 , 0x1FBFF , U " Symbols for Legacy Computing " } ,
{ 0x20000 , 0x2A6DF , U " CJK Unified Ideographs Extension B " } ,
{ 0x2A700 , 0x2B73F , U " CJK Unified Ideographs Extension C " } ,
{ 0x2B740 , 0x2B81F , U " CJK Unified Ideographs Extension D " } ,
{ 0x2B820 , 0x2CEAF , U " CJK Unified Ideographs Extension E " } ,
{ 0x2CEB0 , 0x2EBEF , U " CJK Unified Ideographs Extension F " } ,
{ 0x2F800 , 0x2FA1F , U " CJK Compatibility Ideographs Supplement " } ,
{ 0x30000 , 0x3134F , U " CJK Unified Ideographs Extension G " } ,
2022-09-17 22:19:11 +02:00
{ 0x31350 , 0x323AF , U " CJK Unified Ideographs Extension H " } ,
2020-12-27 14:30:33 +01:00
//{ 0xE0000, 0xE007F, U"Tags" },
//{ 0xE0100, 0xE01EF, U"Variation Selectors Supplement" },
2021-09-22 15:55:39 +02:00
{ 0xF0000 , 0xFFFFF , U " Supplementary Private Use Area-A " } ,
{ 0x100000 , 0x10FFFF , U " Supplementary Private Use Area-B " } ,
2020-12-27 14:30:33 +01:00
{ 0x10FFFF , 0x10FFFF , String ( ) }
} ;
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _add_glyph_range_item ( int32_t p_start , int32_t p_end , const String & p_name ) {
2020-12-27 14:30:33 +01:00
const int page_size = 512 ;
int pages = ( p_end - p_start ) / page_size ;
int remain = ( p_end - p_start ) % page_size ;
int32_t start = p_start ;
for ( int i = 0 ; i < pages ; i + + ) {
TreeItem * item = glyph_tree - > create_item ( glyph_root ) ;
ERR_FAIL_NULL ( item ) ;
2022-01-22 21:10:30 +01:00
item - > set_cell_mode ( 0 , TreeItem : : CELL_MODE_CHECK ) ;
2020-12-27 14:30:33 +01:00
item - > set_text ( 0 , _pad_zeros ( String : : num_int64 ( start , 16 ) ) + " - " + _pad_zeros ( String : : num_int64 ( start + page_size , 16 ) ) ) ;
item - > set_text ( 1 , p_name ) ;
item - > set_metadata ( 0 , Vector2i ( start , start + page_size ) ) ;
start + = page_size ;
}
if ( remain > 0 ) {
TreeItem * item = glyph_tree - > create_item ( glyph_root ) ;
ERR_FAIL_NULL ( item ) ;
2022-01-22 21:10:30 +01:00
item - > set_cell_mode ( 0 , TreeItem : : CELL_MODE_CHECK ) ;
2020-12-27 14:30:33 +01:00
item - > set_text ( 0 , _pad_zeros ( String : : num_int64 ( start , 16 ) ) + " - " + _pad_zeros ( String : : num_int64 ( p_end , 16 ) ) ) ;
item - > set_text ( 1 , p_name ) ;
item - > set_metadata ( 0 , Vector2i ( start , p_end ) ) ;
}
}
/*************************************************************************/
/* Page 1 callbacks: Rendering Options */
/*************************************************************************/
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _main_prop_changed ( const String & p_edited_property ) {
2020-12-27 14:30:33 +01:00
// Update font preview.
2022-05-09 11:47:10 +02:00
if ( font_preview . is_valid ( ) ) {
2022-08-12 13:03:28 +02:00
if ( p_edited_property = = " antialiasing " ) {
font_preview - > set_antialiasing ( ( TextServer : : FontAntialiasing ) import_settings_data - > get ( " antialiasing " ) . operator int ( ) ) ;
2022-05-09 11:47:10 +02:00
} else if ( p_edited_property = = " generate_mipmaps " ) {
font_preview - > set_generate_mipmaps ( import_settings_data - > get ( " generate_mipmaps " ) ) ;
2024-03-11 12:42:16 +01:00
} else if ( p_edited_property = = " disable_embedded_bitmaps " ) {
font_preview - > set_disable_embedded_bitmaps ( import_settings_data - > get ( " disable_embedded_bitmaps " ) ) ;
2022-05-09 11:47:10 +02:00
} else if ( p_edited_property = = " multichannel_signed_distance_field " ) {
font_preview - > set_multichannel_signed_distance_field ( import_settings_data - > get ( " multichannel_signed_distance_field " ) ) ;
_variation_selected ( ) ;
_variations_validate ( ) ;
} else if ( p_edited_property = = " msdf_pixel_range " ) {
font_preview - > set_msdf_pixel_range ( import_settings_data - > get ( " msdf_pixel_range " ) ) ;
} else if ( p_edited_property = = " msdf_size " ) {
font_preview - > set_msdf_size ( import_settings_data - > get ( " msdf_size " ) ) ;
2022-11-21 14:04:01 +01:00
} else if ( p_edited_property = = " allow_system_fallback " ) {
font_preview - > set_allow_system_fallback ( import_settings_data - > get ( " allow_system_fallback " ) ) ;
2022-05-09 11:47:10 +02:00
} else if ( p_edited_property = = " force_autohinter " ) {
font_preview - > set_force_autohinter ( import_settings_data - > get ( " force_autohinter " ) ) ;
} else if ( p_edited_property = = " hinting " ) {
font_preview - > set_hinting ( ( TextServer : : Hinting ) import_settings_data - > get ( " hinting " ) . operator int ( ) ) ;
} else if ( p_edited_property = = " subpixel_positioning " ) {
font_preview - > set_subpixel_positioning ( ( TextServer : : SubpixelPositioning ) import_settings_data - > get ( " subpixel_positioning " ) . operator int ( ) ) ;
} else if ( p_edited_property = = " oversampling " ) {
font_preview - > set_oversampling ( import_settings_data - > get ( " oversampling " ) ) ;
2020-12-27 14:30:33 +01:00
}
}
2022-05-09 11:47:10 +02:00
2024-05-14 15:57:29 +02:00
font_preview_label - > add_theme_font_override ( SceneStringName ( font ) , font_preview ) ;
font_preview_label - > add_theme_font_size_override ( SceneStringName ( font_size ) , 200 * EDSCALE ) ;
2022-08-13 23:21:24 +02:00
font_preview_label - > queue_redraw ( ) ;
2020-12-27 14:30:33 +01:00
}
/*************************************************************************/
/* Page 2 callbacks: Configurations */
/*************************************************************************/
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _variation_add ( ) {
2020-12-27 14:30:33 +01:00
TreeItem * vars_item = vars_list - > create_item ( vars_list_root ) ;
ERR_FAIL_NULL ( vars_item ) ;
2022-11-03 19:15:12 +01:00
vars_item - > set_text ( 0 , TTR ( " New Configuration " ) ) ;
2020-12-27 14:30:33 +01:00
vars_item - > set_editable ( 0 , true ) ;
2023-08-13 02:33:39 +02:00
vars_item - > add_button ( 1 , get_editor_theme_icon ( SNAME ( " Remove " ) ) , BUTTON_REMOVE_VAR , false , TTR ( " Remove Variation " ) ) ;
2020-12-27 14:30:33 +01:00
vars_item - > set_button_color ( 1 , 0 , Color ( 1 , 1 , 1 , 0.75 ) ) ;
Ref < DynamicFontImportSettingsData > import_variation_data ;
import_variation_data . instantiate ( ) ;
import_variation_data - > owner = this ;
ERR_FAIL_NULL ( import_variation_data ) ;
for ( List < ResourceImporter : : ImportOption > : : Element * E = options_variations . front ( ) ; E ; E = E - > next ( ) ) {
import_variation_data - > defaults [ E - > get ( ) . option . name ] = E - > get ( ) . default_value ;
}
import_variation_data - > options = options_variations ;
inspector_vars - > edit ( import_variation_data . ptr ( ) ) ;
import_variation_data - > notify_property_list_changed ( ) ;
2022-05-09 11:47:10 +02:00
import_variation_data - > fd = font_main ;
2020-12-27 14:30:33 +01:00
vars_item - > set_metadata ( 0 , import_variation_data ) ;
_variations_validate ( ) ;
}
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _variation_selected ( ) {
2020-12-27 14:30:33 +01:00
TreeItem * vars_item = vars_list - > get_selected ( ) ;
if ( vars_item ) {
Ref < DynamicFontImportSettingsData > import_variation_data = vars_item - > get_metadata ( 0 ) ;
ERR_FAIL_NULL ( import_variation_data ) ;
inspector_vars - > edit ( import_variation_data . ptr ( ) ) ;
import_variation_data - > notify_property_list_changed ( ) ;
2022-05-09 11:47:10 +02:00
2023-02-09 10:01:32 +01:00
label_glyphs - > set_text ( vformat ( TTR ( " Preloaded glyphs: %d " ) , import_variation_data - > selected_glyphs . size ( ) ) ) ;
2022-05-09 11:47:10 +02:00
_range_selected ( ) ;
_change_text_opts ( ) ;
2022-11-09 13:45:21 +01:00
btn_fill - > set_disabled ( false ) ;
btn_fill_locales - > set_disabled ( false ) ;
} else {
btn_fill - > set_disabled ( true ) ;
btn_fill_locales - > set_disabled ( true ) ;
2020-12-27 14:30:33 +01:00
}
}
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _variation_remove ( Object * p_item , int p_column , int p_id , MouseButton p_button ) {
2021-09-18 09:33:18 +02:00
if ( p_button ! = MouseButton : : LEFT ) {
return ;
}
2020-12-27 14:30:33 +01:00
TreeItem * vars_item = ( TreeItem * ) p_item ;
ERR_FAIL_NULL ( vars_item ) ;
inspector_vars - > edit ( nullptr ) ;
vars_list_root - > remove_child ( vars_item ) ;
memdelete ( vars_item ) ;
if ( vars_list_root - > get_first_child ( ) ) {
Ref < DynamicFontImportSettingsData > import_variation_data = vars_list_root - > get_first_child ( ) - > get_metadata ( 0 ) ;
inspector_vars - > edit ( import_variation_data . ptr ( ) ) ;
import_variation_data - > notify_property_list_changed ( ) ;
}
_variations_validate ( ) ;
2022-11-09 13:45:21 +01:00
vars_item = vars_list - > get_selected ( ) ;
if ( vars_item ) {
btn_fill - > set_disabled ( false ) ;
btn_fill_locales - > set_disabled ( false ) ;
} else {
btn_fill - > set_disabled ( true ) ;
btn_fill_locales - > set_disabled ( true ) ;
}
2020-12-27 14:30:33 +01:00
}
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _variation_changed ( const String & p_edited_property ) {
2020-12-27 14:30:33 +01:00
_variations_validate ( ) ;
}
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _variations_validate ( ) {
2020-12-27 14:30:33 +01:00
String warn ;
if ( ! vars_list_root - > get_first_child ( ) ) {
2022-02-21 19:30:16 +01:00
warn = TTR ( " Warning: There are no configurations specified, no glyphs will be pre-rendered. " ) ;
2020-12-27 14:30:33 +01:00
}
for ( TreeItem * vars_item_a = vars_list_root - > get_first_child ( ) ; vars_item_a ; vars_item_a = vars_item_a - > get_next ( ) ) {
Ref < DynamicFontImportSettingsData > import_variation_data_a = vars_item_a - > get_metadata ( 0 ) ;
ERR_FAIL_NULL ( import_variation_data_a ) ;
for ( TreeItem * vars_item_b = vars_list_root - > get_first_child ( ) ; vars_item_b ; vars_item_b = vars_item_b - > get_next ( ) ) {
if ( vars_item_b ! = vars_item_a ) {
bool match = true ;
2022-05-13 15:04:37 +02:00
for ( const KeyValue < StringName , Variant > & E : import_variation_data_a - > settings ) {
2020-12-27 14:30:33 +01:00
Ref < DynamicFontImportSettingsData > import_variation_data_b = vars_item_b - > get_metadata ( 0 ) ;
ERR_FAIL_NULL ( import_variation_data_b ) ;
2022-05-13 15:04:37 +02:00
match = match & & ( import_variation_data_b - > settings [ E . key ] = = E . value ) ;
2020-12-27 14:30:33 +01:00
}
if ( match ) {
2022-02-21 19:30:16 +01:00
warn = TTR ( " Warning: Multiple configurations have identical settings. Duplicates will be ignored. " ) ;
2020-12-27 14:30:33 +01:00
break ;
}
}
}
}
2022-08-12 13:03:28 +02:00
if ( ( TextServer : : FontAntialiasing ) ( int ) import_settings_data - > get ( " antialiasing " ) = = TextServer : : FONT_ANTIALIASING_LCD ) {
2022-11-03 18:37:21 +01:00
warn + = " \n " + TTR ( " Note: LCD Subpixel antialiasing is selected, each of the glyphs will be pre-rendered for all supported subpixel layouts (5x). " ) ;
2022-08-12 13:03:28 +02:00
}
if ( ( TextServer : : SubpixelPositioning ) ( int ) import_settings_data - > get ( " subpixel_positioning " ) ! = TextServer : : SUBPIXEL_POSITIONING_DISABLED ) {
2022-11-03 18:37:21 +01:00
warn + = " \n " + TTR ( " Note: Subpixel positioning is selected, each of the glyphs might be pre-rendered for multiple subpixel offsets (up to 4x). " ) ;
2022-08-12 13:03:28 +02:00
}
2020-12-27 14:30:33 +01:00
if ( warn . is_empty ( ) ) {
label_warn - > set_text ( " " ) ;
label_warn - > hide ( ) ;
} else {
label_warn - > set_text ( warn ) ;
label_warn - > show ( ) ;
}
}
/*************************************************************************/
2022-05-09 11:47:10 +02:00
/* Page 2.1 callbacks: Text to select glyphs */
2020-12-27 14:30:33 +01:00
/*************************************************************************/
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _change_text_opts ( ) {
2022-05-09 11:47:10 +02:00
Ref < DynamicFontImportSettingsData > import_variation_data ;
TreeItem * vars_item = vars_list - > get_selected ( ) ;
if ( vars_item ) {
import_variation_data = vars_item - > get_metadata ( 0 ) ;
2020-12-27 14:30:33 +01:00
}
2022-05-09 11:47:10 +02:00
if ( import_variation_data . is_null ( ) ) {
return ;
}
Ref < FontVariation > font_main_text ;
font_main_text . instantiate ( ) ;
font_main_text - > set_base_font ( font_main ) ;
font_main_text - > set_opentype_features ( text_settings_data - > get ( " opentype_features " ) ) ;
font_main_text - > set_variation_opentype ( import_variation_data - > get ( " variation_opentype " ) ) ;
font_main_text - > set_variation_embolden ( import_variation_data - > get ( " variation_embolden " ) ) ;
font_main_text - > set_variation_face_index ( import_variation_data - > get ( " variation_face_index " ) ) ;
font_main_text - > set_variation_transform ( import_variation_data - > get ( " variation_transform " ) ) ;
2024-05-14 15:57:29 +02:00
text_edit - > add_theme_font_override ( SceneStringName ( font ) , font_main_text ) ;
2020-12-27 14:30:33 +01:00
}
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _glyph_update_lbl ( ) {
2022-11-09 13:45:21 +01:00
Ref < DynamicFontImportSettingsData > import_variation_data ;
TreeItem * vars_item = vars_list - > get_selected ( ) ;
if ( vars_item ) {
import_variation_data = vars_item - > get_metadata ( 0 ) ;
}
if ( import_variation_data . is_null ( ) ) {
return ;
}
int linked_glyphs = 0 ;
for ( const char32_t & c : import_variation_data - > selected_chars ) {
if ( import_variation_data - > selected_glyphs . has ( font_main - > get_glyph_index ( 16 , c ) ) ) {
linked_glyphs + + ;
}
}
int unlinked_glyphs = import_variation_data - > selected_glyphs . size ( ) - linked_glyphs ;
2023-02-09 10:01:32 +01:00
label_glyphs - > set_text ( vformat ( TTR ( " Preloaded glyphs: %d " ) , unlinked_glyphs + import_variation_data - > selected_chars . size ( ) ) ) ;
2022-11-09 13:45:21 +01:00
}
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _glyph_clear ( ) {
2022-05-09 11:47:10 +02:00
Ref < DynamicFontImportSettingsData > import_variation_data ;
TreeItem * vars_item = vars_list - > get_selected ( ) ;
if ( vars_item ) {
import_variation_data = vars_item - > get_metadata ( 0 ) ;
}
if ( import_variation_data . is_null ( ) ) {
return ;
}
import_variation_data - > selected_glyphs . clear ( ) ;
2022-11-09 13:45:21 +01:00
_glyph_update_lbl ( ) ;
2020-12-27 14:30:33 +01:00
_range_selected ( ) ;
}
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _glyph_text_selected ( ) {
2022-05-09 11:47:10 +02:00
Ref < DynamicFontImportSettingsData > import_variation_data ;
2020-12-27 14:30:33 +01:00
2022-05-09 11:47:10 +02:00
TreeItem * vars_item = vars_list - > get_selected ( ) ;
if ( vars_item ) {
import_variation_data = vars_item - > get_metadata ( 0 ) ;
}
if ( import_variation_data . is_null ( ) ) {
return ;
}
2020-12-27 14:30:33 +01:00
RID text_rid = TS - > create_shaped_text ( ) ;
if ( text_rid . is_valid ( ) ) {
2022-05-09 11:47:10 +02:00
TS - > shaped_text_add_string ( text_rid , text_edit - > get_text ( ) , font_main - > get_rids ( ) , 16 , text_settings_data - > get ( " opentype_features " ) , text_settings_data - > get ( " language " ) ) ;
2020-12-27 14:30:33 +01:00
TS - > shaped_text_shape ( text_rid ) ;
2021-08-27 23:19:51 +02:00
const Glyph * gl = TS - > shaped_text_get_glyphs ( text_rid ) ;
const int gl_size = TS - > shaped_text_get_glyph_count ( text_rid ) ;
2020-12-27 14:30:33 +01:00
2021-08-27 23:19:51 +02:00
for ( int i = 0 ; i < gl_size ; i + + ) {
2020-12-27 14:30:33 +01:00
if ( gl [ i ] . font_rid . is_valid ( ) & & gl [ i ] . index ! = 0 ) {
2022-05-09 11:47:10 +02:00
import_variation_data - > selected_glyphs . insert ( gl [ i ] . index ) ;
2020-12-27 14:30:33 +01:00
}
}
2022-02-13 13:41:29 +01:00
TS - > free_rid ( text_rid ) ;
2022-11-09 13:45:21 +01:00
_glyph_update_lbl ( ) ;
2020-12-27 14:30:33 +01:00
}
_range_selected ( ) ;
}
/*************************************************************************/
2022-05-09 11:47:10 +02:00
/* Page 2.2 callbacks: Character map */
2020-12-27 14:30:33 +01:00
/*************************************************************************/
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _glyph_selected ( ) {
2022-05-09 11:47:10 +02:00
Ref < DynamicFontImportSettingsData > import_variation_data ;
TreeItem * vars_item = vars_list - > get_selected ( ) ;
if ( vars_item ) {
import_variation_data = vars_item - > get_metadata ( 0 ) ;
}
if ( import_variation_data . is_null ( ) ) {
return ;
}
2020-12-27 14:30:33 +01:00
TreeItem * item = glyph_table - > get_selected ( ) ;
ERR_FAIL_NULL ( item ) ;
2023-08-13 02:33:39 +02:00
Color scol = glyph_table - > get_theme_color ( SNAME ( " box_selection_fill_color " ) , EditorStringName ( Editor ) ) ;
Color fcol = glyph_table - > get_theme_color ( SNAME ( " font_selected_color " ) , EditorStringName ( Editor ) ) ;
2020-12-27 14:30:33 +01:00
scol . a = 1.f ;
int32_t c = item - > get_metadata ( glyph_table - > get_selected_column ( ) ) ;
if ( font_main - > has_char ( c ) ) {
if ( _char_update ( c ) ) {
item - > set_custom_color ( glyph_table - > get_selected_column ( ) , fcol ) ;
item - > set_custom_bg_color ( glyph_table - > get_selected_column ( ) , scol ) ;
} else {
item - > clear_custom_color ( glyph_table - > get_selected_column ( ) ) ;
item - > clear_custom_bg_color ( glyph_table - > get_selected_column ( ) ) ;
}
}
2022-11-09 13:45:21 +01:00
_glyph_update_lbl ( ) ;
2022-01-22 21:10:30 +01:00
item = glyph_tree - > get_selected ( ) ;
ERR_FAIL_NULL ( item ) ;
Vector2i range = item - > get_metadata ( 0 ) ;
int total_chars = range . y - range . x ;
int selected_count = 0 ;
for ( int i = range . x ; i < range . y ; i + + ) {
if ( ! font_main - > has_char ( i ) ) {
total_chars - - ;
}
2022-05-09 11:47:10 +02:00
if ( import_variation_data - > selected_chars . has ( i ) ) {
2022-01-22 21:10:30 +01:00
selected_count + + ;
}
}
if ( selected_count = = total_chars ) {
item - > set_checked ( 0 , true ) ;
} else if ( selected_count > 0 ) {
item - > set_indeterminate ( 0 , true ) ;
} else {
item - > set_checked ( 0 , false ) ;
}
2020-12-27 14:30:33 +01:00
}
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _range_edited ( ) {
2020-12-27 14:30:33 +01:00
TreeItem * item = glyph_tree - > get_selected ( ) ;
ERR_FAIL_NULL ( item ) ;
Vector2i range = item - > get_metadata ( 0 ) ;
_range_update ( range . x , range . y ) ;
}
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _range_selected ( ) {
2020-12-27 14:30:33 +01:00
TreeItem * item = glyph_tree - > get_selected ( ) ;
if ( item ) {
Vector2i range = item - > get_metadata ( 0 ) ;
_edit_range ( range . x , range . y ) ;
}
}
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _edit_range ( int32_t p_start , int32_t p_end ) {
2022-05-09 11:47:10 +02:00
Ref < DynamicFontImportSettingsData > import_variation_data ;
TreeItem * vars_item = vars_list - > get_selected ( ) ;
if ( vars_item ) {
import_variation_data = vars_item - > get_metadata ( 0 ) ;
}
if ( import_variation_data . is_null ( ) ) {
return ;
}
2020-12-27 14:30:33 +01:00
glyph_table - > clear ( ) ;
TreeItem * root = glyph_table - > create_item ( ) ;
ERR_FAIL_NULL ( root ) ;
2023-08-13 02:33:39 +02:00
Color scol = glyph_table - > get_theme_color ( SNAME ( " box_selection_fill_color " ) , EditorStringName ( Editor ) ) ;
Color fcol = glyph_table - > get_theme_color ( SNAME ( " font_selected_color " ) , EditorStringName ( Editor ) ) ;
2020-12-27 14:30:33 +01:00
scol . a = 1.f ;
TreeItem * item = nullptr ;
int col = 0 ;
2022-05-09 11:47:10 +02:00
Ref < Font > font_main_big = font_main - > duplicate ( ) ;
2020-12-27 14:30:33 +01:00
for ( int32_t c = p_start ; c < = p_end ; c + + ) {
if ( col = = 0 ) {
item = glyph_table - > create_item ( root ) ;
ERR_FAIL_NULL ( item ) ;
item - > set_text ( 0 , _pad_zeros ( String : : num_int64 ( c , 16 ) ) ) ;
2021-11-25 03:58:47 +01:00
item - > set_text_alignment ( 0 , HORIZONTAL_ALIGNMENT_LEFT ) ;
2020-12-27 14:30:33 +01:00
item - > set_selectable ( 0 , false ) ;
2023-08-13 02:33:39 +02:00
item - > set_custom_bg_color ( 0 , glyph_table - > get_theme_color ( SNAME ( " dark_color_3 " ) , EditorStringName ( Editor ) ) ) ;
2020-12-27 14:30:33 +01:00
}
if ( font_main - > has_char ( c ) ) {
item - > set_text ( col + 1 , String : : chr ( c ) ) ;
item - > set_custom_color ( col + 1 , Color ( 1 , 1 , 1 ) ) ;
2022-05-09 11:47:10 +02:00
if ( import_variation_data - > selected_chars . has ( c ) | | import_variation_data - > selected_glyphs . has ( font_main - > get_glyph_index ( 16 , c ) ) ) {
2020-12-27 14:30:33 +01:00
item - > set_custom_color ( col + 1 , fcol ) ;
item - > set_custom_bg_color ( col + 1 , scol ) ;
} else {
item - > clear_custom_color ( col + 1 ) ;
item - > clear_custom_bg_color ( col + 1 ) ;
}
} else {
2023-08-13 02:33:39 +02:00
item - > set_custom_bg_color ( col + 1 , glyph_table - > get_theme_color ( SNAME ( " dark_color_2 " ) , EditorStringName ( Editor ) ) ) ;
2020-12-27 14:30:33 +01:00
}
item - > set_metadata ( col + 1 , c ) ;
2021-11-25 03:58:47 +01:00
item - > set_text_alignment ( col + 1 , HORIZONTAL_ALIGNMENT_CENTER ) ;
2020-12-27 14:30:33 +01:00
item - > set_selectable ( col + 1 , true ) ;
2022-05-09 11:47:10 +02:00
item - > set_custom_font ( col + 1 , font_main_big ) ;
2024-05-14 15:57:29 +02:00
item - > set_custom_font_size ( col + 1 , get_theme_font_size ( SceneStringName ( font_size ) ) * 2 ) ;
2020-12-27 14:30:33 +01:00
col + + ;
if ( col = = 16 ) {
col = 0 ;
}
}
2022-11-09 13:45:21 +01:00
_glyph_update_lbl ( ) ;
2020-12-27 14:30:33 +01:00
}
2023-10-06 09:00:36 +02:00
bool DynamicFontImportSettingsDialog : : _char_update ( int32_t p_char ) {
2022-05-09 11:47:10 +02:00
Ref < DynamicFontImportSettingsData > import_variation_data ;
TreeItem * vars_item = vars_list - > get_selected ( ) ;
if ( vars_item ) {
import_variation_data = vars_item - > get_metadata ( 0 ) ;
}
if ( import_variation_data . is_null ( ) ) {
2020-12-27 14:30:33 +01:00
return false ;
2022-05-09 11:47:10 +02:00
}
if ( import_variation_data - > selected_chars . has ( p_char ) ) {
import_variation_data - > selected_chars . erase ( p_char ) ;
return false ;
2023-05-30 11:47:50 +02:00
} else if ( font_main . is_valid ( ) & & import_variation_data - > selected_glyphs . has ( font_main - > get_glyph_index ( 16 , p_char ) ) ) {
2022-05-09 11:47:10 +02:00
import_variation_data - > selected_glyphs . erase ( font_main - > get_glyph_index ( 16 , p_char ) ) ;
2020-12-27 14:30:33 +01:00
return false ;
} else {
2022-05-09 11:47:10 +02:00
import_variation_data - > selected_chars . insert ( p_char ) ;
2020-12-27 14:30:33 +01:00
return true ;
}
}
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _range_update ( int32_t p_start , int32_t p_end ) {
2022-05-09 11:47:10 +02:00
Ref < DynamicFontImportSettingsData > import_variation_data ;
TreeItem * vars_item = vars_list - > get_selected ( ) ;
if ( vars_item ) {
import_variation_data = vars_item - > get_metadata ( 0 ) ;
}
if ( import_variation_data . is_null ( ) ) {
return ;
}
2020-12-27 14:30:33 +01:00
bool all_selected = true ;
for ( int32_t i = p_start ; i < = p_end ; i + + ) {
if ( font_main - > has_char ( i ) ) {
2022-05-09 11:47:10 +02:00
if ( font_main . is_valid ( ) ) {
all_selected = all_selected & & ( import_variation_data - > selected_chars . has ( i ) | | import_variation_data - > selected_glyphs . has ( font_main - > get_glyph_index ( 16 , i ) ) ) ;
2020-12-27 14:30:33 +01:00
} else {
2022-05-09 11:47:10 +02:00
all_selected = all_selected & & import_variation_data - > selected_chars . has ( i ) ;
2020-12-27 14:30:33 +01:00
}
}
}
for ( int32_t i = p_start ; i < = p_end ; i + + ) {
if ( font_main - > has_char ( i ) ) {
if ( ! all_selected ) {
2022-05-09 11:47:10 +02:00
import_variation_data - > selected_chars . insert ( i ) ;
2020-12-27 14:30:33 +01:00
} else {
2022-05-09 11:47:10 +02:00
import_variation_data - > selected_chars . erase ( i ) ;
if ( font_main . is_valid ( ) ) {
import_variation_data - > selected_glyphs . erase ( font_main - > get_glyph_index ( 16 , i ) ) ;
2020-12-27 14:30:33 +01:00
}
}
}
}
_edit_range ( p_start , p_end ) ;
2022-01-22 21:10:30 +01:00
TreeItem * item = glyph_tree - > get_selected ( ) ;
ERR_FAIL_NULL ( item ) ;
item - > set_checked ( 0 , ! all_selected ) ;
2020-12-27 14:30:33 +01:00
}
/*************************************************************************/
/* Common */
/*************************************************************************/
2023-10-06 09:00:36 +02:00
DynamicFontImportSettingsDialog * DynamicFontImportSettingsDialog : : singleton = nullptr ;
2020-12-27 14:30:33 +01:00
2023-10-06 09:00:36 +02:00
String DynamicFontImportSettingsDialog : : _pad_zeros ( const String & p_hex ) const {
2020-12-27 14:30:33 +01:00
int len = CLAMP ( 5 - p_hex . length ( ) , 0 , 5 ) ;
return String ( " 0 " ) . repeat ( len ) + p_hex ;
}
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _notification ( int p_what ) {
2022-02-16 03:44:22 +01:00
switch ( p_what ) {
case NOTIFICATION_READY : {
2024-05-14 14:28:18 +02:00
connect ( SceneStringName ( confirmed ) , callable_mp ( this , & DynamicFontImportSettingsDialog : : _re_import ) ) ;
2022-02-16 03:44:22 +01:00
} break ;
case NOTIFICATION_THEME_CHANGED : {
2023-08-13 02:33:39 +02:00
add_var - > set_icon ( get_editor_theme_icon ( SNAME ( " Add " ) ) ) ;
2024-05-14 15:57:29 +02:00
label_warn - > add_theme_color_override ( SceneStringName ( font_color ) , get_theme_color ( SNAME ( " warning_color " ) , EditorStringName ( Editor ) ) ) ;
2022-02-16 03:44:22 +01:00
} break ;
2020-12-27 14:30:33 +01:00
}
}
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _re_import ( ) {
2022-05-13 15:04:37 +02:00
HashMap < StringName , Variant > main_settings ;
2020-12-27 14:30:33 +01:00
2022-06-07 10:35:59 +02:00
main_settings [ " face_index " ] = import_settings_data - > get ( " face_index " ) ;
2022-08-12 13:03:28 +02:00
main_settings [ " antialiasing " ] = import_settings_data - > get ( " antialiasing " ) ;
2022-04-19 12:27:18 +02:00
main_settings [ " generate_mipmaps " ] = import_settings_data - > get ( " generate_mipmaps " ) ;
2024-03-11 12:42:16 +01:00
main_settings [ " disable_embedded_bitmaps " ] = import_settings_data - > get ( " disable_embedded_bitmaps " ) ;
2020-12-27 14:30:33 +01:00
main_settings [ " multichannel_signed_distance_field " ] = import_settings_data - > get ( " multichannel_signed_distance_field " ) ;
main_settings [ " msdf_pixel_range " ] = import_settings_data - > get ( " msdf_pixel_range " ) ;
main_settings [ " msdf_size " ] = import_settings_data - > get ( " msdf_size " ) ;
2022-11-21 14:04:01 +01:00
main_settings [ " allow_system_fallback " ] = import_settings_data - > get ( " allow_system_fallback " ) ;
2020-12-27 14:30:33 +01:00
main_settings [ " force_autohinter " ] = import_settings_data - > get ( " force_autohinter " ) ;
main_settings [ " hinting " ] = import_settings_data - > get ( " hinting " ) ;
2022-01-10 09:13:22 +01:00
main_settings [ " subpixel_positioning " ] = import_settings_data - > get ( " subpixel_positioning " ) ;
2020-12-27 14:30:33 +01:00
main_settings [ " oversampling " ] = import_settings_data - > get ( " oversampling " ) ;
2022-05-09 11:47:10 +02:00
main_settings [ " fallbacks " ] = import_settings_data - > get ( " fallbacks " ) ;
2020-12-27 14:30:33 +01:00
main_settings [ " compress " ] = import_settings_data - > get ( " compress " ) ;
2022-05-09 11:47:10 +02:00
Array configurations ;
2020-12-27 14:30:33 +01:00
for ( TreeItem * vars_item = vars_list_root - > get_first_child ( ) ; vars_item ; vars_item = vars_item - > get_next ( ) ) {
Ref < DynamicFontImportSettingsData > import_variation_data = vars_item - > get_metadata ( 0 ) ;
ERR_FAIL_NULL ( import_variation_data ) ;
2022-05-09 11:47:10 +02:00
Dictionary preload_config ;
preload_config [ " name " ] = vars_item - > get_text ( 0 ) ;
2022-12-12 21:14:15 +01:00
Size2i conf_size = Vector2i ( 16 , 0 ) ;
2022-05-13 15:04:37 +02:00
for ( const KeyValue < StringName , Variant > & E : import_variation_data - > settings ) {
2022-12-12 21:14:15 +01:00
if ( E . key = = " size " ) {
conf_size . x = E . value ;
}
if ( E . key = = " outline_size " ) {
conf_size . y = E . value ;
} else {
preload_config [ E . key ] = E . value ;
}
2020-12-27 14:30:33 +01:00
}
2022-12-12 21:14:15 +01:00
preload_config [ " size " ] = conf_size ;
2022-05-09 11:47:10 +02:00
Array chars ;
for ( const char32_t & E : import_variation_data - > selected_chars ) {
chars . push_back ( E ) ;
2020-12-27 14:30:33 +01:00
}
2022-05-09 11:47:10 +02:00
preload_config [ " chars " ] = chars ;
2020-12-27 14:30:33 +01:00
2022-05-09 11:47:10 +02:00
Array glyphs ;
for ( const int32_t & E : import_variation_data - > selected_glyphs ) {
glyphs . push_back ( E ) ;
2020-12-27 14:30:33 +01:00
}
2022-05-09 11:47:10 +02:00
preload_config [ " glyphs " ] = glyphs ;
2020-12-27 14:30:33 +01:00
2022-05-09 11:47:10 +02:00
configurations . push_back ( preload_config ) ;
2021-11-18 22:36:22 +01:00
}
2022-05-09 11:47:10 +02:00
main_settings [ " preload " ] = configurations ;
main_settings [ " language_support " ] = import_settings_data - > get ( " language_support " ) ;
main_settings [ " script_support " ] = import_settings_data - > get ( " script_support " ) ;
main_settings [ " opentype_features " ] = import_settings_data - > get ( " opentype_features " ) ;
2021-11-18 22:36:22 +01:00
2020-12-27 14:30:33 +01:00
if ( OS : : get_singleton ( ) - > is_stdout_verbose ( ) ) {
print_line ( " Import settings: " ) ;
2022-05-13 15:04:37 +02:00
for ( const KeyValue < StringName , Variant > & E : main_settings ) {
print_line ( String ( " " ) + String ( E . key ) . utf8 ( ) . get_data ( ) + " == " + String ( E . value ) . utf8 ( ) . get_data ( ) ) ;
2020-12-27 14:30:33 +01:00
}
}
EditorFileSystem : : get_singleton ( ) - > reimport_file_with_custom_parameters ( base_path , " font_data_dynamic " , main_settings ) ;
}
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _locale_edited ( ) {
2022-11-09 13:45:21 +01:00
TreeItem * item = locale_tree - > get_selected ( ) ;
ERR_FAIL_NULL ( item ) ;
item - > set_checked ( 0 , ! item - > is_checked ( 0 ) ) ;
}
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : _process_locales ( ) {
2022-11-09 13:45:21 +01:00
Ref < DynamicFontImportSettingsData > import_variation_data ;
TreeItem * vars_item = vars_list - > get_selected ( ) ;
if ( vars_item ) {
import_variation_data = vars_item - > get_metadata ( 0 ) ;
}
if ( import_variation_data . is_null ( ) ) {
return ;
}
for ( int i = 0 ; i < locale_root - > get_child_count ( ) ; i + + ) {
TreeItem * item = locale_root - > get_child ( i ) ;
if ( item ) {
if ( item - > is_checked ( 0 ) ) {
String locale = item - > get_text ( 0 ) ;
Ref < Translation > tr = ResourceLoader : : load ( locale ) ;
if ( tr . is_valid ( ) ) {
Vector < String > messages = tr - > get_translated_message_list ( ) ;
for ( const String & E : messages ) {
RID text_rid = TS - > create_shaped_text ( ) ;
if ( text_rid . is_valid ( ) ) {
TS - > shaped_text_add_string ( text_rid , E , font_main - > get_rids ( ) , 16 , Dictionary ( ) , tr - > get_locale ( ) ) ;
TS - > shaped_text_shape ( text_rid ) ;
const Glyph * gl = TS - > shaped_text_get_glyphs ( text_rid ) ;
const int gl_size = TS - > shaped_text_get_glyph_count ( text_rid ) ;
for ( int j = 0 ; j < gl_size ; j + + ) {
if ( gl [ j ] . font_rid . is_valid ( ) & & gl [ j ] . index ! = 0 ) {
import_variation_data - > selected_glyphs . insert ( gl [ j ] . index ) ;
}
}
TS - > free_rid ( text_rid ) ;
}
}
}
}
}
}
_glyph_update_lbl ( ) ;
_range_selected ( ) ;
}
2023-10-06 09:00:36 +02:00
void DynamicFontImportSettingsDialog : : open_settings ( const String & p_path ) {
2020-12-27 14:30:33 +01:00
// Load base font data.
2022-11-21 14:04:01 +01:00
Vector < uint8_t > font_data = FileAccess : : get_file_as_bytes ( p_path ) ;
2020-12-27 14:30:33 +01:00
2022-11-09 13:45:21 +01:00
// Load project locale list.
locale_tree - > clear ( ) ;
locale_root = locale_tree - > create_item ( ) ;
ERR_FAIL_NULL ( locale_root ) ;
Vector < String > translations = GLOBAL_GET ( " internationalization/locale/translations " ) ;
for ( const String & E : translations ) {
TreeItem * item = locale_tree - > create_item ( locale_root ) ;
ERR_FAIL_NULL ( item ) ;
item - > set_cell_mode ( 0 , TreeItem : : CELL_MODE_CHECK ) ;
item - > set_text ( 0 , E ) ;
}
2020-12-27 14:30:33 +01:00
// Load font for preview.
font_preview . instantiate ( ) ;
2022-09-29 11:53:28 +02:00
font_preview - > set_data ( font_data ) ;
2020-12-27 14:30:33 +01:00
2022-05-09 11:47:10 +02:00
String font_name = vformat ( " %s (%s) " , font_preview - > get_font_name ( ) , font_preview - > get_font_style_name ( ) ) ;
2020-12-27 14:30:33 +01:00
String sample ;
static const String sample_base = U " 12漢字ԱբΑ α А б Α α אבا بܐܒހށआআਆઆଆஆఆಆആආกิກິༀကႠა한글ሀ ᎣᐁᚁᚠᜀᜠᝀᝠកᠠᤁᥐAb😀 " ;
for ( int i = 0 ; i < sample_base . length ( ) ; i + + ) {
2022-05-09 11:47:10 +02:00
if ( font_preview - > has_char ( sample_base [ i ] ) ) {
2020-12-27 14:30:33 +01:00
sample + = sample_base [ i ] ;
}
}
if ( sample . is_empty ( ) ) {
2022-05-09 11:47:10 +02:00
sample = font_preview - > get_supported_chars ( ) . substr ( 0 , 6 ) ;
2020-12-27 14:30:33 +01:00
}
font_preview_label - > set_text ( sample ) ;
2023-08-13 02:33:39 +02:00
Ref < Font > bold_font = get_theme_font ( SNAME ( " bold " ) , EditorStringName ( EditorFonts ) ) ;
2023-05-30 11:47:50 +02:00
if ( bold_font . is_valid ( ) ) {
2022-05-09 11:47:10 +02:00
font_name_label - > add_theme_font_override ( " bold_font " , bold_font ) ;
}
font_name_label - > set_text ( font_name ) ;
2020-12-27 14:30:33 +01:00
2022-05-09 11:47:10 +02:00
// Load second copy of font with MSDF disabled for the glyph table and metadata extraction.
2020-12-27 14:30:33 +01:00
font_main . instantiate ( ) ;
2022-09-29 11:53:28 +02:00
font_main - > set_data ( font_data ) ;
2022-05-09 11:47:10 +02:00
font_main - > set_multichannel_signed_distance_field ( false ) ;
2024-05-14 15:57:29 +02:00
text_edit - > add_theme_font_override ( SceneStringName ( font ) , font_main ) ;
2020-12-27 14:30:33 +01:00
base_path = p_path ;
inspector_vars - > edit ( nullptr ) ;
2022-07-26 04:28:44 +02:00
inspector_text - > edit ( nullptr ) ;
2020-12-27 14:30:33 +01:00
inspector_general - > edit ( nullptr ) ;
2022-05-09 11:47:10 +02:00
text_settings_data . instantiate ( ) ;
ERR_FAIL_NULL ( text_settings_data ) ;
text_settings_data - > owner = this ;
for ( List < ResourceImporter : : ImportOption > : : Element * F = options_text . front ( ) ; F ; F = F - > next ( ) ) {
text_settings_data - > defaults [ F - > get ( ) . option . name ] = F - > get ( ) . default_value ;
}
text_settings_data - > fd = font_main ;
text_settings_data - > options = options_text ;
inspector_text - > edit ( text_settings_data . ptr ( ) ) ;
2024-05-14 15:57:29 +02:00
int gww = get_theme_font ( SceneStringName ( font ) ) - > get_string_size ( " 00000 " ) . x + 50 ;
2020-12-27 14:30:33 +01:00
glyph_table - > set_column_custom_minimum_width ( 0 , gww ) ;
glyph_table - > clear ( ) ;
vars_list - > clear ( ) ;
2022-11-09 13:45:21 +01:00
glyph_tree - > set_selected ( glyph_root - > get_child ( 0 ) ) ;
2020-12-27 14:30:33 +01:00
vars_list_root = vars_list - > create_item ( ) ;
2022-09-22 07:20:40 +02:00
import_settings_data - > settings . clear ( ) ;
2020-12-27 14:30:33 +01:00
import_settings_data - > defaults . clear ( ) ;
for ( List < ResourceImporter : : ImportOption > : : Element * E = options_general . front ( ) ; E ; E = E - > next ( ) ) {
import_settings_data - > defaults [ E - > get ( ) . option . name ] = E - > get ( ) . default_value ;
}
Ref < ConfigFile > config ;
config . instantiate ( ) ;
ERR_FAIL_NULL ( config ) ;
Error err = config - > load ( p_path + " .import " ) ;
print_verbose ( " Loading import settings: " ) ;
if ( err = = OK ) {
List < String > keys ;
config - > get_section_keys ( " params " , & keys ) ;
for ( List < String > : : Element * E = keys . front ( ) ; E ; E = E - > next ( ) ) {
String key = E - > get ( ) ;
print_verbose ( String ( " " ) + key + " == " + String ( config - > get_value ( " params " , key ) ) ) ;
2022-05-09 11:47:10 +02:00
if ( key = = " preload " ) {
Array preload_configurations = config - > get_value ( " params " , key ) ;
for ( int i = 0 ; i < preload_configurations . size ( ) ; i + + ) {
Dictionary preload_config = preload_configurations [ i ] ;
Dictionary variation = preload_config . has ( " variation_opentype " ) ? preload_config [ " variation_opentype " ] . operator Dictionary ( ) : Dictionary ( ) ;
double embolden = preload_config . has ( " variation_embolden " ) ? preload_config [ " variation_embolden " ] . operator double ( ) : 0 ;
int face_index = preload_config . has ( " variation_face_index " ) ? preload_config [ " variation_face_index " ] . operator int ( ) : 0 ;
Transform2D transform = preload_config . has ( " variation_transform " ) ? preload_config [ " variation_transform " ] . operator Transform2D ( ) : Transform2D ( ) ;
2022-09-29 11:53:28 +02:00
Vector2i font_size = preload_config . has ( " size " ) ? preload_config [ " size " ] . operator Vector2i ( ) : Vector2i ( 16 , 0 ) ;
2022-05-09 11:47:10 +02:00
String cfg_name = preload_config . has ( " name " ) ? preload_config [ " name " ] . operator String ( ) : vformat ( " Configuration %d " , i ) ;
2020-12-27 14:30:33 +01:00
TreeItem * vars_item = vars_list - > create_item ( vars_list_root ) ;
ERR_FAIL_NULL ( vars_item ) ;
2022-05-09 11:47:10 +02:00
vars_item - > set_text ( 0 , cfg_name ) ;
2020-12-27 14:30:33 +01:00
vars_item - > set_editable ( 0 , true ) ;
2023-08-13 02:33:39 +02:00
vars_item - > add_button ( 1 , get_editor_theme_icon ( SNAME ( " Remove " ) ) , BUTTON_REMOVE_VAR , false , TTR ( " Remove Variation " ) ) ;
2020-12-27 14:30:33 +01:00
vars_item - > set_button_color ( 1 , 0 , Color ( 1 , 1 , 1 , 0.75 ) ) ;
Ref < DynamicFontImportSettingsData > import_variation_data_custom ;
import_variation_data_custom . instantiate ( ) ;
ERR_FAIL_NULL ( import_variation_data_custom ) ;
2022-05-09 11:47:10 +02:00
import_variation_data_custom - > owner = this ;
2020-12-27 14:30:33 +01:00
for ( List < ResourceImporter : : ImportOption > : : Element * F = options_variations . front ( ) ; F ; F = F - > next ( ) ) {
import_variation_data_custom - > defaults [ F - > get ( ) . option . name ] = F - > get ( ) . default_value ;
}
2022-05-09 11:47:10 +02:00
import_variation_data_custom - > fd = font_main ;
2020-12-27 14:30:33 +01:00
2022-05-09 11:47:10 +02:00
import_variation_data_custom - > options = options_variations ;
2020-12-27 14:30:33 +01:00
vars_item - > set_metadata ( 0 , import_variation_data_custom ) ;
2022-05-09 11:47:10 +02:00
2022-09-29 11:53:28 +02:00
import_variation_data_custom - > set ( " size " , font_size . x ) ;
import_variation_data_custom - > set ( " outline_size " , font_size . y ) ;
2022-05-09 11:47:10 +02:00
import_variation_data_custom - > set ( " variation_opentype " , variation ) ;
import_variation_data_custom - > set ( " variation_embolden " , embolden ) ;
import_variation_data_custom - > set ( " variation_face_index " , face_index ) ;
import_variation_data_custom - > set ( " variation_transform " , transform ) ;
Array chars = preload_config [ " chars " ] ;
for ( int j = 0 ; j < chars . size ( ) ; j + + ) {
char32_t c = chars [ j ] . operator int ( ) ;
import_variation_data_custom - > selected_chars . insert ( c ) ;
2020-12-27 14:30:33 +01:00
}
2022-05-09 11:47:10 +02:00
Array glyphs = preload_config [ " glyphs " ] ;
for ( int j = 0 ; j < glyphs . size ( ) ; j + + ) {
int32_t c = glyphs [ j ] ;
import_variation_data_custom - > selected_glyphs . insert ( c ) ;
2021-11-18 22:36:22 +01:00
}
}
2022-11-09 13:45:21 +01:00
if ( preload_configurations . is_empty ( ) ) {
_variation_add ( ) ; // Add default variation.
}
vars_list - > set_selected ( vars_list_root - > get_child ( 0 ) ) ;
2020-12-27 14:30:33 +01:00
} else {
Variant value = config - > get_value ( " params " , key ) ;
import_settings_data - > defaults [ key ] = value ;
}
}
}
2022-05-09 11:47:10 +02:00
import_settings_data - > fd = font_main ;
2020-12-27 14:30:33 +01:00
import_settings_data - > options = options_general ;
inspector_general - > edit ( import_settings_data . ptr ( ) ) ;
import_settings_data - > notify_property_list_changed ( ) ;
2022-05-09 11:47:10 +02:00
if ( font_preview . is_valid ( ) ) {
2022-08-12 13:03:28 +02:00
font_preview - > set_antialiasing ( ( TextServer : : FontAntialiasing ) import_settings_data - > get ( " antialiasing " ) . operator int ( ) ) ;
2022-05-09 11:47:10 +02:00
font_preview - > set_multichannel_signed_distance_field ( import_settings_data - > get ( " multichannel_signed_distance_field " ) ) ;
font_preview - > set_msdf_pixel_range ( import_settings_data - > get ( " msdf_pixel_range " ) ) ;
font_preview - > set_msdf_size ( import_settings_data - > get ( " msdf_size " ) ) ;
2022-11-21 14:04:01 +01:00
font_preview - > set_allow_system_fallback ( import_settings_data - > get ( " allow_system_fallback " ) ) ;
2022-05-09 11:47:10 +02:00
font_preview - > set_force_autohinter ( import_settings_data - > get ( " force_autohinter " ) ) ;
font_preview - > set_hinting ( ( TextServer : : Hinting ) import_settings_data - > get ( " hinting " ) . operator int ( ) ) ;
font_preview - > set_subpixel_positioning ( ( TextServer : : SubpixelPositioning ) import_settings_data - > get ( " subpixel_positioning " ) . operator int ( ) ) ;
font_preview - > set_oversampling ( import_settings_data - > get ( " oversampling " ) ) ;
2020-12-27 14:30:33 +01:00
}
2024-05-14 15:57:29 +02:00
font_preview_label - > add_theme_font_override ( SceneStringName ( font ) , font_preview ) ;
font_preview_label - > add_theme_font_size_override ( SceneStringName ( font_size ) , 200 * EDSCALE ) ;
2022-08-13 23:21:24 +02:00
font_preview_label - > queue_redraw ( ) ;
2020-12-27 14:30:33 +01:00
_variations_validate ( ) ;
popup_centered_ratio ( ) ;
set_title ( vformat ( TTR ( " Advanced Import Settings for '%s' " ) , base_path . get_file ( ) ) ) ;
}
2023-10-06 09:00:36 +02:00
DynamicFontImportSettingsDialog * DynamicFontImportSettingsDialog : : get_singleton ( ) {
2020-12-27 14:30:33 +01:00
return singleton ;
}
2023-10-06 09:00:36 +02:00
DynamicFontImportSettingsDialog : : DynamicFontImportSettingsDialog ( ) {
2020-12-27 14:30:33 +01:00
singleton = this ;
2022-05-09 11:47:10 +02:00
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : NIL , " Rendering " , PROPERTY_HINT_NONE , " " , PROPERTY_USAGE_GROUP ) , Variant ( ) ) ) ;
2022-11-03 18:37:21 +01:00
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : INT , " antialiasing " , PROPERTY_HINT_ENUM , " None,Grayscale,LCD Subpixel " ) , 1 ) ) ;
2022-04-19 12:27:18 +02:00
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : BOOL , " generate_mipmaps " ) , false ) ) ;
2024-03-11 12:42:16 +01:00
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : BOOL , " disable_embedded_bitmaps " ) , true ) ) ;
2020-12-27 14:30:33 +01:00
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : BOOL , " multichannel_signed_distance_field " , PROPERTY_HINT_NONE , " " , PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED ) , true ) ) ;
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : INT , " msdf_pixel_range " , PROPERTY_HINT_RANGE , " 1,100,1 " ) , 8 ) ) ;
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : INT , " msdf_size " , PROPERTY_HINT_RANGE , " 1,250,1 " ) , 48 ) ) ;
2022-11-21 14:04:01 +01:00
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : BOOL , " allow_system_fallback " ) , true ) ) ;
2020-12-27 14:30:33 +01:00
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : BOOL , " force_autohinter " ) , false ) ) ;
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : INT , " hinting " , PROPERTY_HINT_ENUM , " None,Light,Normal " ) , 1 ) ) ;
2022-11-03 18:37:21 +01:00
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : INT , " subpixel_positioning " , PROPERTY_HINT_ENUM , " Disabled,Auto,One Half of a Pixel,One Quarter of a Pixel " ) , 1 ) ) ;
2020-12-27 14:30:33 +01:00
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : FLOAT , " oversampling " , PROPERTY_HINT_RANGE , " 0,10,0.1 " ) , 0.0 ) ) ;
2022-05-09 11:47:10 +02:00
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : NIL , " Metadata Overrides " , PROPERTY_HINT_NONE , " " , PROPERTY_USAGE_GROUP ) , Variant ( ) ) ) ;
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : DICTIONARY , " language_support " ) , Dictionary ( ) ) ) ;
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : DICTIONARY , " script_support " ) , Dictionary ( ) ) ) ;
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : DICTIONARY , " opentype_features " ) , Dictionary ( ) ) ) ;
2020-12-27 14:30:33 +01:00
2022-05-09 11:47:10 +02:00
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : NIL , " Fallbacks " , PROPERTY_HINT_NONE , " " , PROPERTY_USAGE_GROUP ) , Variant ( ) ) ) ;
2022-11-22 16:10:41 +01:00
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : ARRAY , " fallbacks " , PROPERTY_HINT_ARRAY_TYPE , MAKE_RESOURCE_TYPE_HINT ( " Font " ) ) , Array ( ) ) ) ;
2021-11-18 22:36:22 +01:00
2022-05-09 11:47:10 +02:00
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : NIL , " Compress " , PROPERTY_HINT_NONE , " " , PROPERTY_USAGE_GROUP ) , Variant ( ) ) ) ;
options_general . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : BOOL , " compress " , PROPERTY_HINT_NONE , " " ) , false ) ) ;
2021-11-18 22:36:22 +01:00
2022-05-09 11:47:10 +02:00
options_text . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : DICTIONARY , " opentype_features " ) , Dictionary ( ) ) ) ;
options_text . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : STRING , " language " , PROPERTY_HINT_LOCALE_ID , " " ) , " " ) ) ;
2021-11-18 22:36:22 +01:00
2022-05-09 11:47:10 +02:00
options_variations . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : INT , " size " , PROPERTY_HINT_RANGE , " 0,127,1 " ) , 16 ) ) ;
options_variations . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : INT , " outline_size " , PROPERTY_HINT_RANGE , " 0,127,1 " ) , 0 ) ) ;
options_variations . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : NIL , " Variation " , PROPERTY_HINT_NONE , " variation " , PROPERTY_USAGE_GROUP ) , Variant ( ) ) ) ;
options_variations . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : DICTIONARY , " variation_opentype " ) , Dictionary ( ) ) ) ;
options_variations . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : FLOAT , " variation_embolden " , PROPERTY_HINT_RANGE , " -2,2,0.01 " ) , 0 ) ) ;
options_variations . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : INT , " variation_face_index " ) , 0 ) ) ;
options_variations . push_back ( ResourceImporter : : ImportOption ( PropertyInfo ( Variant : : TRANSFORM2D , " variation_transform " ) , Transform2D ( ) ) ) ;
2021-11-18 22:36:22 +01:00
2020-12-27 14:30:33 +01:00
// Root layout
VBoxContainer * root_vb = memnew ( VBoxContainer ) ;
add_child ( root_vb ) ;
main_pages = memnew ( TabContainer ) ;
2022-03-07 15:32:49 +01:00
main_pages - > set_tab_alignment ( TabBar : : ALIGNMENT_CENTER ) ;
2020-12-27 14:30:33 +01:00
main_pages - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
main_pages - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2022-05-27 04:12:09 +02:00
main_pages - > set_theme_type_variation ( " TabContainerOdd " ) ;
2020-12-27 14:30:33 +01:00
root_vb - > add_child ( main_pages ) ;
label_warn = memnew ( Label ) ;
2021-11-25 03:58:47 +01:00
label_warn - > set_horizontal_alignment ( HORIZONTAL_ALIGNMENT_CENTER ) ;
2020-12-27 14:30:33 +01:00
label_warn - > set_text ( " " ) ;
root_vb - > add_child ( label_warn ) ;
label_warn - > hide ( ) ;
// Page 1 layout: Rendering Options
VBoxContainer * page1_vb = memnew ( VBoxContainer ) ;
2022-03-18 04:45:33 +01:00
page1_vb - > set_name ( TTR ( " Rendering Options " ) ) ;
2020-12-27 14:30:33 +01:00
main_pages - > add_child ( page1_vb ) ;
page1_description = memnew ( Label ) ;
2022-05-09 11:47:10 +02:00
page1_description - > set_text ( TTR ( " Select font rendering options, fallback font, and metadata override: " ) ) ;
2020-12-27 14:30:33 +01:00
page1_description - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
page1_vb - > add_child ( page1_description ) ;
HSplitContainer * page1_hb = memnew ( HSplitContainer ) ;
page1_hb - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
page1_hb - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
page1_vb - > add_child ( page1_hb ) ;
2022-05-09 11:47:10 +02:00
VBoxContainer * page1_lbl_vb = memnew ( VBoxContainer ) ;
page1_lbl_vb - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
page1_lbl_vb - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
page1_hb - > add_child ( page1_lbl_vb ) ;
font_name_label = memnew ( Label ) ;
font_name_label - > set_horizontal_alignment ( HORIZONTAL_ALIGNMENT_CENTER ) ;
font_name_label - > set_clip_text ( true ) ;
font_name_label - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
page1_lbl_vb - > add_child ( font_name_label ) ;
2020-12-27 14:30:33 +01:00
font_preview_label = memnew ( Label ) ;
2021-11-25 03:58:47 +01:00
font_preview_label - > set_horizontal_alignment ( HORIZONTAL_ALIGNMENT_CENTER ) ;
font_preview_label - > set_vertical_alignment ( VERTICAL_ALIGNMENT_CENTER ) ;
2022-06-15 10:01:45 +02:00
font_preview_label - > set_autowrap_mode ( TextServer : : AUTOWRAP_ARBITRARY ) ;
2020-12-27 14:30:33 +01:00
font_preview_label - > set_clip_text ( true ) ;
font_preview_label - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
font_preview_label - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2022-05-09 11:47:10 +02:00
page1_lbl_vb - > add_child ( font_preview_label ) ;
2020-12-27 14:30:33 +01:00
inspector_general = memnew ( EditorInspector ) ;
inspector_general - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
inspector_general - > set_custom_minimum_size ( Size2 ( 300 * EDSCALE , 250 * EDSCALE ) ) ;
page1_hb - > add_child ( inspector_general ) ;
2023-10-06 09:00:36 +02:00
inspector_general - > connect ( " property_edited " , callable_mp ( this , & DynamicFontImportSettingsDialog : : _main_prop_changed ) ) ;
2020-12-27 14:30:33 +01:00
// Page 2 layout: Configurations
VBoxContainer * page2_vb = memnew ( VBoxContainer ) ;
2022-11-03 19:15:12 +01:00
page2_vb - > set_name ( TTR ( " Pre-render Configurations " ) ) ;
2020-12-27 14:30:33 +01:00
main_pages - > add_child ( page2_vb ) ;
page2_description = memnew ( Label ) ;
2022-05-09 11:47:10 +02:00
page2_description - > set_text ( TTR ( " Add font size, and variation coordinates, and select glyphs to pre-render: " ) ) ;
2020-12-27 14:30:33 +01:00
page2_description - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2022-06-15 10:01:45 +02:00
page2_description - > set_autowrap_mode ( TextServer : : AUTOWRAP_WORD_SMART ) ;
2023-12-14 03:41:22 +01:00
page2_description - > set_custom_minimum_size ( Size2 ( 300 * EDSCALE , 1 ) ) ;
2020-12-27 14:30:33 +01:00
page2_vb - > add_child ( page2_description ) ;
HSplitContainer * page2_hb = memnew ( HSplitContainer ) ;
page2_hb - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
page2_hb - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
page2_vb - > add_child ( page2_hb ) ;
VBoxContainer * page2_side_vb = memnew ( VBoxContainer ) ;
page2_hb - > add_child ( page2_side_vb ) ;
HBoxContainer * page2_hb_vars = memnew ( HBoxContainer ) ;
page2_side_vb - > add_child ( page2_hb_vars ) ;
label_vars = memnew ( Label ) ;
2021-11-25 03:58:47 +01:00
label_vars - > set_horizontal_alignment ( HORIZONTAL_ALIGNMENT_CENTER ) ;
2020-12-27 14:30:33 +01:00
label_vars - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
label_vars - > set_text ( TTR ( " Configuration: " ) ) ;
2023-10-19 18:05:19 +02:00
page2_hb_vars - > add_child ( label_vars ) ;
2020-12-27 14:30:33 +01:00
add_var = memnew ( Button ) ;
2022-08-25 12:42:17 +02:00
add_var - > set_tooltip_text ( TTR ( " Add configuration " ) ) ;
2023-10-19 18:05:19 +02:00
page2_hb_vars - > add_child ( add_var ) ;
2024-05-14 09:40:21 +02:00
add_var - > connect ( SceneStringName ( pressed ) , callable_mp ( this , & DynamicFontImportSettingsDialog : : _variation_add ) ) ;
2020-12-27 14:30:33 +01:00
vars_list = memnew ( Tree ) ;
2024-03-17 09:28:18 +01:00
vars_list - > set_auto_translate_mode ( AUTO_TRANSLATE_MODE_DISABLED ) ;
2020-12-27 14:30:33 +01:00
vars_list - > set_custom_minimum_size ( Size2 ( 300 * EDSCALE , 0 ) ) ;
vars_list - > set_hide_root ( true ) ;
vars_list - > set_columns ( 2 ) ;
vars_list - > set_column_expand ( 0 , true ) ;
vars_list - > set_column_custom_minimum_width ( 0 , 80 * EDSCALE ) ;
vars_list - > set_column_expand ( 1 , false ) ;
vars_list - > set_column_custom_minimum_width ( 1 , 50 * EDSCALE ) ;
2023-10-19 18:05:19 +02:00
vars_list - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
page2_side_vb - > add_child ( vars_list ) ;
2024-05-14 14:21:31 +02:00
vars_list - > connect ( SceneStringName ( item_selected ) , callable_mp ( this , & DynamicFontImportSettingsDialog : : _variation_selected ) ) ;
2023-10-06 09:00:36 +02:00
vars_list - > connect ( " button_clicked " , callable_mp ( this , & DynamicFontImportSettingsDialog : : _variation_remove ) ) ;
2020-12-27 14:30:33 +01:00
inspector_vars = memnew ( EditorInspector ) ;
inspector_vars - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2022-05-09 11:47:10 +02:00
page2_side_vb - > add_child ( inspector_vars ) ;
2023-10-06 09:00:36 +02:00
inspector_vars - > connect ( " property_edited " , callable_mp ( this , & DynamicFontImportSettingsDialog : : _variation_changed ) ) ;
2020-12-27 14:30:33 +01:00
2022-11-09 13:45:21 +01:00
VBoxContainer * preload_pages_vb = memnew ( VBoxContainer ) ;
page2_hb - > add_child ( preload_pages_vb ) ;
2022-05-09 11:47:10 +02:00
preload_pages = memnew ( TabContainer ) ;
preload_pages - > set_tab_alignment ( TabBar : : ALIGNMENT_CENTER ) ;
preload_pages - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
preload_pages - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2022-11-09 13:45:21 +01:00
preload_pages_vb - > add_child ( preload_pages ) ;
HBoxContainer * gl_hb = memnew ( HBoxContainer ) ;
gl_hb - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2023-10-19 18:05:19 +02:00
preload_pages_vb - > add_child ( gl_hb ) ;
2022-11-09 13:45:21 +01:00
label_glyphs = memnew ( Label ) ;
2023-02-09 10:01:32 +01:00
label_glyphs - > set_text ( vformat ( TTR ( " Preloaded glyphs: %d " ) , 0 ) ) ;
2022-11-09 13:45:21 +01:00
label_glyphs - > set_custom_minimum_size ( Size2 ( 50 * EDSCALE , 0 ) ) ;
2023-10-19 18:05:19 +02:00
gl_hb - > add_child ( label_glyphs ) ;
2022-11-09 13:45:21 +01:00
Button * btn_clear = memnew ( Button ) ;
btn_clear - > set_text ( TTR ( " Clear Glyph List " ) ) ;
2023-10-19 18:05:19 +02:00
gl_hb - > add_child ( btn_clear ) ;
2024-05-14 09:40:21 +02:00
btn_clear - > connect ( SceneStringName ( pressed ) , callable_mp ( this , & DynamicFontImportSettingsDialog : : _glyph_clear ) ) ;
2022-11-09 13:45:21 +01:00
VBoxContainer * page2_0_vb = memnew ( VBoxContainer ) ;
page2_0_vb - > set_name ( TTR ( " Glyphs from the Translations " ) ) ;
preload_pages - > add_child ( page2_0_vb ) ;
page2_0_description = memnew ( Label ) ;
page2_0_description - > set_text ( TTR ( " Select translations to add all required glyphs to pre-render list: " ) ) ;
page2_0_description - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
page2_0_description - > set_autowrap_mode ( TextServer : : AUTOWRAP_WORD_SMART ) ;
2023-12-14 03:41:22 +01:00
page2_0_description - > set_custom_minimum_size ( Size2 ( 300 * EDSCALE , 1 ) ) ;
2022-11-09 13:45:21 +01:00
page2_0_vb - > add_child ( page2_0_description ) ;
locale_tree = memnew ( Tree ) ;
2024-03-17 09:28:18 +01:00
locale_tree - > set_auto_translate_mode ( AUTO_TRANSLATE_MODE_DISABLED ) ;
2022-11-09 13:45:21 +01:00
locale_tree - > set_columns ( 1 ) ;
locale_tree - > set_hide_root ( true ) ;
locale_tree - > set_column_expand ( 0 , true ) ;
locale_tree - > set_column_custom_minimum_width ( 0 , 120 * EDSCALE ) ;
locale_tree - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2023-10-19 18:05:19 +02:00
page2_0_vb - > add_child ( locale_tree ) ;
2023-10-06 09:00:36 +02:00
locale_tree - > connect ( " item_activated " , callable_mp ( this , & DynamicFontImportSettingsDialog : : _locale_edited ) ) ;
2023-10-19 18:05:19 +02:00
2022-11-09 13:45:21 +01:00
locale_root = locale_tree - > create_item ( ) ;
HBoxContainer * locale_hb = memnew ( HBoxContainer ) ;
locale_hb - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2023-10-19 18:05:19 +02:00
page2_0_vb - > add_child ( locale_hb ) ;
2022-11-09 13:45:21 +01:00
btn_fill_locales = memnew ( Button ) ;
btn_fill_locales - > set_text ( TTR ( " Shape all Strings in the Translations and Add Glyphs " ) ) ;
2023-10-19 18:05:19 +02:00
locale_hb - > add_child ( btn_fill_locales ) ;
2024-05-14 09:40:21 +02:00
btn_fill_locales - > connect ( SceneStringName ( pressed ) , callable_mp ( this , & DynamicFontImportSettingsDialog : : _process_locales ) ) ;
2020-12-27 14:30:33 +01:00
2022-05-09 11:47:10 +02:00
// Page 2.1 layout: Text to select glyphs
VBoxContainer * page2_1_vb = memnew ( VBoxContainer ) ;
page2_1_vb - > set_name ( TTR ( " Glyphs from the Text " ) ) ;
preload_pages - > add_child ( page2_1_vb ) ;
2020-12-27 14:30:33 +01:00
2022-05-09 11:47:10 +02:00
page2_1_description = memnew ( Label ) ;
2022-11-09 13:45:21 +01:00
page2_1_description - > set_text ( TTR ( " Enter a text and select OpenType features to shape and add all required glyphs to pre-render list: " ) ) ;
2022-05-09 11:47:10 +02:00
page2_1_description - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
page2_1_description - > set_autowrap_mode ( TextServer : : AUTOWRAP_WORD_SMART ) ;
2023-12-14 03:41:22 +01:00
page2_1_description - > set_custom_minimum_size ( Size2 ( 300 * EDSCALE , 1 ) ) ;
2022-05-09 11:47:10 +02:00
page2_1_vb - > add_child ( page2_1_description ) ;
2020-12-27 14:30:33 +01:00
2022-05-09 11:47:10 +02:00
HSplitContainer * page2_1_hb = memnew ( HSplitContainer ) ;
page2_1_hb - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
page2_1_hb - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2023-10-19 18:05:19 +02:00
page2_1_vb - > add_child ( page2_1_hb ) ;
2020-12-27 14:30:33 +01:00
2022-05-09 11:47:10 +02:00
inspector_text = memnew ( EditorInspector ) ;
2020-12-27 14:30:33 +01:00
2022-05-09 11:47:10 +02:00
inspector_text - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
inspector_text - > set_custom_minimum_size ( Size2 ( 300 * EDSCALE , 250 * EDSCALE ) ) ;
page2_1_hb - > add_child ( inspector_text ) ;
2023-10-06 09:00:36 +02:00
inspector_text - > connect ( " property_edited " , callable_mp ( this , & DynamicFontImportSettingsDialog : : _change_text_opts ) ) ;
2020-12-27 14:30:33 +01:00
text_edit = memnew ( TextEdit ) ;
text_edit - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
text_edit - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2023-10-19 18:05:19 +02:00
page2_1_hb - > add_child ( text_edit ) ;
2020-12-27 14:30:33 +01:00
HBoxContainer * text_hb = memnew ( HBoxContainer ) ;
text_hb - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2023-10-19 18:05:19 +02:00
page2_1_vb - > add_child ( text_hb ) ;
2020-12-27 14:30:33 +01:00
2022-11-09 13:45:21 +01:00
btn_fill = memnew ( Button ) ;
2022-11-03 19:15:12 +01:00
btn_fill - > set_text ( TTR ( " Shape Text and Add Glyphs " ) ) ;
2023-10-19 18:05:19 +02:00
text_hb - > add_child ( btn_fill ) ;
2024-05-14 09:40:21 +02:00
btn_fill - > connect ( SceneStringName ( pressed ) , callable_mp ( this , & DynamicFontImportSettingsDialog : : _glyph_text_selected ) ) ;
2020-12-27 14:30:33 +01:00
2022-05-09 11:47:10 +02:00
// Page 2.2 layout: Character map
VBoxContainer * page2_2_vb = memnew ( VBoxContainer ) ;
page2_2_vb - > set_name ( TTR ( " Glyphs from the Character Map " ) ) ;
preload_pages - > add_child ( page2_2_vb ) ;
2020-12-27 14:30:33 +01:00
2022-05-09 11:47:10 +02:00
page2_2_description = memnew ( Label ) ;
page2_2_description - > set_text ( TTR ( " Add or remove glyphs from the character map to pre-render list: \n Note: Some stylistic alternatives and glyph variants do not have one-to-one correspondence to character, and not shown in this map, use \" Glyphs from the text \" tab to add these. " ) ) ;
page2_2_description - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
page2_2_description - > set_autowrap_mode ( TextServer : : AUTOWRAP_WORD_SMART ) ;
2023-12-14 03:41:22 +01:00
page2_2_description - > set_custom_minimum_size ( Size2 ( 300 * EDSCALE , 1 ) ) ;
2022-05-09 11:47:10 +02:00
page2_2_vb - > add_child ( page2_2_description ) ;
2020-12-27 14:30:33 +01:00
HSplitContainer * glyphs_split = memnew ( HSplitContainer ) ;
glyphs_split - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
glyphs_split - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2022-05-09 11:47:10 +02:00
page2_2_vb - > add_child ( glyphs_split ) ;
2020-12-27 14:30:33 +01:00
glyph_table = memnew ( Tree ) ;
2024-03-17 09:28:18 +01:00
glyph_table - > set_auto_translate_mode ( AUTO_TRANSLATE_MODE_DISABLED ) ;
2020-12-27 14:30:33 +01:00
glyph_table - > set_custom_minimum_size ( Size2 ( ( 30 * 16 + 100 ) * EDSCALE , 0 ) ) ;
glyph_table - > set_columns ( 17 ) ;
glyph_table - > set_column_expand ( 0 , false ) ;
glyph_table - > set_hide_root ( true ) ;
glyph_table - > set_allow_reselect ( true ) ;
glyph_table - > set_select_mode ( Tree : : SELECT_SINGLE ) ;
glyph_table - > set_column_titles_visible ( true ) ;
for ( int i = 0 ; i < 16 ; i + + ) {
glyph_table - > set_column_title ( i + 1 , String : : num_int64 ( i , 16 ) ) ;
}
2024-05-14 15:50:53 +02:00
glyph_table - > add_theme_style_override ( " selected " , glyph_table - > get_theme_stylebox ( SceneStringName ( panel ) ) ) ;
glyph_table - > add_theme_style_override ( " selected_focus " , glyph_table - > get_theme_stylebox ( SceneStringName ( panel ) ) ) ;
2022-04-14 23:20:28 +02:00
glyph_table - > add_theme_constant_override ( " h_separation " , 0 ) ;
2020-12-27 14:30:33 +01:00
glyph_table - > set_h_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
glyph_table - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
2023-10-19 18:05:19 +02:00
glyphs_split - > add_child ( glyph_table ) ;
2023-10-06 09:00:36 +02:00
glyph_table - > connect ( " item_activated " , callable_mp ( this , & DynamicFontImportSettingsDialog : : _glyph_selected ) ) ;
2020-12-27 14:30:33 +01:00
glyph_tree = memnew ( Tree ) ;
2024-03-17 09:28:18 +01:00
glyph_tree - > set_auto_translate_mode ( AUTO_TRANSLATE_MODE_DISABLED ) ;
2020-12-27 14:30:33 +01:00
glyph_tree - > set_custom_minimum_size ( Size2 ( 300 * EDSCALE , 0 ) ) ;
2021-09-22 15:55:39 +02:00
glyph_tree - > set_columns ( 2 ) ;
2020-12-27 14:30:33 +01:00
glyph_tree - > set_hide_root ( true ) ;
glyph_tree - > set_column_expand ( 0 , false ) ;
glyph_tree - > set_column_expand ( 1 , true ) ;
glyph_tree - > set_column_custom_minimum_width ( 0 , 120 * EDSCALE ) ;
glyph_tree - > set_v_size_flags ( Control : : SIZE_EXPAND_FILL ) ;
glyph_root = glyph_tree - > create_item ( ) ;
2021-12-09 10:42:46 +01:00
for ( int i = 0 ; ! unicode_ranges [ i ] . name . is_empty ( ) ; i + + ) {
2020-12-27 14:30:33 +01:00
_add_glyph_range_item ( unicode_ranges [ i ] . start , unicode_ranges [ i ] . end , unicode_ranges [ i ] . name ) ;
}
2023-10-19 18:05:19 +02:00
glyphs_split - > add_child ( glyph_tree ) ;
2023-10-06 09:00:36 +02:00
glyph_tree - > connect ( " item_activated " , callable_mp ( this , & DynamicFontImportSettingsDialog : : _range_edited ) ) ;
2024-05-14 14:21:31 +02:00
glyph_tree - > connect ( SceneStringName ( item_selected ) , callable_mp ( this , & DynamicFontImportSettingsDialog : : _range_selected ) ) ;
2020-12-27 14:30:33 +01:00
// Common
import_settings_data . instantiate ( ) ;
import_settings_data - > owner = this ;
2022-07-08 02:31:19 +02:00
set_ok_button_text ( TTR ( " Reimport " ) ) ;
set_cancel_button_text ( TTR ( " Close " ) ) ;
2020-12-27 14:30:33 +01:00
}