| 1 | /**************************************************************************/ |
| 2 | /* dynamic_font_import_settings.cpp */ |
| 3 | /**************************************************************************/ |
| 4 | /* This file is part of: */ |
| 5 | /* GODOT ENGINE */ |
| 6 | /* https://godotengine.org */ |
| 7 | /**************************************************************************/ |
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 10 | /* */ |
| 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
| 12 | /* a copy of this software and associated documentation files (the */ |
| 13 | /* "Software"), to deal in the Software without restriction, including */ |
| 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
| 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
| 16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
| 17 | /* the following conditions: */ |
| 18 | /* */ |
| 19 | /* The above copyright notice and this permission notice shall be */ |
| 20 | /* included in all copies or substantial portions of the Software. */ |
| 21 | /* */ |
| 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
| 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
| 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
| 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
| 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
| 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
| 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 29 | /**************************************************************************/ |
| 30 | |
| 31 | #include "dynamic_font_import_settings.h" |
| 32 | |
| 33 | #include "core/config/project_settings.h" |
| 34 | #include "editor/editor_file_system.h" |
| 35 | #include "editor/editor_inspector.h" |
| 36 | #include "editor/editor_locale_dialog.h" |
| 37 | #include "editor/editor_node.h" |
| 38 | #include "editor/editor_property_name_processor.h" |
| 39 | #include "editor/editor_scale.h" |
| 40 | #include "editor/editor_settings.h" |
| 41 | #include "editor/editor_string_names.h" |
| 42 | #include "editor/gui/editor_file_dialog.h" |
| 43 | |
| 44 | /*************************************************************************/ |
| 45 | /* Settings data */ |
| 46 | /*************************************************************************/ |
| 47 | |
| 48 | bool DynamicFontImportSettingsData::_set(const StringName &p_name, const Variant &p_value) { |
| 49 | if (defaults.has(p_name) && defaults[p_name] == p_value) { |
| 50 | settings.erase(p_name); |
| 51 | } else { |
| 52 | settings[p_name] = p_value; |
| 53 | } |
| 54 | return true; |
| 55 | } |
| 56 | |
| 57 | bool DynamicFontImportSettingsData::_get(const StringName &p_name, Variant &r_ret) const { |
| 58 | if (settings.has(p_name)) { |
| 59 | r_ret = settings[p_name]; |
| 60 | return true; |
| 61 | } |
| 62 | if (defaults.has(p_name)) { |
| 63 | r_ret = defaults[p_name]; |
| 64 | return true; |
| 65 | } |
| 66 | return false; |
| 67 | } |
| 68 | |
| 69 | void DynamicFontImportSettingsData::_get_property_list(List<PropertyInfo> *p_list) const { |
| 70 | for (const List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { |
| 71 | if (owner && owner->import_settings_data.is_valid()) { |
| 72 | 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" )) { |
| 73 | continue; |
| 74 | } |
| 75 | if (!owner->import_settings_data->get("multichannel_signed_distance_field" ) && (E->get().option.name == "msdf_pixel_range" || E->get().option.name == "msdf_size" )) { |
| 76 | continue; |
| 77 | } |
| 78 | } |
| 79 | p_list->push_back(E->get().option); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | Ref<FontFile> DynamicFontImportSettingsData::get_font() const { |
| 84 | return fd; |
| 85 | } |
| 86 | |
| 87 | /*************************************************************************/ |
| 88 | /* Glyph ranges */ |
| 89 | /*************************************************************************/ |
| 90 | |
| 91 | struct UniRange { |
| 92 | int32_t start; |
| 93 | int32_t end; |
| 94 | String name; |
| 95 | }; |
| 96 | |
| 97 | // Unicode Character Blocks |
| 98 | // Source: https://www.unicode.org/Public/14.0.0/ucd/Blocks.txt |
| 99 | static UniRange unicode_ranges[] = { |
| 100 | { 0x0000, 0x007F, U"Basic Latin" }, |
| 101 | { 0x0080, 0x00FF, U"Latin-1 Supplement" }, |
| 102 | { 0x0100, 0x017F, U"Latin Extended-A" }, |
| 103 | { 0x0180, 0x024F, U"Latin Extended-B" }, |
| 104 | { 0x0250, 0x02AF, U"IPA Extensions" }, |
| 105 | { 0x02B0, 0x02FF, U"Spacing Modifier Letters" }, |
| 106 | { 0x0300, 0x036F, U"Combining Diacritical Marks" }, |
| 107 | { 0x0370, 0x03FF, U"Greek and Coptic" }, |
| 108 | { 0x0400, 0x04FF, U"Cyrillic" }, |
| 109 | { 0x0500, 0x052F, U"Cyrillic Supplement" }, |
| 110 | { 0x0530, 0x058F, U"Armenian" }, |
| 111 | { 0x0590, 0x05FF, U"Hebrew" }, |
| 112 | { 0x0600, 0x06FF, U"Arabic" }, |
| 113 | { 0x0700, 0x074F, U"Syriac" }, |
| 114 | { 0x0750, 0x077F, U"Arabic Supplement" }, |
| 115 | { 0x0780, 0x07BF, U"Thaana" }, |
| 116 | { 0x07C0, 0x07FF, U"NKo" }, |
| 117 | { 0x0800, 0x083F, U"Samaritan" }, |
| 118 | { 0x0840, 0x085F, U"Mandaic" }, |
| 119 | { 0x0860, 0x086F, U"Syriac Supplement" }, |
| 120 | { 0x0870, 0x089F, U"Arabic Extended-B" }, |
| 121 | { 0x08A0, 0x08FF, U"Arabic Extended-A" }, |
| 122 | { 0x0900, 0x097F, U"Devanagari" }, |
| 123 | { 0x0980, 0x09FF, U"Bengali" }, |
| 124 | { 0x0A00, 0x0A7F, U"Gurmukhi" }, |
| 125 | { 0x0A80, 0x0AFF, U"Gujarati" }, |
| 126 | { 0x0B00, 0x0B7F, U"Oriya" }, |
| 127 | { 0x0B80, 0x0BFF, U"Tamil" }, |
| 128 | { 0x0C00, 0x0C7F, U"Telugu" }, |
| 129 | { 0x0C80, 0x0CFF, U"Kannada" }, |
| 130 | { 0x0D00, 0x0D7F, U"Malayalam" }, |
| 131 | { 0x0D80, 0x0DFF, U"Sinhala" }, |
| 132 | { 0x0E00, 0x0E7F, U"Thai" }, |
| 133 | { 0x0E80, 0x0EFF, U"Lao" }, |
| 134 | { 0x0F00, 0x0FFF, U"Tibetan" }, |
| 135 | { 0x1000, 0x109F, U"Myanmar" }, |
| 136 | { 0x10A0, 0x10FF, U"Georgian" }, |
| 137 | { 0x1100, 0x11FF, U"Hangul Jamo" }, |
| 138 | { 0x1200, 0x137F, U"Ethiopic" }, |
| 139 | { 0x1380, 0x139F, U"Ethiopic Supplement" }, |
| 140 | { 0x13A0, 0x13FF, U"Cherokee" }, |
| 141 | { 0x1400, 0x167F, U"Unified Canadian Aboriginal Syllabics" }, |
| 142 | { 0x1680, 0x169F, U"Ogham" }, |
| 143 | { 0x16A0, 0x16FF, U"Runic" }, |
| 144 | { 0x1700, 0x171F, U"Tagalog" }, |
| 145 | { 0x1720, 0x173F, U"Hanunoo" }, |
| 146 | { 0x1740, 0x175F, U"Buhid" }, |
| 147 | { 0x1760, 0x177F, U"Tagbanwa" }, |
| 148 | { 0x1780, 0x17FF, U"Khmer" }, |
| 149 | { 0x1800, 0x18AF, U"Mongolian" }, |
| 150 | { 0x18B0, 0x18FF, U"Unified Canadian Aboriginal Syllabics Extended" }, |
| 151 | { 0x1900, 0x194F, U"Limbu" }, |
| 152 | { 0x1950, 0x197F, U"Tai Le" }, |
| 153 | { 0x1980, 0x19DF, U"New Tai Lue" }, |
| 154 | { 0x19E0, 0x19FF, U"Khmer Symbols" }, |
| 155 | { 0x1A00, 0x1A1F, U"Buginese" }, |
| 156 | { 0x1A20, 0x1AAF, U"Tai Tham" }, |
| 157 | { 0x1AB0, 0x1AFF, U"Combining Diacritical Marks Extended" }, |
| 158 | { 0x1B00, 0x1B7F, U"Balinese" }, |
| 159 | { 0x1B80, 0x1BBF, U"Sundanese" }, |
| 160 | { 0x1BC0, 0x1BFF, U"Batak" }, |
| 161 | { 0x1C00, 0x1C4F, U"Lepcha" }, |
| 162 | { 0x1C50, 0x1C7F, U"Ol Chiki" }, |
| 163 | { 0x1C80, 0x1C8F, U"Cyrillic Extended-C" }, |
| 164 | { 0x1C90, 0x1CBF, U"Georgian Extended" }, |
| 165 | { 0x1CC0, 0x1CCF, U"Sundanese Supplement" }, |
| 166 | { 0x1CD0, 0x1CFF, U"Vedic Extensions" }, |
| 167 | { 0x1D00, 0x1D7F, U"Phonetic Extensions" }, |
| 168 | { 0x1D80, 0x1DBF, U"Phonetic Extensions Supplement" }, |
| 169 | { 0x1DC0, 0x1DFF, U"Combining Diacritical Marks Supplement" }, |
| 170 | { 0x1E00, 0x1EFF, U"Latin Extended Additional" }, |
| 171 | { 0x1F00, 0x1FFF, U"Greek Extended" }, |
| 172 | { 0x2000, 0x206F, U"General Punctuation" }, |
| 173 | { 0x2070, 0x209F, U"Superscripts and Subscripts" }, |
| 174 | { 0x20A0, 0x20CF, U"Currency Symbols" }, |
| 175 | { 0x20D0, 0x20FF, U"Combining Diacritical Marks for Symbols" }, |
| 176 | { 0x2100, 0x214F, U"Letterlike Symbols" }, |
| 177 | { 0x2150, 0x218F, U"Number Forms" }, |
| 178 | { 0x2190, 0x21FF, U"Arrows" }, |
| 179 | { 0x2200, 0x22FF, U"Mathematical Operators" }, |
| 180 | { 0x2300, 0x23FF, U"Miscellaneous Technical" }, |
| 181 | { 0x2400, 0x243F, U"Control Pictures" }, |
| 182 | { 0x2440, 0x245F, U"Optical Character Recognition" }, |
| 183 | { 0x2460, 0x24FF, U"Enclosed Alphanumerics" }, |
| 184 | { 0x2500, 0x257F, U"Box Drawing" }, |
| 185 | { 0x2580, 0x259F, U"Block Elements" }, |
| 186 | { 0x25A0, 0x25FF, U"Geometric Shapes" }, |
| 187 | { 0x2600, 0x26FF, U"Miscellaneous Symbols" }, |
| 188 | { 0x2700, 0x27BF, U"Dingbats" }, |
| 189 | { 0x27C0, 0x27EF, U"Miscellaneous Mathematical Symbols-A" }, |
| 190 | { 0x27F0, 0x27FF, U"Supplemental Arrows-A" }, |
| 191 | { 0x2800, 0x28FF, U"Braille Patterns" }, |
| 192 | { 0x2900, 0x297F, U"Supplemental Arrows-B" }, |
| 193 | { 0x2980, 0x29FF, U"Miscellaneous Mathematical Symbols-B" }, |
| 194 | { 0x2A00, 0x2AFF, U"Supplemental Mathematical Operators" }, |
| 195 | { 0x2B00, 0x2BFF, U"Miscellaneous Symbols and Arrows" }, |
| 196 | { 0x2C00, 0x2C5F, U"Glagolitic" }, |
| 197 | { 0x2C60, 0x2C7F, U"Latin Extended-C" }, |
| 198 | { 0x2C80, 0x2CFF, U"Coptic" }, |
| 199 | { 0x2D00, 0x2D2F, U"Georgian Supplement" }, |
| 200 | { 0x2D30, 0x2D7F, U"Tifinagh" }, |
| 201 | { 0x2D80, 0x2DDF, U"Ethiopic Extended" }, |
| 202 | { 0x2DE0, 0x2DFF, U"Cyrillic Extended-A" }, |
| 203 | { 0x2E00, 0x2E7F, U"Supplemental Punctuation" }, |
| 204 | { 0x2E80, 0x2EFF, U"CJK Radicals Supplement" }, |
| 205 | { 0x2F00, 0x2FDF, U"Kangxi Radicals" }, |
| 206 | { 0x2FF0, 0x2FFF, U"Ideographic Description Characters" }, |
| 207 | { 0x3000, 0x303F, U"CJK Symbols and Punctuation" }, |
| 208 | { 0x3040, 0x309F, U"Hiragana" }, |
| 209 | { 0x30A0, 0x30FF, U"Katakana" }, |
| 210 | { 0x3100, 0x312F, U"Bopomofo" }, |
| 211 | { 0x3130, 0x318F, U"Hangul Compatibility Jamo" }, |
| 212 | { 0x3190, 0x319F, U"Kanbun" }, |
| 213 | { 0x31A0, 0x31BF, U"Bopomofo Extended" }, |
| 214 | { 0x31C0, 0x31EF, U"CJK Strokes" }, |
| 215 | { 0x31F0, 0x31FF, U"Katakana Phonetic Extensions" }, |
| 216 | { 0x3200, 0x32FF, U"Enclosed CJK Letters and Months" }, |
| 217 | { 0x3300, 0x33FF, U"CJK Compatibility" }, |
| 218 | { 0x3400, 0x4DBF, U"CJK Unified Ideographs Extension A" }, |
| 219 | { 0x4DC0, 0x4DFF, U"Yijing Hexagram Symbols" }, |
| 220 | { 0x4E00, 0x9FFF, U"CJK Unified Ideographs" }, |
| 221 | { 0xA000, 0xA48F, U"Yi Syllables" }, |
| 222 | { 0xA490, 0xA4CF, U"Yi Radicals" }, |
| 223 | { 0xA4D0, 0xA4FF, U"Lisu" }, |
| 224 | { 0xA500, 0xA63F, U"Vai" }, |
| 225 | { 0xA640, 0xA69F, U"Cyrillic Extended-B" }, |
| 226 | { 0xA6A0, 0xA6FF, U"Bamum" }, |
| 227 | { 0xA700, 0xA71F, U"Modifier Tone Letters" }, |
| 228 | { 0xA720, 0xA7FF, U"Latin Extended-D" }, |
| 229 | { 0xA800, 0xA82F, U"Syloti Nagri" }, |
| 230 | { 0xA830, 0xA83F, U"Common Indic Number Forms" }, |
| 231 | { 0xA840, 0xA87F, U"Phags-pa" }, |
| 232 | { 0xA880, 0xA8DF, U"Saurashtra" }, |
| 233 | { 0xA8E0, 0xA8FF, U"Devanagari Extended" }, |
| 234 | { 0xA900, 0xA92F, U"Kayah Li" }, |
| 235 | { 0xA930, 0xA95F, U"Rejang" }, |
| 236 | { 0xA960, 0xA97F, U"Hangul Jamo Extended-A" }, |
| 237 | { 0xA980, 0xA9DF, U"Javanese" }, |
| 238 | { 0xA9E0, 0xA9FF, U"Myanmar Extended-B" }, |
| 239 | { 0xAA00, 0xAA5F, U"Cham" }, |
| 240 | { 0xAA60, 0xAA7F, U"Myanmar Extended-A" }, |
| 241 | { 0xAA80, 0xAADF, U"Tai Viet" }, |
| 242 | { 0xAAE0, 0xAAFF, U"Meetei Mayek Extensions" }, |
| 243 | { 0xAB00, 0xAB2F, U"Ethiopic Extended-A" }, |
| 244 | { 0xAB30, 0xAB6F, U"Latin Extended-E" }, |
| 245 | { 0xAB70, 0xABBF, U"Cherokee Supplement" }, |
| 246 | { 0xABC0, 0xABFF, U"Meetei Mayek" }, |
| 247 | { 0xAC00, 0xD7AF, U"Hangul Syllables" }, |
| 248 | { 0xD7B0, 0xD7FF, U"Hangul Jamo Extended-B" }, |
| 249 | //{ 0xD800, 0xDB7F, U"High Surrogates" }, |
| 250 | //{ 0xDB80, 0xDBFF, U"High Private Use Surrogates" }, |
| 251 | //{ 0xDC00, 0xDFFF, U"Low Surrogates" }, |
| 252 | { 0xE000, 0xF8FF, U"Private Use Area" }, |
| 253 | { 0xF900, 0xFAFF, U"CJK Compatibility Ideographs" }, |
| 254 | { 0xFB00, 0xFB4F, U"Alphabetic Presentation Forms" }, |
| 255 | { 0xFB50, 0xFDFF, U"Arabic Presentation Forms-A" }, |
| 256 | //{ 0xFE00, 0xFE0F, U"Variation Selectors" }, |
| 257 | { 0xFE10, 0xFE1F, U"Vertical Forms" }, |
| 258 | { 0xFE20, 0xFE2F, U"Combining Half Marks" }, |
| 259 | { 0xFE30, 0xFE4F, U"CJK Compatibility Forms" }, |
| 260 | { 0xFE50, 0xFE6F, U"Small Form Variants" }, |
| 261 | { 0xFE70, 0xFEFF, U"Arabic Presentation Forms-B" }, |
| 262 | { 0xFF00, 0xFFEF, U"Halfwidth and Fullwidth Forms" }, |
| 263 | //{ 0xFFF0, 0xFFFF, U"Specials" }, |
| 264 | { 0x10000, 0x1007F, U"Linear B Syllabary" }, |
| 265 | { 0x10080, 0x100FF, U"Linear B Ideograms" }, |
| 266 | { 0x10100, 0x1013F, U"Aegean Numbers" }, |
| 267 | { 0x10140, 0x1018F, U"Ancient Greek Numbers" }, |
| 268 | { 0x10190, 0x101CF, U"Ancient Symbols" }, |
| 269 | { 0x101D0, 0x101FF, U"Phaistos Disc" }, |
| 270 | { 0x10280, 0x1029F, U"Lycian" }, |
| 271 | { 0x102A0, 0x102DF, U"Carian" }, |
| 272 | { 0x102E0, 0x102FF, U"Coptic Epact Numbers" }, |
| 273 | { 0x10300, 0x1032F, U"Old Italic" }, |
| 274 | { 0x10330, 0x1034F, U"Gothic" }, |
| 275 | { 0x10350, 0x1037F, U"Old Permic" }, |
| 276 | { 0x10380, 0x1039F, U"Ugaritic" }, |
| 277 | { 0x103A0, 0x103DF, U"Old Persian" }, |
| 278 | { 0x10400, 0x1044F, U"Deseret" }, |
| 279 | { 0x10450, 0x1047F, U"Shavian" }, |
| 280 | { 0x10480, 0x104AF, U"Osmanya" }, |
| 281 | { 0x104B0, 0x104FF, U"Osage" }, |
| 282 | { 0x10500, 0x1052F, U"Elbasan" }, |
| 283 | { 0x10530, 0x1056F, U"Caucasian Albanian" }, |
| 284 | { 0x10570, 0x105BF, U"Vithkuqi" }, |
| 285 | { 0x10600, 0x1077F, U"Linear A" }, |
| 286 | { 0x10780, 0x107BF, U"Latin Extended-F" }, |
| 287 | { 0x10800, 0x1083F, U"Cypriot Syllabary" }, |
| 288 | { 0x10840, 0x1085F, U"Imperial Aramaic" }, |
| 289 | { 0x10860, 0x1087F, U"Palmyrene" }, |
| 290 | { 0x10880, 0x108AF, U"Nabataean" }, |
| 291 | { 0x108E0, 0x108FF, U"Hatran" }, |
| 292 | { 0x10900, 0x1091F, U"Phoenician" }, |
| 293 | { 0x10920, 0x1093F, U"Lydian" }, |
| 294 | { 0x10980, 0x1099F, U"Meroitic Hieroglyphs" }, |
| 295 | { 0x109A0, 0x109FF, U"Meroitic Cursive" }, |
| 296 | { 0x10A00, 0x10A5F, U"Kharoshthi" }, |
| 297 | { 0x10A60, 0x10A7F, U"Old South Arabian" }, |
| 298 | { 0x10A80, 0x10A9F, U"Old North Arabian" }, |
| 299 | { 0x10AC0, 0x10AFF, U"Manichaean" }, |
| 300 | { 0x10B00, 0x10B3F, U"Avestan" }, |
| 301 | { 0x10B40, 0x10B5F, U"Inscriptional Parthian" }, |
| 302 | { 0x10B60, 0x10B7F, U"Inscriptional Pahlavi" }, |
| 303 | { 0x10B80, 0x10BAF, U"Psalter Pahlavi" }, |
| 304 | { 0x10C00, 0x10C4F, U"Old Turkic" }, |
| 305 | { 0x10C80, 0x10CFF, U"Old Hungarian" }, |
| 306 | { 0x10D00, 0x10D3F, U"Hanifi Rohingya" }, |
| 307 | { 0x10E60, 0x10E7F, U"Rumi Numeral Symbols" }, |
| 308 | { 0x10E80, 0x10EBF, U"Yezidi" }, |
| 309 | { 0x10EC0, 0x10EFF, U"Arabic Extended-C" }, |
| 310 | { 0x10F00, 0x10F2F, U"Old Sogdian" }, |
| 311 | { 0x10F30, 0x10F6F, U"Sogdian" }, |
| 312 | { 0x10F70, 0x10FAF, U"Old Uyghur" }, |
| 313 | { 0x10FB0, 0x10FDF, U"Chorasmian" }, |
| 314 | { 0x10FE0, 0x10FFF, U"Elymaic" }, |
| 315 | { 0x11000, 0x1107F, U"Brahmi" }, |
| 316 | { 0x11080, 0x110CF, U"Kaithi" }, |
| 317 | { 0x110D0, 0x110FF, U"Sora Sompeng" }, |
| 318 | { 0x11100, 0x1114F, U"Chakma" }, |
| 319 | { 0x11150, 0x1117F, U"Mahajani" }, |
| 320 | { 0x11180, 0x111DF, U"Sharada" }, |
| 321 | { 0x111E0, 0x111FF, U"Sinhala Archaic Numbers" }, |
| 322 | { 0x11200, 0x1124F, U"Khojki" }, |
| 323 | { 0x11280, 0x112AF, U"Multani" }, |
| 324 | { 0x112B0, 0x112FF, U"Khudawadi" }, |
| 325 | { 0x11300, 0x1137F, U"Grantha" }, |
| 326 | { 0x11400, 0x1147F, U"Newa" }, |
| 327 | { 0x11480, 0x114DF, U"Tirhuta" }, |
| 328 | { 0x11580, 0x115FF, U"Siddham" }, |
| 329 | { 0x11600, 0x1165F, U"Modi" }, |
| 330 | { 0x11660, 0x1167F, U"Mongolian Supplement" }, |
| 331 | { 0x11680, 0x116CF, U"Takri" }, |
| 332 | { 0x11700, 0x1174F, U"Ahom" }, |
| 333 | { 0x11800, 0x1184F, U"Dogra" }, |
| 334 | { 0x118A0, 0x118FF, U"Warang Citi" }, |
| 335 | { 0x11900, 0x1195F, U"Dives Akuru" }, |
| 336 | { 0x119A0, 0x119FF, U"Nandinagari" }, |
| 337 | { 0x11A00, 0x11A4F, U"Zanabazar Square" }, |
| 338 | { 0x11A50, 0x11AAF, U"Soyombo" }, |
| 339 | { 0x11AB0, 0x11ABF, U"Unified Canadian Aboriginal Syllabics Extended-A" }, |
| 340 | { 0x11AC0, 0x11AFF, U"Pau Cin Hau" }, |
| 341 | { 0x11B00, 0x11B5F, U"Devanagari Extended-A" }, |
| 342 | { 0x11C00, 0x11C6F, U"Bhaiksuki" }, |
| 343 | { 0x11C70, 0x11CBF, U"Marchen" }, |
| 344 | { 0x11D00, 0x11D5F, U"Masaram Gondi" }, |
| 345 | { 0x11D60, 0x11DAF, U"Gunjala Gondi" }, |
| 346 | { 0x11EE0, 0x11EFF, U"Makasar" }, |
| 347 | { 0x11F00, 0x11F5F, U"Kawi" }, |
| 348 | { 0x11FB0, 0x11FBF, U"Lisu Supplement" }, |
| 349 | { 0x11FC0, 0x11FFF, U"Tamil Supplement" }, |
| 350 | { 0x12000, 0x123FF, U"Cuneiform" }, |
| 351 | { 0x12400, 0x1247F, U"Cuneiform Numbers and Punctuation" }, |
| 352 | { 0x12480, 0x1254F, U"Early Dynastic Cuneiform" }, |
| 353 | { 0x12F90, 0x12FFF, U"Cypro-Minoan" }, |
| 354 | { 0x13000, 0x1342F, U"Egyptian Hieroglyphs" }, |
| 355 | { 0x13430, 0x1343F, U"Egyptian Hieroglyph Format Controls" }, |
| 356 | { 0x14400, 0x1467F, U"Anatolian Hieroglyphs" }, |
| 357 | { 0x16800, 0x16A3F, U"Bamum Supplement" }, |
| 358 | { 0x16A40, 0x16A6F, U"Mro" }, |
| 359 | { 0x16A70, 0x16ACF, U"Tangsa" }, |
| 360 | { 0x16AD0, 0x16AFF, U"Bassa Vah" }, |
| 361 | { 0x16B00, 0x16B8F, U"Pahawh Hmong" }, |
| 362 | { 0x16E40, 0x16E9F, U"Medefaidrin" }, |
| 363 | { 0x16F00, 0x16F9F, U"Miao" }, |
| 364 | { 0x16FE0, 0x16FFF, U"Ideographic Symbols and Punctuation" }, |
| 365 | { 0x17000, 0x187FF, U"Tangut" }, |
| 366 | { 0x18800, 0x18AFF, U"Tangut Components" }, |
| 367 | { 0x18B00, 0x18CFF, U"Khitan Small Script" }, |
| 368 | { 0x18D00, 0x18D7F, U"Tangut Supplement" }, |
| 369 | { 0x1AFF0, 0x1AFFF, U"Kana Extended-B" }, |
| 370 | { 0x1B000, 0x1B0FF, U"Kana Supplement" }, |
| 371 | { 0x1B100, 0x1B12F, U"Kana Extended-A" }, |
| 372 | { 0x1B130, 0x1B16F, U"Small Kana Extension" }, |
| 373 | { 0x1B170, 0x1B2FF, U"Nushu" }, |
| 374 | { 0x1BC00, 0x1BC9F, U"Duployan" }, |
| 375 | { 0x1BCA0, 0x1BCAF, U"Shorthand Format Controls" }, |
| 376 | { 0x1CF00, 0x1CFCF, U"Znamenny Musical Notation" }, |
| 377 | { 0x1D000, 0x1D0FF, U"Byzantine Musical Symbols" }, |
| 378 | { 0x1D100, 0x1D1FF, U"Musical Symbols" }, |
| 379 | { 0x1D200, 0x1D24F, U"Ancient Greek Musical Notation" }, |
| 380 | { 0x1D2C0, 0x1D2DF, U"Kaktovik Numerals" }, |
| 381 | { 0x1D2E0, 0x1D2FF, U"Mayan Numerals" }, |
| 382 | { 0x1D300, 0x1D35F, U"Tai Xuan Jing Symbols" }, |
| 383 | { 0x1D360, 0x1D37F, U"Counting Rod Numerals" }, |
| 384 | { 0x1D400, 0x1D7FF, U"Mathematical Alphanumeric Symbols" }, |
| 385 | { 0x1D800, 0x1DAAF, U"Sutton SignWriting" }, |
| 386 | { 0x1DF00, 0x1DFFF, U"Latin Extended-G" }, |
| 387 | { 0x1E000, 0x1E02F, U"Glagolitic Supplement" }, |
| 388 | { 0x1E030, 0x1E08F, U"Cyrillic Extended-D" }, |
| 389 | { 0x1E100, 0x1E14F, U"Nyiakeng Puachue Hmong" }, |
| 390 | { 0x1E290, 0x1E2BF, U"Toto" }, |
| 391 | { 0x1E2C0, 0x1E2FF, U"Wancho" }, |
| 392 | { 0x1E4D0, 0x1E4FF, U"Nag Mundari" }, |
| 393 | { 0x1E7E0, 0x1E7FF, U"Ethiopic Extended-B" }, |
| 394 | { 0x1E800, 0x1E8DF, U"Mende Kikakui" }, |
| 395 | { 0x1E900, 0x1E95F, U"Adlam" }, |
| 396 | { 0x1EC70, 0x1ECBF, U"Indic Siyaq Numbers" }, |
| 397 | { 0x1ED00, 0x1ED4F, U"Ottoman Siyaq Numbers" }, |
| 398 | { 0x1EE00, 0x1EEFF, U"Arabic Mathematical Alphabetic Symbols" }, |
| 399 | { 0x1F000, 0x1F02F, U"Mahjong Tiles" }, |
| 400 | { 0x1F030, 0x1F09F, U"Domino Tiles" }, |
| 401 | { 0x1F0A0, 0x1F0FF, U"Playing Cards" }, |
| 402 | { 0x1F100, 0x1F1FF, U"Enclosed Alphanumeric Supplement" }, |
| 403 | { 0x1F200, 0x1F2FF, U"Enclosed Ideographic Supplement" }, |
| 404 | { 0x1F300, 0x1F5FF, U"Miscellaneous Symbols and Pictographs" }, |
| 405 | { 0x1F600, 0x1F64F, U"Emoticons" }, |
| 406 | { 0x1F650, 0x1F67F, U"Ornamental Dingbats" }, |
| 407 | { 0x1F680, 0x1F6FF, U"Transport and Map Symbols" }, |
| 408 | { 0x1F700, 0x1F77F, U"Alchemical Symbols" }, |
| 409 | { 0x1F780, 0x1F7FF, U"Geometric Shapes Extended" }, |
| 410 | { 0x1F800, 0x1F8FF, U"Supplemental Arrows-C" }, |
| 411 | { 0x1F900, 0x1F9FF, U"Supplemental Symbols and Pictographs" }, |
| 412 | { 0x1FA00, 0x1FA6F, U"Chess Symbols" }, |
| 413 | { 0x1FA70, 0x1FAFF, U"Symbols and Pictographs Extended-A" }, |
| 414 | { 0x1FB00, 0x1FBFF, U"Symbols for Legacy Computing" }, |
| 415 | { 0x20000, 0x2A6DF, U"CJK Unified Ideographs Extension B" }, |
| 416 | { 0x2A700, 0x2B73F, U"CJK Unified Ideographs Extension C" }, |
| 417 | { 0x2B740, 0x2B81F, U"CJK Unified Ideographs Extension D" }, |
| 418 | { 0x2B820, 0x2CEAF, U"CJK Unified Ideographs Extension E" }, |
| 419 | { 0x2CEB0, 0x2EBEF, U"CJK Unified Ideographs Extension F" }, |
| 420 | { 0x2F800, 0x2FA1F, U"CJK Compatibility Ideographs Supplement" }, |
| 421 | { 0x30000, 0x3134F, U"CJK Unified Ideographs Extension G" }, |
| 422 | { 0x31350, 0x323AF, U"CJK Unified Ideographs Extension H" }, |
| 423 | //{ 0xE0000, 0xE007F, U"Tags" }, |
| 424 | //{ 0xE0100, 0xE01EF, U"Variation Selectors Supplement" }, |
| 425 | { 0xF0000, 0xFFFFF, U"Supplementary Private Use Area-A" }, |
| 426 | { 0x100000, 0x10FFFF, U"Supplementary Private Use Area-B" }, |
| 427 | { 0x10FFFF, 0x10FFFF, String() } |
| 428 | }; |
| 429 | |
| 430 | void DynamicFontImportSettings::_add_glyph_range_item(int32_t p_start, int32_t p_end, const String &p_name) { |
| 431 | const int page_size = 512; |
| 432 | int pages = (p_end - p_start) / page_size; |
| 433 | int remain = (p_end - p_start) % page_size; |
| 434 | |
| 435 | int32_t start = p_start; |
| 436 | for (int i = 0; i < pages; i++) { |
| 437 | TreeItem *item = glyph_tree->create_item(glyph_root); |
| 438 | ERR_FAIL_NULL(item); |
| 439 | item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); |
| 440 | item->set_text(0, _pad_zeros(String::num_int64(start, 16)) + " - " + _pad_zeros(String::num_int64(start + page_size, 16))); |
| 441 | item->set_text(1, p_name); |
| 442 | item->set_metadata(0, Vector2i(start, start + page_size)); |
| 443 | start += page_size; |
| 444 | } |
| 445 | if (remain > 0) { |
| 446 | TreeItem *item = glyph_tree->create_item(glyph_root); |
| 447 | ERR_FAIL_NULL(item); |
| 448 | item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); |
| 449 | item->set_text(0, _pad_zeros(String::num_int64(start, 16)) + " - " + _pad_zeros(String::num_int64(p_end, 16))); |
| 450 | item->set_text(1, p_name); |
| 451 | item->set_metadata(0, Vector2i(start, p_end)); |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | /*************************************************************************/ |
| 456 | /* Page 1 callbacks: Rendering Options */ |
| 457 | /*************************************************************************/ |
| 458 | |
| 459 | void DynamicFontImportSettings::_main_prop_changed(const String &p_edited_property) { |
| 460 | // Update font preview. |
| 461 | |
| 462 | if (font_preview.is_valid()) { |
| 463 | if (p_edited_property == "antialiasing" ) { |
| 464 | font_preview->set_antialiasing((TextServer::FontAntialiasing)import_settings_data->get("antialiasing" ).operator int()); |
| 465 | } else if (p_edited_property == "generate_mipmaps" ) { |
| 466 | font_preview->set_generate_mipmaps(import_settings_data->get("generate_mipmaps" )); |
| 467 | } else if (p_edited_property == "multichannel_signed_distance_field" ) { |
| 468 | font_preview->set_multichannel_signed_distance_field(import_settings_data->get("multichannel_signed_distance_field" )); |
| 469 | _variation_selected(); |
| 470 | _variations_validate(); |
| 471 | } else if (p_edited_property == "msdf_pixel_range" ) { |
| 472 | font_preview->set_msdf_pixel_range(import_settings_data->get("msdf_pixel_range" )); |
| 473 | } else if (p_edited_property == "msdf_size" ) { |
| 474 | font_preview->set_msdf_size(import_settings_data->get("msdf_size" )); |
| 475 | } else if (p_edited_property == "allow_system_fallback" ) { |
| 476 | font_preview->set_allow_system_fallback(import_settings_data->get("allow_system_fallback" )); |
| 477 | } else if (p_edited_property == "force_autohinter" ) { |
| 478 | font_preview->set_force_autohinter(import_settings_data->get("force_autohinter" )); |
| 479 | } else if (p_edited_property == "hinting" ) { |
| 480 | font_preview->set_hinting((TextServer::Hinting)import_settings_data->get("hinting" ).operator int()); |
| 481 | } else if (p_edited_property == "subpixel_positioning" ) { |
| 482 | font_preview->set_subpixel_positioning((TextServer::SubpixelPositioning)import_settings_data->get("subpixel_positioning" ).operator int()); |
| 483 | } else if (p_edited_property == "oversampling" ) { |
| 484 | font_preview->set_oversampling(import_settings_data->get("oversampling" )); |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | font_preview_label->add_theme_font_override("font" , font_preview); |
| 489 | font_preview_label->add_theme_font_size_override("font_size" , 200 * EDSCALE); |
| 490 | font_preview_label->queue_redraw(); |
| 491 | } |
| 492 | |
| 493 | /*************************************************************************/ |
| 494 | /* Page 2 callbacks: Configurations */ |
| 495 | /*************************************************************************/ |
| 496 | |
| 497 | void DynamicFontImportSettings::_variation_add() { |
| 498 | TreeItem *vars_item = vars_list->create_item(vars_list_root); |
| 499 | ERR_FAIL_NULL(vars_item); |
| 500 | |
| 501 | vars_item->set_text(0, TTR("New Configuration" )); |
| 502 | vars_item->set_editable(0, true); |
| 503 | vars_item->add_button(1, get_editor_theme_icon(SNAME("Remove" )), BUTTON_REMOVE_VAR, false, TTR("Remove Variation" )); |
| 504 | vars_item->set_button_color(1, 0, Color(1, 1, 1, 0.75)); |
| 505 | |
| 506 | Ref<DynamicFontImportSettingsData> import_variation_data; |
| 507 | import_variation_data.instantiate(); |
| 508 | import_variation_data->owner = this; |
| 509 | ERR_FAIL_NULL(import_variation_data); |
| 510 | |
| 511 | for (List<ResourceImporter::ImportOption>::Element *E = options_variations.front(); E; E = E->next()) { |
| 512 | import_variation_data->defaults[E->get().option.name] = E->get().default_value; |
| 513 | } |
| 514 | |
| 515 | import_variation_data->options = options_variations; |
| 516 | inspector_vars->edit(import_variation_data.ptr()); |
| 517 | import_variation_data->notify_property_list_changed(); |
| 518 | import_variation_data->fd = font_main; |
| 519 | |
| 520 | vars_item->set_metadata(0, import_variation_data); |
| 521 | |
| 522 | _variations_validate(); |
| 523 | } |
| 524 | |
| 525 | void DynamicFontImportSettings::_variation_selected() { |
| 526 | TreeItem *vars_item = vars_list->get_selected(); |
| 527 | if (vars_item) { |
| 528 | Ref<DynamicFontImportSettingsData> import_variation_data = vars_item->get_metadata(0); |
| 529 | ERR_FAIL_NULL(import_variation_data); |
| 530 | |
| 531 | inspector_vars->edit(import_variation_data.ptr()); |
| 532 | import_variation_data->notify_property_list_changed(); |
| 533 | |
| 534 | label_glyphs->set_text(vformat(TTR("Preloaded glyphs: %d" ), import_variation_data->selected_glyphs.size())); |
| 535 | _range_selected(); |
| 536 | _change_text_opts(); |
| 537 | |
| 538 | btn_fill->set_disabled(false); |
| 539 | btn_fill_locales->set_disabled(false); |
| 540 | } else { |
| 541 | btn_fill->set_disabled(true); |
| 542 | btn_fill_locales->set_disabled(true); |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | void DynamicFontImportSettings::_variation_remove(Object *p_item, int p_column, int p_id, MouseButton p_button) { |
| 547 | if (p_button != MouseButton::LEFT) { |
| 548 | return; |
| 549 | } |
| 550 | |
| 551 | TreeItem *vars_item = (TreeItem *)p_item; |
| 552 | ERR_FAIL_NULL(vars_item); |
| 553 | |
| 554 | inspector_vars->edit(nullptr); |
| 555 | |
| 556 | vars_list_root->remove_child(vars_item); |
| 557 | memdelete(vars_item); |
| 558 | |
| 559 | if (vars_list_root->get_first_child()) { |
| 560 | Ref<DynamicFontImportSettingsData> import_variation_data = vars_list_root->get_first_child()->get_metadata(0); |
| 561 | inspector_vars->edit(import_variation_data.ptr()); |
| 562 | import_variation_data->notify_property_list_changed(); |
| 563 | } |
| 564 | |
| 565 | _variations_validate(); |
| 566 | |
| 567 | vars_item = vars_list->get_selected(); |
| 568 | if (vars_item) { |
| 569 | btn_fill->set_disabled(false); |
| 570 | btn_fill_locales->set_disabled(false); |
| 571 | } else { |
| 572 | btn_fill->set_disabled(true); |
| 573 | btn_fill_locales->set_disabled(true); |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | void DynamicFontImportSettings::_variation_changed(const String &p_edited_property) { |
| 578 | _variations_validate(); |
| 579 | } |
| 580 | |
| 581 | void DynamicFontImportSettings::_variations_validate() { |
| 582 | String warn; |
| 583 | if (!vars_list_root->get_first_child()) { |
| 584 | warn = TTR("Warning: There are no configurations specified, no glyphs will be pre-rendered." ); |
| 585 | } |
| 586 | for (TreeItem *vars_item_a = vars_list_root->get_first_child(); vars_item_a; vars_item_a = vars_item_a->get_next()) { |
| 587 | Ref<DynamicFontImportSettingsData> import_variation_data_a = vars_item_a->get_metadata(0); |
| 588 | ERR_FAIL_NULL(import_variation_data_a); |
| 589 | |
| 590 | for (TreeItem *vars_item_b = vars_list_root->get_first_child(); vars_item_b; vars_item_b = vars_item_b->get_next()) { |
| 591 | if (vars_item_b != vars_item_a) { |
| 592 | bool match = true; |
| 593 | for (const KeyValue<StringName, Variant> &E : import_variation_data_a->settings) { |
| 594 | Ref<DynamicFontImportSettingsData> import_variation_data_b = vars_item_b->get_metadata(0); |
| 595 | ERR_FAIL_NULL(import_variation_data_b); |
| 596 | match = match && (import_variation_data_b->settings[E.key] == E.value); |
| 597 | } |
| 598 | if (match) { |
| 599 | warn = TTR("Warning: Multiple configurations have identical settings. Duplicates will be ignored." ); |
| 600 | break; |
| 601 | } |
| 602 | } |
| 603 | } |
| 604 | } |
| 605 | if ((TextServer::FontAntialiasing)(int)import_settings_data->get("antialiasing" ) == TextServer::FONT_ANTIALIASING_LCD) { |
| 606 | warn += "\n" + TTR("Note: LCD Subpixel antialiasing is selected, each of the glyphs will be pre-rendered for all supported subpixel layouts (5x)." ); |
| 607 | } |
| 608 | if ((TextServer::SubpixelPositioning)(int)import_settings_data->get("subpixel_positioning" ) != TextServer::SUBPIXEL_POSITIONING_DISABLED) { |
| 609 | warn += "\n" + TTR("Note: Subpixel positioning is selected, each of the glyphs might be pre-rendered for multiple subpixel offsets (up to 4x)." ); |
| 610 | } |
| 611 | if (warn.is_empty()) { |
| 612 | label_warn->set_text("" ); |
| 613 | label_warn->hide(); |
| 614 | } else { |
| 615 | label_warn->set_text(warn); |
| 616 | label_warn->show(); |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | /*************************************************************************/ |
| 621 | /* Page 2.1 callbacks: Text to select glyphs */ |
| 622 | /*************************************************************************/ |
| 623 | |
| 624 | void DynamicFontImportSettings::_change_text_opts() { |
| 625 | Ref<DynamicFontImportSettingsData> import_variation_data; |
| 626 | |
| 627 | TreeItem *vars_item = vars_list->get_selected(); |
| 628 | if (vars_item) { |
| 629 | import_variation_data = vars_item->get_metadata(0); |
| 630 | } |
| 631 | if (import_variation_data.is_null()) { |
| 632 | return; |
| 633 | } |
| 634 | |
| 635 | Ref<FontVariation> font_main_text; |
| 636 | font_main_text.instantiate(); |
| 637 | font_main_text->set_base_font(font_main); |
| 638 | font_main_text->set_opentype_features(text_settings_data->get("opentype_features" )); |
| 639 | font_main_text->set_variation_opentype(import_variation_data->get("variation_opentype" )); |
| 640 | font_main_text->set_variation_embolden(import_variation_data->get("variation_embolden" )); |
| 641 | font_main_text->set_variation_face_index(import_variation_data->get("variation_face_index" )); |
| 642 | font_main_text->set_variation_transform(import_variation_data->get("variation_transform" )); |
| 643 | |
| 644 | text_edit->add_theme_font_override("font" , font_main_text); |
| 645 | } |
| 646 | |
| 647 | void DynamicFontImportSettings::_glyph_update_lbl() { |
| 648 | Ref<DynamicFontImportSettingsData> import_variation_data; |
| 649 | |
| 650 | TreeItem *vars_item = vars_list->get_selected(); |
| 651 | if (vars_item) { |
| 652 | import_variation_data = vars_item->get_metadata(0); |
| 653 | } |
| 654 | if (import_variation_data.is_null()) { |
| 655 | return; |
| 656 | } |
| 657 | |
| 658 | int linked_glyphs = 0; |
| 659 | for (const char32_t &c : import_variation_data->selected_chars) { |
| 660 | if (import_variation_data->selected_glyphs.has(font_main->get_glyph_index(16, c))) { |
| 661 | linked_glyphs++; |
| 662 | } |
| 663 | } |
| 664 | int unlinked_glyphs = import_variation_data->selected_glyphs.size() - linked_glyphs; |
| 665 | label_glyphs->set_text(vformat(TTR("Preloaded glyphs: %d" ), unlinked_glyphs + import_variation_data->selected_chars.size())); |
| 666 | } |
| 667 | |
| 668 | void DynamicFontImportSettings::_glyph_clear() { |
| 669 | Ref<DynamicFontImportSettingsData> import_variation_data; |
| 670 | |
| 671 | TreeItem *vars_item = vars_list->get_selected(); |
| 672 | if (vars_item) { |
| 673 | import_variation_data = vars_item->get_metadata(0); |
| 674 | } |
| 675 | if (import_variation_data.is_null()) { |
| 676 | return; |
| 677 | } |
| 678 | |
| 679 | import_variation_data->selected_glyphs.clear(); |
| 680 | _glyph_update_lbl(); |
| 681 | _range_selected(); |
| 682 | } |
| 683 | |
| 684 | void DynamicFontImportSettings::_glyph_text_selected() { |
| 685 | Ref<DynamicFontImportSettingsData> import_variation_data; |
| 686 | |
| 687 | TreeItem *vars_item = vars_list->get_selected(); |
| 688 | if (vars_item) { |
| 689 | import_variation_data = vars_item->get_metadata(0); |
| 690 | } |
| 691 | if (import_variation_data.is_null()) { |
| 692 | return; |
| 693 | } |
| 694 | RID text_rid = TS->create_shaped_text(); |
| 695 | if (text_rid.is_valid()) { |
| 696 | 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" )); |
| 697 | TS->shaped_text_shape(text_rid); |
| 698 | const Glyph *gl = TS->shaped_text_get_glyphs(text_rid); |
| 699 | const int gl_size = TS->shaped_text_get_glyph_count(text_rid); |
| 700 | |
| 701 | for (int i = 0; i < gl_size; i++) { |
| 702 | if (gl[i].font_rid.is_valid() && gl[i].index != 0) { |
| 703 | import_variation_data->selected_glyphs.insert(gl[i].index); |
| 704 | } |
| 705 | } |
| 706 | TS->free_rid(text_rid); |
| 707 | _glyph_update_lbl(); |
| 708 | } |
| 709 | _range_selected(); |
| 710 | } |
| 711 | |
| 712 | /*************************************************************************/ |
| 713 | /* Page 2.2 callbacks: Character map */ |
| 714 | /*************************************************************************/ |
| 715 | |
| 716 | void DynamicFontImportSettings::_glyph_selected() { |
| 717 | Ref<DynamicFontImportSettingsData> import_variation_data; |
| 718 | |
| 719 | TreeItem *vars_item = vars_list->get_selected(); |
| 720 | if (vars_item) { |
| 721 | import_variation_data = vars_item->get_metadata(0); |
| 722 | } |
| 723 | if (import_variation_data.is_null()) { |
| 724 | return; |
| 725 | } |
| 726 | |
| 727 | TreeItem *item = glyph_table->get_selected(); |
| 728 | ERR_FAIL_NULL(item); |
| 729 | |
| 730 | Color scol = glyph_table->get_theme_color(SNAME("box_selection_fill_color" ), EditorStringName(Editor)); |
| 731 | Color fcol = glyph_table->get_theme_color(SNAME("font_selected_color" ), EditorStringName(Editor)); |
| 732 | scol.a = 1.f; |
| 733 | |
| 734 | int32_t c = item->get_metadata(glyph_table->get_selected_column()); |
| 735 | if (font_main->has_char(c)) { |
| 736 | if (_char_update(c)) { |
| 737 | item->set_custom_color(glyph_table->get_selected_column(), fcol); |
| 738 | item->set_custom_bg_color(glyph_table->get_selected_column(), scol); |
| 739 | } else { |
| 740 | item->clear_custom_color(glyph_table->get_selected_column()); |
| 741 | item->clear_custom_bg_color(glyph_table->get_selected_column()); |
| 742 | } |
| 743 | } |
| 744 | _glyph_update_lbl(); |
| 745 | |
| 746 | item = glyph_tree->get_selected(); |
| 747 | ERR_FAIL_NULL(item); |
| 748 | Vector2i range = item->get_metadata(0); |
| 749 | |
| 750 | int total_chars = range.y - range.x; |
| 751 | int selected_count = 0; |
| 752 | for (int i = range.x; i < range.y; i++) { |
| 753 | if (!font_main->has_char(i)) { |
| 754 | total_chars--; |
| 755 | } |
| 756 | |
| 757 | if (import_variation_data->selected_chars.has(i)) { |
| 758 | selected_count++; |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | if (selected_count == total_chars) { |
| 763 | item->set_checked(0, true); |
| 764 | } else if (selected_count > 0) { |
| 765 | item->set_indeterminate(0, true); |
| 766 | } else { |
| 767 | item->set_checked(0, false); |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | void DynamicFontImportSettings::_range_edited() { |
| 772 | TreeItem *item = glyph_tree->get_selected(); |
| 773 | ERR_FAIL_NULL(item); |
| 774 | Vector2i range = item->get_metadata(0); |
| 775 | _range_update(range.x, range.y); |
| 776 | } |
| 777 | |
| 778 | void DynamicFontImportSettings::_range_selected() { |
| 779 | TreeItem *item = glyph_tree->get_selected(); |
| 780 | if (item) { |
| 781 | Vector2i range = item->get_metadata(0); |
| 782 | _edit_range(range.x, range.y); |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | void DynamicFontImportSettings::_edit_range(int32_t p_start, int32_t p_end) { |
| 787 | Ref<DynamicFontImportSettingsData> import_variation_data; |
| 788 | |
| 789 | TreeItem *vars_item = vars_list->get_selected(); |
| 790 | if (vars_item) { |
| 791 | import_variation_data = vars_item->get_metadata(0); |
| 792 | } |
| 793 | if (import_variation_data.is_null()) { |
| 794 | return; |
| 795 | } |
| 796 | |
| 797 | glyph_table->clear(); |
| 798 | |
| 799 | TreeItem *root = glyph_table->create_item(); |
| 800 | ERR_FAIL_NULL(root); |
| 801 | |
| 802 | Color scol = glyph_table->get_theme_color(SNAME("box_selection_fill_color" ), EditorStringName(Editor)); |
| 803 | Color fcol = glyph_table->get_theme_color(SNAME("font_selected_color" ), EditorStringName(Editor)); |
| 804 | scol.a = 1.f; |
| 805 | |
| 806 | TreeItem *item = nullptr; |
| 807 | int col = 0; |
| 808 | |
| 809 | Ref<Font> font_main_big = font_main->duplicate(); |
| 810 | |
| 811 | for (int32_t c = p_start; c <= p_end; c++) { |
| 812 | if (col == 0) { |
| 813 | item = glyph_table->create_item(root); |
| 814 | ERR_FAIL_NULL(item); |
| 815 | item->set_text(0, _pad_zeros(String::num_int64(c, 16))); |
| 816 | item->set_text_alignment(0, HORIZONTAL_ALIGNMENT_LEFT); |
| 817 | item->set_selectable(0, false); |
| 818 | item->set_custom_bg_color(0, glyph_table->get_theme_color(SNAME("dark_color_3" ), EditorStringName(Editor))); |
| 819 | } |
| 820 | if (font_main->has_char(c)) { |
| 821 | item->set_text(col + 1, String::chr(c)); |
| 822 | item->set_custom_color(col + 1, Color(1, 1, 1)); |
| 823 | if (import_variation_data->selected_chars.has(c) || import_variation_data->selected_glyphs.has(font_main->get_glyph_index(16, c))) { |
| 824 | item->set_custom_color(col + 1, fcol); |
| 825 | item->set_custom_bg_color(col + 1, scol); |
| 826 | } else { |
| 827 | item->clear_custom_color(col + 1); |
| 828 | item->clear_custom_bg_color(col + 1); |
| 829 | } |
| 830 | } else { |
| 831 | item->set_custom_bg_color(col + 1, glyph_table->get_theme_color(SNAME("dark_color_2" ), EditorStringName(Editor))); |
| 832 | } |
| 833 | item->set_metadata(col + 1, c); |
| 834 | item->set_text_alignment(col + 1, HORIZONTAL_ALIGNMENT_CENTER); |
| 835 | item->set_selectable(col + 1, true); |
| 836 | |
| 837 | item->set_custom_font(col + 1, font_main_big); |
| 838 | item->set_custom_font_size(col + 1, get_theme_font_size(SNAME("font_size" )) * 2); |
| 839 | |
| 840 | col++; |
| 841 | if (col == 16) { |
| 842 | col = 0; |
| 843 | } |
| 844 | } |
| 845 | _glyph_update_lbl(); |
| 846 | } |
| 847 | |
| 848 | bool DynamicFontImportSettings::_char_update(int32_t p_char) { |
| 849 | Ref<DynamicFontImportSettingsData> import_variation_data; |
| 850 | |
| 851 | TreeItem *vars_item = vars_list->get_selected(); |
| 852 | if (vars_item) { |
| 853 | import_variation_data = vars_item->get_metadata(0); |
| 854 | } |
| 855 | if (import_variation_data.is_null()) { |
| 856 | return false; |
| 857 | } |
| 858 | |
| 859 | if (import_variation_data->selected_chars.has(p_char)) { |
| 860 | import_variation_data->selected_chars.erase(p_char); |
| 861 | return false; |
| 862 | } else if (font_main.is_valid() && import_variation_data->selected_glyphs.has(font_main->get_glyph_index(16, p_char))) { |
| 863 | import_variation_data->selected_glyphs.erase(font_main->get_glyph_index(16, p_char)); |
| 864 | return false; |
| 865 | } else { |
| 866 | import_variation_data->selected_chars.insert(p_char); |
| 867 | return true; |
| 868 | } |
| 869 | } |
| 870 | |
| 871 | void DynamicFontImportSettings::_range_update(int32_t p_start, int32_t p_end) { |
| 872 | Ref<DynamicFontImportSettingsData> import_variation_data; |
| 873 | |
| 874 | TreeItem *vars_item = vars_list->get_selected(); |
| 875 | if (vars_item) { |
| 876 | import_variation_data = vars_item->get_metadata(0); |
| 877 | } |
| 878 | if (import_variation_data.is_null()) { |
| 879 | return; |
| 880 | } |
| 881 | |
| 882 | bool all_selected = true; |
| 883 | for (int32_t i = p_start; i <= p_end; i++) { |
| 884 | if (font_main->has_char(i)) { |
| 885 | if (font_main.is_valid()) { |
| 886 | all_selected = all_selected && (import_variation_data->selected_chars.has(i) || import_variation_data->selected_glyphs.has(font_main->get_glyph_index(16, i))); |
| 887 | } else { |
| 888 | all_selected = all_selected && import_variation_data->selected_chars.has(i); |
| 889 | } |
| 890 | } |
| 891 | } |
| 892 | for (int32_t i = p_start; i <= p_end; i++) { |
| 893 | if (font_main->has_char(i)) { |
| 894 | if (!all_selected) { |
| 895 | import_variation_data->selected_chars.insert(i); |
| 896 | } else { |
| 897 | import_variation_data->selected_chars.erase(i); |
| 898 | if (font_main.is_valid()) { |
| 899 | import_variation_data->selected_glyphs.erase(font_main->get_glyph_index(16, i)); |
| 900 | } |
| 901 | } |
| 902 | } |
| 903 | } |
| 904 | _edit_range(p_start, p_end); |
| 905 | |
| 906 | TreeItem *item = glyph_tree->get_selected(); |
| 907 | ERR_FAIL_NULL(item); |
| 908 | item->set_checked(0, !all_selected); |
| 909 | } |
| 910 | |
| 911 | /*************************************************************************/ |
| 912 | /* Common */ |
| 913 | /*************************************************************************/ |
| 914 | |
| 915 | DynamicFontImportSettings *DynamicFontImportSettings::singleton = nullptr; |
| 916 | |
| 917 | String DynamicFontImportSettings::_pad_zeros(const String &p_hex) const { |
| 918 | int len = CLAMP(5 - p_hex.length(), 0, 5); |
| 919 | return String("0" ).repeat(len) + p_hex; |
| 920 | } |
| 921 | |
| 922 | void DynamicFontImportSettings::_notification(int p_what) { |
| 923 | switch (p_what) { |
| 924 | case NOTIFICATION_READY: { |
| 925 | connect("confirmed" , callable_mp(this, &DynamicFontImportSettings::_re_import)); |
| 926 | } break; |
| 927 | |
| 928 | case NOTIFICATION_THEME_CHANGED: { |
| 929 | add_var->set_icon(get_editor_theme_icon(SNAME("Add" ))); |
| 930 | label_warn->add_theme_color_override("font_color" , get_theme_color(SNAME("warning_color" ), EditorStringName(Editor))); |
| 931 | } break; |
| 932 | } |
| 933 | } |
| 934 | |
| 935 | void DynamicFontImportSettings::_re_import() { |
| 936 | HashMap<StringName, Variant> main_settings; |
| 937 | |
| 938 | main_settings["face_index" ] = import_settings_data->get("face_index" ); |
| 939 | main_settings["antialiasing" ] = import_settings_data->get("antialiasing" ); |
| 940 | main_settings["generate_mipmaps" ] = import_settings_data->get("generate_mipmaps" ); |
| 941 | main_settings["multichannel_signed_distance_field" ] = import_settings_data->get("multichannel_signed_distance_field" ); |
| 942 | main_settings["msdf_pixel_range" ] = import_settings_data->get("msdf_pixel_range" ); |
| 943 | main_settings["msdf_size" ] = import_settings_data->get("msdf_size" ); |
| 944 | main_settings["allow_system_fallback" ] = import_settings_data->get("allow_system_fallback" ); |
| 945 | main_settings["force_autohinter" ] = import_settings_data->get("force_autohinter" ); |
| 946 | main_settings["hinting" ] = import_settings_data->get("hinting" ); |
| 947 | main_settings["subpixel_positioning" ] = import_settings_data->get("subpixel_positioning" ); |
| 948 | main_settings["oversampling" ] = import_settings_data->get("oversampling" ); |
| 949 | main_settings["fallbacks" ] = import_settings_data->get("fallbacks" ); |
| 950 | main_settings["compress" ] = import_settings_data->get("compress" ); |
| 951 | |
| 952 | Array configurations; |
| 953 | for (TreeItem *vars_item = vars_list_root->get_first_child(); vars_item; vars_item = vars_item->get_next()) { |
| 954 | Ref<DynamicFontImportSettingsData> import_variation_data = vars_item->get_metadata(0); |
| 955 | ERR_FAIL_NULL(import_variation_data); |
| 956 | |
| 957 | Dictionary preload_config; |
| 958 | preload_config["name" ] = vars_item->get_text(0); |
| 959 | |
| 960 | Size2i conf_size = Vector2i(16, 0); |
| 961 | for (const KeyValue<StringName, Variant> &E : import_variation_data->settings) { |
| 962 | if (E.key == "size" ) { |
| 963 | conf_size.x = E.value; |
| 964 | } |
| 965 | if (E.key == "outline_size" ) { |
| 966 | conf_size.y = E.value; |
| 967 | } else { |
| 968 | preload_config[E.key] = E.value; |
| 969 | } |
| 970 | } |
| 971 | preload_config["size" ] = conf_size; |
| 972 | |
| 973 | Array chars; |
| 974 | for (const char32_t &E : import_variation_data->selected_chars) { |
| 975 | chars.push_back(E); |
| 976 | } |
| 977 | preload_config["chars" ] = chars; |
| 978 | |
| 979 | Array glyphs; |
| 980 | for (const int32_t &E : import_variation_data->selected_glyphs) { |
| 981 | glyphs.push_back(E); |
| 982 | } |
| 983 | preload_config["glyphs" ] = glyphs; |
| 984 | |
| 985 | configurations.push_back(preload_config); |
| 986 | } |
| 987 | main_settings["preload" ] = configurations; |
| 988 | main_settings["language_support" ] = import_settings_data->get("language_support" ); |
| 989 | main_settings["script_support" ] = import_settings_data->get("script_support" ); |
| 990 | main_settings["opentype_features" ] = import_settings_data->get("opentype_features" ); |
| 991 | |
| 992 | if (OS::get_singleton()->is_stdout_verbose()) { |
| 993 | print_line("Import settings:" ); |
| 994 | for (const KeyValue<StringName, Variant> &E : main_settings) { |
| 995 | print_line(String(" " ) + String(E.key).utf8().get_data() + " == " + String(E.value).utf8().get_data()); |
| 996 | } |
| 997 | } |
| 998 | |
| 999 | EditorFileSystem::get_singleton()->reimport_file_with_custom_parameters(base_path, "font_data_dynamic" , main_settings); |
| 1000 | } |
| 1001 | |
| 1002 | void DynamicFontImportSettings::_locale_edited() { |
| 1003 | TreeItem *item = locale_tree->get_selected(); |
| 1004 | ERR_FAIL_NULL(item); |
| 1005 | item->set_checked(0, !item->is_checked(0)); |
| 1006 | } |
| 1007 | |
| 1008 | void DynamicFontImportSettings::_process_locales() { |
| 1009 | Ref<DynamicFontImportSettingsData> import_variation_data; |
| 1010 | |
| 1011 | TreeItem *vars_item = vars_list->get_selected(); |
| 1012 | if (vars_item) { |
| 1013 | import_variation_data = vars_item->get_metadata(0); |
| 1014 | } |
| 1015 | if (import_variation_data.is_null()) { |
| 1016 | return; |
| 1017 | } |
| 1018 | |
| 1019 | for (int i = 0; i < locale_root->get_child_count(); i++) { |
| 1020 | TreeItem *item = locale_root->get_child(i); |
| 1021 | if (item) { |
| 1022 | if (item->is_checked(0)) { |
| 1023 | String locale = item->get_text(0); |
| 1024 | Ref<Translation> tr = ResourceLoader::load(locale); |
| 1025 | if (tr.is_valid()) { |
| 1026 | Vector<String> messages = tr->get_translated_message_list(); |
| 1027 | for (const String &E : messages) { |
| 1028 | RID text_rid = TS->create_shaped_text(); |
| 1029 | if (text_rid.is_valid()) { |
| 1030 | TS->shaped_text_add_string(text_rid, E, font_main->get_rids(), 16, Dictionary(), tr->get_locale()); |
| 1031 | TS->shaped_text_shape(text_rid); |
| 1032 | const Glyph *gl = TS->shaped_text_get_glyphs(text_rid); |
| 1033 | const int gl_size = TS->shaped_text_get_glyph_count(text_rid); |
| 1034 | |
| 1035 | for (int j = 0; j < gl_size; j++) { |
| 1036 | if (gl[j].font_rid.is_valid() && gl[j].index != 0) { |
| 1037 | import_variation_data->selected_glyphs.insert(gl[j].index); |
| 1038 | } |
| 1039 | } |
| 1040 | TS->free_rid(text_rid); |
| 1041 | } |
| 1042 | } |
| 1043 | } |
| 1044 | } |
| 1045 | } |
| 1046 | } |
| 1047 | |
| 1048 | _glyph_update_lbl(); |
| 1049 | _range_selected(); |
| 1050 | } |
| 1051 | |
| 1052 | void DynamicFontImportSettings::open_settings(const String &p_path) { |
| 1053 | // Load base font data. |
| 1054 | Vector<uint8_t> font_data = FileAccess::get_file_as_bytes(p_path); |
| 1055 | |
| 1056 | // Load project locale list. |
| 1057 | locale_tree->clear(); |
| 1058 | locale_root = locale_tree->create_item(); |
| 1059 | ERR_FAIL_NULL(locale_root); |
| 1060 | |
| 1061 | Vector<String> translations = GLOBAL_GET("internationalization/locale/translations" ); |
| 1062 | for (const String &E : translations) { |
| 1063 | TreeItem *item = locale_tree->create_item(locale_root); |
| 1064 | ERR_FAIL_NULL(item); |
| 1065 | item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); |
| 1066 | item->set_text(0, E); |
| 1067 | } |
| 1068 | |
| 1069 | // Load font for preview. |
| 1070 | font_preview.instantiate(); |
| 1071 | font_preview->set_data(font_data); |
| 1072 | |
| 1073 | String font_name = vformat("%s (%s)" , font_preview->get_font_name(), font_preview->get_font_style_name()); |
| 1074 | String sample; |
| 1075 | static const String sample_base = U"12漢字ԱբΑαАбΑαאבابܐܒހށआআਆઆଆஆఆಆആආกิກິༀကႠა한글ሀᎣᐁᚁᚠᜀᜠᝀᝠកᠠᤁᥐAb😀" ; |
| 1076 | for (int i = 0; i < sample_base.length(); i++) { |
| 1077 | if (font_preview->has_char(sample_base[i])) { |
| 1078 | sample += sample_base[i]; |
| 1079 | } |
| 1080 | } |
| 1081 | if (sample.is_empty()) { |
| 1082 | sample = font_preview->get_supported_chars().substr(0, 6); |
| 1083 | } |
| 1084 | font_preview_label->set_text(sample); |
| 1085 | |
| 1086 | Ref<Font> bold_font = get_theme_font(SNAME("bold" ), EditorStringName(EditorFonts)); |
| 1087 | if (bold_font.is_valid()) { |
| 1088 | font_name_label->add_theme_font_override("bold_font" , bold_font); |
| 1089 | } |
| 1090 | font_name_label->set_text(font_name); |
| 1091 | |
| 1092 | // Load second copy of font with MSDF disabled for the glyph table and metadata extraction. |
| 1093 | font_main.instantiate(); |
| 1094 | font_main->set_data(font_data); |
| 1095 | font_main->set_multichannel_signed_distance_field(false); |
| 1096 | |
| 1097 | text_edit->add_theme_font_override("font" , font_main); |
| 1098 | |
| 1099 | base_path = p_path; |
| 1100 | |
| 1101 | inspector_vars->edit(nullptr); |
| 1102 | inspector_text->edit(nullptr); |
| 1103 | inspector_general->edit(nullptr); |
| 1104 | |
| 1105 | text_settings_data.instantiate(); |
| 1106 | ERR_FAIL_NULL(text_settings_data); |
| 1107 | |
| 1108 | text_settings_data->owner = this; |
| 1109 | |
| 1110 | for (List<ResourceImporter::ImportOption>::Element *F = options_text.front(); F; F = F->next()) { |
| 1111 | text_settings_data->defaults[F->get().option.name] = F->get().default_value; |
| 1112 | } |
| 1113 | |
| 1114 | text_settings_data->fd = font_main; |
| 1115 | text_settings_data->options = options_text; |
| 1116 | |
| 1117 | inspector_text->edit(text_settings_data.ptr()); |
| 1118 | |
| 1119 | int gww = get_theme_font(SNAME("font" ))->get_string_size("00000" ).x + 50; |
| 1120 | glyph_table->set_column_custom_minimum_width(0, gww); |
| 1121 | glyph_table->clear(); |
| 1122 | vars_list->clear(); |
| 1123 | |
| 1124 | glyph_tree->set_selected(glyph_root->get_child(0)); |
| 1125 | |
| 1126 | vars_list_root = vars_list->create_item(); |
| 1127 | |
| 1128 | import_settings_data->settings.clear(); |
| 1129 | import_settings_data->defaults.clear(); |
| 1130 | for (List<ResourceImporter::ImportOption>::Element *E = options_general.front(); E; E = E->next()) { |
| 1131 | import_settings_data->defaults[E->get().option.name] = E->get().default_value; |
| 1132 | } |
| 1133 | |
| 1134 | Ref<ConfigFile> config; |
| 1135 | config.instantiate(); |
| 1136 | ERR_FAIL_NULL(config); |
| 1137 | |
| 1138 | Error err = config->load(p_path + ".import" ); |
| 1139 | print_verbose("Loading import settings:" ); |
| 1140 | if (err == OK) { |
| 1141 | List<String> keys; |
| 1142 | config->get_section_keys("params" , &keys); |
| 1143 | for (List<String>::Element *E = keys.front(); E; E = E->next()) { |
| 1144 | String key = E->get(); |
| 1145 | print_verbose(String(" " ) + key + " == " + String(config->get_value("params" , key))); |
| 1146 | if (key == "preload" ) { |
| 1147 | Array preload_configurations = config->get_value("params" , key); |
| 1148 | for (int i = 0; i < preload_configurations.size(); i++) { |
| 1149 | Dictionary preload_config = preload_configurations[i]; |
| 1150 | |
| 1151 | Dictionary variation = preload_config.has("variation_opentype" ) ? preload_config["variation_opentype" ].operator Dictionary() : Dictionary(); |
| 1152 | double embolden = preload_config.has("variation_embolden" ) ? preload_config["variation_embolden" ].operator double() : 0; |
| 1153 | int face_index = preload_config.has("variation_face_index" ) ? preload_config["variation_face_index" ].operator int() : 0; |
| 1154 | Transform2D transform = preload_config.has("variation_transform" ) ? preload_config["variation_transform" ].operator Transform2D() : Transform2D(); |
| 1155 | Vector2i font_size = preload_config.has("size" ) ? preload_config["size" ].operator Vector2i() : Vector2i(16, 0); |
| 1156 | String cfg_name = preload_config.has("name" ) ? preload_config["name" ].operator String() : vformat("Configuration %d" , i); |
| 1157 | |
| 1158 | TreeItem *vars_item = vars_list->create_item(vars_list_root); |
| 1159 | ERR_FAIL_NULL(vars_item); |
| 1160 | |
| 1161 | vars_item->set_text(0, cfg_name); |
| 1162 | vars_item->set_editable(0, true); |
| 1163 | vars_item->add_button(1, get_editor_theme_icon(SNAME("Remove" )), BUTTON_REMOVE_VAR, false, TTR("Remove Variation" )); |
| 1164 | vars_item->set_button_color(1, 0, Color(1, 1, 1, 0.75)); |
| 1165 | |
| 1166 | Ref<DynamicFontImportSettingsData> import_variation_data_custom; |
| 1167 | import_variation_data_custom.instantiate(); |
| 1168 | ERR_FAIL_NULL(import_variation_data_custom); |
| 1169 | |
| 1170 | import_variation_data_custom->owner = this; |
| 1171 | for (List<ResourceImporter::ImportOption>::Element *F = options_variations.front(); F; F = F->next()) { |
| 1172 | import_variation_data_custom->defaults[F->get().option.name] = F->get().default_value; |
| 1173 | } |
| 1174 | |
| 1175 | import_variation_data_custom->fd = font_main; |
| 1176 | |
| 1177 | import_variation_data_custom->options = options_variations; |
| 1178 | vars_item->set_metadata(0, import_variation_data_custom); |
| 1179 | |
| 1180 | import_variation_data_custom->set("size" , font_size.x); |
| 1181 | import_variation_data_custom->set("outline_size" , font_size.y); |
| 1182 | import_variation_data_custom->set("variation_opentype" , variation); |
| 1183 | import_variation_data_custom->set("variation_embolden" , embolden); |
| 1184 | import_variation_data_custom->set("variation_face_index" , face_index); |
| 1185 | import_variation_data_custom->set("variation_transform" , transform); |
| 1186 | |
| 1187 | Array chars = preload_config["chars" ]; |
| 1188 | for (int j = 0; j < chars.size(); j++) { |
| 1189 | char32_t c = chars[j].operator int(); |
| 1190 | import_variation_data_custom->selected_chars.insert(c); |
| 1191 | } |
| 1192 | |
| 1193 | Array glyphs = preload_config["glyphs" ]; |
| 1194 | for (int j = 0; j < glyphs.size(); j++) { |
| 1195 | int32_t c = glyphs[j]; |
| 1196 | import_variation_data_custom->selected_glyphs.insert(c); |
| 1197 | } |
| 1198 | } |
| 1199 | if (preload_configurations.is_empty()) { |
| 1200 | _variation_add(); // Add default variation. |
| 1201 | } |
| 1202 | vars_list->set_selected(vars_list_root->get_child(0)); |
| 1203 | } else { |
| 1204 | Variant value = config->get_value("params" , key); |
| 1205 | import_settings_data->defaults[key] = value; |
| 1206 | } |
| 1207 | } |
| 1208 | } |
| 1209 | |
| 1210 | import_settings_data->fd = font_main; |
| 1211 | import_settings_data->options = options_general; |
| 1212 | inspector_general->edit(import_settings_data.ptr()); |
| 1213 | import_settings_data->notify_property_list_changed(); |
| 1214 | |
| 1215 | if (font_preview.is_valid()) { |
| 1216 | font_preview->set_antialiasing((TextServer::FontAntialiasing)import_settings_data->get("antialiasing" ).operator int()); |
| 1217 | font_preview->set_multichannel_signed_distance_field(import_settings_data->get("multichannel_signed_distance_field" )); |
| 1218 | font_preview->set_msdf_pixel_range(import_settings_data->get("msdf_pixel_range" )); |
| 1219 | font_preview->set_msdf_size(import_settings_data->get("msdf_size" )); |
| 1220 | font_preview->set_allow_system_fallback(import_settings_data->get("allow_system_fallback" )); |
| 1221 | font_preview->set_force_autohinter(import_settings_data->get("force_autohinter" )); |
| 1222 | font_preview->set_hinting((TextServer::Hinting)import_settings_data->get("hinting" ).operator int()); |
| 1223 | font_preview->set_subpixel_positioning((TextServer::SubpixelPositioning)import_settings_data->get("subpixel_positioning" ).operator int()); |
| 1224 | font_preview->set_oversampling(import_settings_data->get("oversampling" )); |
| 1225 | } |
| 1226 | font_preview_label->add_theme_font_override("font" , font_preview); |
| 1227 | font_preview_label->add_theme_font_size_override("font_size" , 200 * EDSCALE); |
| 1228 | font_preview_label->queue_redraw(); |
| 1229 | |
| 1230 | _variations_validate(); |
| 1231 | |
| 1232 | popup_centered_ratio(); |
| 1233 | |
| 1234 | set_title(vformat(TTR("Advanced Import Settings for '%s'" ), base_path.get_file())); |
| 1235 | } |
| 1236 | |
| 1237 | DynamicFontImportSettings *DynamicFontImportSettings::get_singleton() { |
| 1238 | return singleton; |
| 1239 | } |
| 1240 | |
| 1241 | DynamicFontImportSettings::DynamicFontImportSettings() { |
| 1242 | singleton = this; |
| 1243 | |
| 1244 | options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::NIL, "Rendering" , PROPERTY_HINT_NONE, "" , PROPERTY_USAGE_GROUP), Variant())); |
| 1245 | |
| 1246 | options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "antialiasing" , PROPERTY_HINT_ENUM, "None,Grayscale,LCD Subpixel" ), 1)); |
| 1247 | options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "generate_mipmaps" ), false)); |
| 1248 | 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)); |
| 1249 | options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "msdf_pixel_range" , PROPERTY_HINT_RANGE, "1,100,1" ), 8)); |
| 1250 | options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "msdf_size" , PROPERTY_HINT_RANGE, "1,250,1" ), 48)); |
| 1251 | options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "allow_system_fallback" ), true)); |
| 1252 | options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "force_autohinter" ), false)); |
| 1253 | options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "hinting" , PROPERTY_HINT_ENUM, "None,Light,Normal" ), 1)); |
| 1254 | 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)); |
| 1255 | options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::FLOAT, "oversampling" , PROPERTY_HINT_RANGE, "0,10,0.1" ), 0.0)); |
| 1256 | |
| 1257 | options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::NIL, "Metadata Overrides" , PROPERTY_HINT_NONE, "" , PROPERTY_USAGE_GROUP), Variant())); |
| 1258 | options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::DICTIONARY, "language_support" ), Dictionary())); |
| 1259 | options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::DICTIONARY, "script_support" ), Dictionary())); |
| 1260 | options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::DICTIONARY, "opentype_features" ), Dictionary())); |
| 1261 | |
| 1262 | options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::NIL, "Fallbacks" , PROPERTY_HINT_NONE, "" , PROPERTY_USAGE_GROUP), Variant())); |
| 1263 | options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::ARRAY, "fallbacks" , PROPERTY_HINT_ARRAY_TYPE, MAKE_RESOURCE_TYPE_HINT("Font" )), Array())); |
| 1264 | |
| 1265 | options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::NIL, "Compress" , PROPERTY_HINT_NONE, "" , PROPERTY_USAGE_GROUP), Variant())); |
| 1266 | options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "compress" , PROPERTY_HINT_NONE, "" ), false)); |
| 1267 | |
| 1268 | options_text.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::DICTIONARY, "opentype_features" ), Dictionary())); |
| 1269 | options_text.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::STRING, "language" , PROPERTY_HINT_LOCALE_ID, "" ), "" )); |
| 1270 | |
| 1271 | options_variations.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "size" , PROPERTY_HINT_RANGE, "0,127,1" ), 16)); |
| 1272 | options_variations.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "outline_size" , PROPERTY_HINT_RANGE, "0,127,1" ), 0)); |
| 1273 | options_variations.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::NIL, "Variation" , PROPERTY_HINT_NONE, "variation" , PROPERTY_USAGE_GROUP), Variant())); |
| 1274 | options_variations.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::DICTIONARY, "variation_opentype" ), Dictionary())); |
| 1275 | options_variations.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::FLOAT, "variation_embolden" , PROPERTY_HINT_RANGE, "-2,2,0.01" ), 0)); |
| 1276 | options_variations.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "variation_face_index" ), 0)); |
| 1277 | options_variations.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::TRANSFORM2D, "variation_transform" ), Transform2D())); |
| 1278 | |
| 1279 | // Root layout |
| 1280 | |
| 1281 | VBoxContainer *root_vb = memnew(VBoxContainer); |
| 1282 | add_child(root_vb); |
| 1283 | |
| 1284 | main_pages = memnew(TabContainer); |
| 1285 | main_pages->set_tab_alignment(TabBar::ALIGNMENT_CENTER); |
| 1286 | main_pages->set_v_size_flags(Control::SIZE_EXPAND_FILL); |
| 1287 | main_pages->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1288 | main_pages->set_theme_type_variation("TabContainerOdd" ); |
| 1289 | root_vb->add_child(main_pages); |
| 1290 | |
| 1291 | label_warn = memnew(Label); |
| 1292 | label_warn->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); |
| 1293 | label_warn->set_text("" ); |
| 1294 | root_vb->add_child(label_warn); |
| 1295 | label_warn->hide(); |
| 1296 | |
| 1297 | // Page 1 layout: Rendering Options |
| 1298 | |
| 1299 | VBoxContainer *page1_vb = memnew(VBoxContainer); |
| 1300 | page1_vb->set_name(TTR("Rendering Options" )); |
| 1301 | main_pages->add_child(page1_vb); |
| 1302 | |
| 1303 | page1_description = memnew(Label); |
| 1304 | page1_description->set_text(TTR("Select font rendering options, fallback font, and metadata override:" )); |
| 1305 | page1_description->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1306 | page1_vb->add_child(page1_description); |
| 1307 | |
| 1308 | HSplitContainer *page1_hb = memnew(HSplitContainer); |
| 1309 | page1_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL); |
| 1310 | page1_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1311 | page1_vb->add_child(page1_hb); |
| 1312 | |
| 1313 | VBoxContainer *page1_lbl_vb = memnew(VBoxContainer); |
| 1314 | page1_lbl_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL); |
| 1315 | page1_lbl_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1316 | page1_hb->add_child(page1_lbl_vb); |
| 1317 | |
| 1318 | font_name_label = memnew(Label); |
| 1319 | font_name_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); |
| 1320 | font_name_label->set_clip_text(true); |
| 1321 | font_name_label->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1322 | page1_lbl_vb->add_child(font_name_label); |
| 1323 | |
| 1324 | font_preview_label = memnew(Label); |
| 1325 | font_preview_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); |
| 1326 | font_preview_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER); |
| 1327 | font_preview_label->set_autowrap_mode(TextServer::AUTOWRAP_ARBITRARY); |
| 1328 | font_preview_label->set_clip_text(true); |
| 1329 | font_preview_label->set_v_size_flags(Control::SIZE_EXPAND_FILL); |
| 1330 | font_preview_label->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1331 | page1_lbl_vb->add_child(font_preview_label); |
| 1332 | |
| 1333 | inspector_general = memnew(EditorInspector); |
| 1334 | inspector_general->set_v_size_flags(Control::SIZE_EXPAND_FILL); |
| 1335 | inspector_general->set_custom_minimum_size(Size2(300 * EDSCALE, 250 * EDSCALE)); |
| 1336 | inspector_general->connect("property_edited" , callable_mp(this, &DynamicFontImportSettings::_main_prop_changed)); |
| 1337 | page1_hb->add_child(inspector_general); |
| 1338 | |
| 1339 | // Page 2 layout: Configurations |
| 1340 | VBoxContainer *page2_vb = memnew(VBoxContainer); |
| 1341 | page2_vb->set_name(TTR("Pre-render Configurations" )); |
| 1342 | main_pages->add_child(page2_vb); |
| 1343 | |
| 1344 | page2_description = memnew(Label); |
| 1345 | page2_description->set_text(TTR("Add font size, and variation coordinates, and select glyphs to pre-render:" )); |
| 1346 | page2_description->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1347 | page2_description->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART); |
| 1348 | page2_vb->add_child(page2_description); |
| 1349 | |
| 1350 | HSplitContainer *page2_hb = memnew(HSplitContainer); |
| 1351 | page2_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL); |
| 1352 | page2_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1353 | page2_vb->add_child(page2_hb); |
| 1354 | |
| 1355 | VBoxContainer *page2_side_vb = memnew(VBoxContainer); |
| 1356 | page2_hb->add_child(page2_side_vb); |
| 1357 | |
| 1358 | HBoxContainer *page2_hb_vars = memnew(HBoxContainer); |
| 1359 | page2_side_vb->add_child(page2_hb_vars); |
| 1360 | |
| 1361 | label_vars = memnew(Label); |
| 1362 | page2_hb_vars->add_child(label_vars); |
| 1363 | label_vars->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); |
| 1364 | label_vars->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1365 | label_vars->set_text(TTR("Configuration:" )); |
| 1366 | |
| 1367 | add_var = memnew(Button); |
| 1368 | page2_hb_vars->add_child(add_var); |
| 1369 | add_var->set_tooltip_text(TTR("Add configuration" )); |
| 1370 | add_var->connect("pressed" , callable_mp(this, &DynamicFontImportSettings::_variation_add)); |
| 1371 | |
| 1372 | vars_list = memnew(Tree); |
| 1373 | page2_side_vb->add_child(vars_list); |
| 1374 | vars_list->set_custom_minimum_size(Size2(300 * EDSCALE, 0)); |
| 1375 | vars_list->set_hide_root(true); |
| 1376 | vars_list->set_columns(2); |
| 1377 | vars_list->set_column_expand(0, true); |
| 1378 | vars_list->set_column_custom_minimum_width(0, 80 * EDSCALE); |
| 1379 | vars_list->set_column_expand(1, false); |
| 1380 | vars_list->set_column_custom_minimum_width(1, 50 * EDSCALE); |
| 1381 | vars_list->connect("item_selected" , callable_mp(this, &DynamicFontImportSettings::_variation_selected)); |
| 1382 | vars_list->connect("button_clicked" , callable_mp(this, &DynamicFontImportSettings::_variation_remove)); |
| 1383 | vars_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); |
| 1384 | |
| 1385 | inspector_vars = memnew(EditorInspector); |
| 1386 | inspector_vars->set_v_size_flags(Control::SIZE_EXPAND_FILL); |
| 1387 | inspector_vars->connect("property_edited" , callable_mp(this, &DynamicFontImportSettings::_variation_changed)); |
| 1388 | page2_side_vb->add_child(inspector_vars); |
| 1389 | |
| 1390 | VBoxContainer *preload_pages_vb = memnew(VBoxContainer); |
| 1391 | page2_hb->add_child(preload_pages_vb); |
| 1392 | |
| 1393 | preload_pages = memnew(TabContainer); |
| 1394 | preload_pages->set_tab_alignment(TabBar::ALIGNMENT_CENTER); |
| 1395 | preload_pages->set_v_size_flags(Control::SIZE_EXPAND_FILL); |
| 1396 | preload_pages->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1397 | preload_pages_vb->add_child(preload_pages); |
| 1398 | |
| 1399 | HBoxContainer *gl_hb = memnew(HBoxContainer); |
| 1400 | preload_pages_vb->add_child(gl_hb); |
| 1401 | gl_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1402 | |
| 1403 | label_glyphs = memnew(Label); |
| 1404 | gl_hb->add_child(label_glyphs); |
| 1405 | label_glyphs->set_text(vformat(TTR("Preloaded glyphs: %d" ), 0)); |
| 1406 | label_glyphs->set_custom_minimum_size(Size2(50 * EDSCALE, 0)); |
| 1407 | |
| 1408 | Button *btn_clear = memnew(Button); |
| 1409 | gl_hb->add_child(btn_clear); |
| 1410 | btn_clear->set_text(TTR("Clear Glyph List" )); |
| 1411 | btn_clear->connect("pressed" , callable_mp(this, &DynamicFontImportSettings::_glyph_clear)); |
| 1412 | |
| 1413 | VBoxContainer *page2_0_vb = memnew(VBoxContainer); |
| 1414 | page2_0_vb->set_name(TTR("Glyphs from the Translations" )); |
| 1415 | preload_pages->add_child(page2_0_vb); |
| 1416 | |
| 1417 | page2_0_description = memnew(Label); |
| 1418 | page2_0_description->set_text(TTR("Select translations to add all required glyphs to pre-render list:" )); |
| 1419 | page2_0_description->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1420 | page2_0_description->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART); |
| 1421 | page2_0_vb->add_child(page2_0_description); |
| 1422 | |
| 1423 | locale_tree = memnew(Tree); |
| 1424 | page2_0_vb->add_child(locale_tree); |
| 1425 | locale_tree->set_columns(1); |
| 1426 | locale_tree->set_hide_root(true); |
| 1427 | locale_tree->set_column_expand(0, true); |
| 1428 | locale_tree->connect("item_activated" , callable_mp(this, &DynamicFontImportSettings::_locale_edited)); |
| 1429 | locale_tree->set_column_custom_minimum_width(0, 120 * EDSCALE); |
| 1430 | locale_tree->set_v_size_flags(Control::SIZE_EXPAND_FILL); |
| 1431 | locale_root = locale_tree->create_item(); |
| 1432 | |
| 1433 | HBoxContainer *locale_hb = memnew(HBoxContainer); |
| 1434 | page2_0_vb->add_child(locale_hb); |
| 1435 | locale_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1436 | |
| 1437 | btn_fill_locales = memnew(Button); |
| 1438 | locale_hb->add_child(btn_fill_locales); |
| 1439 | btn_fill_locales->set_text(TTR("Shape all Strings in the Translations and Add Glyphs" )); |
| 1440 | btn_fill_locales->connect("pressed" , callable_mp(this, &DynamicFontImportSettings::_process_locales)); |
| 1441 | |
| 1442 | // Page 2.1 layout: Text to select glyphs |
| 1443 | VBoxContainer *page2_1_vb = memnew(VBoxContainer); |
| 1444 | page2_1_vb->set_name(TTR("Glyphs from the Text" )); |
| 1445 | preload_pages->add_child(page2_1_vb); |
| 1446 | |
| 1447 | page2_1_description = memnew(Label); |
| 1448 | page2_1_description->set_text(TTR("Enter a text and select OpenType features to shape and add all required glyphs to pre-render list:" )); |
| 1449 | page2_1_description->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1450 | page2_1_description->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART); |
| 1451 | page2_1_vb->add_child(page2_1_description); |
| 1452 | |
| 1453 | HSplitContainer *page2_1_hb = memnew(HSplitContainer); |
| 1454 | page2_1_vb->add_child(page2_1_hb); |
| 1455 | page2_1_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1456 | page2_1_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL); |
| 1457 | |
| 1458 | inspector_text = memnew(EditorInspector); |
| 1459 | |
| 1460 | inspector_text->set_v_size_flags(Control::SIZE_EXPAND_FILL); |
| 1461 | inspector_text->set_custom_minimum_size(Size2(300 * EDSCALE, 250 * EDSCALE)); |
| 1462 | inspector_text->connect("property_edited" , callable_mp(this, &DynamicFontImportSettings::_change_text_opts)); |
| 1463 | page2_1_hb->add_child(inspector_text); |
| 1464 | |
| 1465 | text_edit = memnew(TextEdit); |
| 1466 | page2_1_hb->add_child(text_edit); |
| 1467 | text_edit->set_v_size_flags(Control::SIZE_EXPAND_FILL); |
| 1468 | text_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1469 | |
| 1470 | HBoxContainer *text_hb = memnew(HBoxContainer); |
| 1471 | page2_1_vb->add_child(text_hb); |
| 1472 | text_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1473 | |
| 1474 | btn_fill = memnew(Button); |
| 1475 | text_hb->add_child(btn_fill); |
| 1476 | btn_fill->set_text(TTR("Shape Text and Add Glyphs" )); |
| 1477 | btn_fill->connect("pressed" , callable_mp(this, &DynamicFontImportSettings::_glyph_text_selected)); |
| 1478 | |
| 1479 | // Page 2.2 layout: Character map |
| 1480 | VBoxContainer *page2_2_vb = memnew(VBoxContainer); |
| 1481 | page2_2_vb->set_name(TTR("Glyphs from the Character Map" )); |
| 1482 | preload_pages->add_child(page2_2_vb); |
| 1483 | |
| 1484 | page2_2_description = memnew(Label); |
| 1485 | page2_2_description->set_text(TTR("Add or remove glyphs from the character map to pre-render list:\nNote: 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." )); |
| 1486 | page2_2_description->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1487 | page2_2_description->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART); |
| 1488 | page2_2_vb->add_child(page2_2_description); |
| 1489 | |
| 1490 | HSplitContainer *glyphs_split = memnew(HSplitContainer); |
| 1491 | glyphs_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); |
| 1492 | glyphs_split->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1493 | page2_2_vb->add_child(glyphs_split); |
| 1494 | |
| 1495 | glyph_table = memnew(Tree); |
| 1496 | glyphs_split->add_child(glyph_table); |
| 1497 | glyph_table->set_custom_minimum_size(Size2((30 * 16 + 100) * EDSCALE, 0)); |
| 1498 | glyph_table->set_columns(17); |
| 1499 | glyph_table->set_column_expand(0, false); |
| 1500 | glyph_table->set_hide_root(true); |
| 1501 | glyph_table->set_allow_reselect(true); |
| 1502 | glyph_table->set_select_mode(Tree::SELECT_SINGLE); |
| 1503 | glyph_table->connect("item_activated" , callable_mp(this, &DynamicFontImportSettings::_glyph_selected)); |
| 1504 | glyph_table->set_column_titles_visible(true); |
| 1505 | for (int i = 0; i < 16; i++) { |
| 1506 | glyph_table->set_column_title(i + 1, String::num_int64(i, 16)); |
| 1507 | } |
| 1508 | glyph_table->add_theme_style_override("selected" , glyph_table->get_theme_stylebox(SNAME("panel" ))); |
| 1509 | glyph_table->add_theme_style_override("selected_focus" , glyph_table->get_theme_stylebox(SNAME("panel" ))); |
| 1510 | glyph_table->add_theme_constant_override("h_separation" , 0); |
| 1511 | glyph_table->set_h_size_flags(Control::SIZE_EXPAND_FILL); |
| 1512 | glyph_table->set_v_size_flags(Control::SIZE_EXPAND_FILL); |
| 1513 | |
| 1514 | glyph_tree = memnew(Tree); |
| 1515 | glyphs_split->add_child(glyph_tree); |
| 1516 | glyph_tree->set_custom_minimum_size(Size2(300 * EDSCALE, 0)); |
| 1517 | glyph_tree->set_columns(2); |
| 1518 | glyph_tree->set_hide_root(true); |
| 1519 | glyph_tree->set_column_expand(0, false); |
| 1520 | glyph_tree->set_column_expand(1, true); |
| 1521 | glyph_tree->set_column_custom_minimum_width(0, 120 * EDSCALE); |
| 1522 | glyph_tree->connect("item_activated" , callable_mp(this, &DynamicFontImportSettings::_range_edited)); |
| 1523 | glyph_tree->connect("item_selected" , callable_mp(this, &DynamicFontImportSettings::_range_selected)); |
| 1524 | glyph_tree->set_v_size_flags(Control::SIZE_EXPAND_FILL); |
| 1525 | glyph_root = glyph_tree->create_item(); |
| 1526 | for (int i = 0; !unicode_ranges[i].name.is_empty(); i++) { |
| 1527 | _add_glyph_range_item(unicode_ranges[i].start, unicode_ranges[i].end, unicode_ranges[i].name); |
| 1528 | } |
| 1529 | |
| 1530 | // Common |
| 1531 | |
| 1532 | import_settings_data.instantiate(); |
| 1533 | import_settings_data->owner = this; |
| 1534 | |
| 1535 | set_ok_button_text(TTR("Reimport" )); |
| 1536 | set_cancel_button_text(TTR("Close" )); |
| 1537 | } |
| 1538 | |