editor_fonts.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. /*************************************************************************/
  2. /* editor_fonts.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  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. #include "editor_fonts.h"
  31. #include "builtin_fonts.gen.h"
  32. #include "core/io/dir_access.h"
  33. #include "editor/editor_scale.h"
  34. #include "editor/editor_settings.h"
  35. #include "scene/resources/default_theme/default_theme.h"
  36. #include "scene/resources/font.h"
  37. Ref<FontFile> load_external_font(const String &p_path, TextServer::Hinting p_hinting, TextServer::FontAntialiasing p_aa, bool p_autohint, TextServer::SubpixelPositioning p_font_subpixel_positioning, bool p_msdf = false, TypedArray<Font> *r_fallbacks = nullptr) {
  38. Ref<FontFile> font;
  39. font.instantiate();
  40. Vector<uint8_t> data = FileAccess::get_file_as_array(p_path);
  41. font->set_data(data);
  42. font->set_multichannel_signed_distance_field(p_msdf);
  43. font->set_antialiasing(p_aa);
  44. font->set_hinting(p_hinting);
  45. font->set_force_autohinter(p_autohint);
  46. font->set_subpixel_positioning(p_font_subpixel_positioning);
  47. if (r_fallbacks != nullptr) {
  48. r_fallbacks->push_back(font);
  49. }
  50. return font;
  51. }
  52. Ref<FontFile> load_internal_font(const uint8_t *p_data, size_t p_size, TextServer::Hinting p_hinting, TextServer::FontAntialiasing p_aa, bool p_autohint, TextServer::SubpixelPositioning p_font_subpixel_positioning, bool p_msdf = false, TypedArray<Font> *r_fallbacks = nullptr) {
  53. Ref<FontFile> font;
  54. font.instantiate();
  55. font->set_data_ptr(p_data, p_size);
  56. font->set_multichannel_signed_distance_field(p_msdf);
  57. font->set_antialiasing(p_aa);
  58. font->set_hinting(p_hinting);
  59. font->set_force_autohinter(p_autohint);
  60. font->set_subpixel_positioning(p_font_subpixel_positioning);
  61. if (r_fallbacks != nullptr) {
  62. r_fallbacks->push_back(font);
  63. }
  64. return font;
  65. }
  66. Ref<FontVariation> make_bold_font(const Ref<Font> &p_font, double p_embolden, TypedArray<Font> *r_fallbacks = nullptr) {
  67. Ref<FontVariation> font_var;
  68. font_var.instantiate();
  69. font_var->set_base_font(p_font);
  70. font_var->set_variation_embolden(p_embolden);
  71. if (r_fallbacks != nullptr) {
  72. r_fallbacks->push_back(font_var);
  73. }
  74. return font_var;
  75. }
  76. void editor_register_fonts(Ref<Theme> p_theme) {
  77. Ref<DirAccess> dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  78. TextServer::FontAntialiasing font_antialiasing = (TextServer::FontAntialiasing)(int)EDITOR_GET("interface/editor/font_antialiasing");
  79. int font_hinting_setting = (int)EDITOR_GET("interface/editor/font_hinting");
  80. TextServer::SubpixelPositioning font_subpixel_positioning = (TextServer::SubpixelPositioning)(int)EDITOR_GET("interface/editor/font_subpixel_positioning");
  81. TextServer::Hinting font_hinting;
  82. TextServer::Hinting font_mono_hinting;
  83. switch (font_hinting_setting) {
  84. case 0:
  85. // The "Auto" setting uses the setting that best matches the OS' font rendering:
  86. // - macOS doesn't use font hinting.
  87. // - Windows uses ClearType, which is in between "Light" and "Normal" hinting.
  88. // - Linux has configurable font hinting, but most distributions including Ubuntu default to "Light".
  89. #ifdef MACOS_ENABLED
  90. font_hinting = TextServer::HINTING_NONE;
  91. font_mono_hinting = TextServer::HINTING_NONE;
  92. #else
  93. font_hinting = TextServer::HINTING_LIGHT;
  94. font_mono_hinting = TextServer::HINTING_LIGHT;
  95. #endif
  96. break;
  97. case 1:
  98. font_hinting = TextServer::HINTING_NONE;
  99. font_mono_hinting = TextServer::HINTING_NONE;
  100. break;
  101. case 2:
  102. font_hinting = TextServer::HINTING_LIGHT;
  103. font_mono_hinting = TextServer::HINTING_LIGHT;
  104. break;
  105. default:
  106. font_hinting = TextServer::HINTING_NORMAL;
  107. font_mono_hinting = TextServer::HINTING_LIGHT;
  108. break;
  109. }
  110. // Load built-in fonts.
  111. const int default_font_size = int(EDITOR_GET("interface/editor/main_font_size")) * EDSCALE;
  112. const float embolden_strength = 0.6;
  113. Ref<Font> default_font = load_internal_font(_font_NotoSans_Regular, _font_NotoSans_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false);
  114. Ref<Font> default_font_msdf = load_internal_font(_font_NotoSans_Regular, _font_NotoSans_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, true);
  115. TypedArray<Font> fallbacks;
  116. Ref<FontFile> arabic_font = load_internal_font(_font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks);
  117. Ref<FontFile> bengali_font = load_internal_font(_font_NotoSansBengaliUI_Regular, _font_NotoSansBengaliUI_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks);
  118. Ref<FontFile> devanagari_font = load_internal_font(_font_NotoSansDevanagariUI_Regular, _font_NotoSansDevanagariUI_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks);
  119. Ref<FontFile> georgian_font = load_internal_font(_font_NotoSansGeorgian_Regular, _font_NotoSansGeorgian_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks);
  120. Ref<FontFile> hebrew_font = load_internal_font(_font_NotoSansHebrew_Regular, _font_NotoSansHebrew_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks);
  121. Ref<FontFile> malayalam_font = load_internal_font(_font_NotoSansMalayalamUI_Regular, _font_NotoSansMalayalamUI_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks);
  122. Ref<FontFile> oriya_font = load_internal_font(_font_NotoSansOriyaUI_Regular, _font_NotoSansOriyaUI_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks);
  123. Ref<FontFile> sinhala_font = load_internal_font(_font_NotoSansSinhalaUI_Regular, _font_NotoSansSinhalaUI_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks);
  124. Ref<FontFile> tamil_font = load_internal_font(_font_NotoSansTamilUI_Regular, _font_NotoSansTamilUI_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks);
  125. Ref<FontFile> telugu_font = load_internal_font(_font_NotoSansTeluguUI_Regular, _font_NotoSansTeluguUI_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks);
  126. Ref<FontFile> thai_font = load_internal_font(_font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks);
  127. Ref<FontFile> fallback_font = load_internal_font(_font_DroidSansFallback, _font_DroidSansFallback_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks);
  128. Ref<FontFile> japanese_font = load_internal_font(_font_DroidSansJapanese, _font_DroidSansJapanese_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks);
  129. default_font->set_fallbacks(fallbacks);
  130. default_font_msdf->set_fallbacks(fallbacks);
  131. Ref<FontFile> default_font_bold = load_internal_font(_font_NotoSans_Bold, _font_NotoSans_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false);
  132. Ref<FontFile> default_font_bold_msdf = load_internal_font(_font_NotoSans_Bold, _font_NotoSans_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, true);
  133. TypedArray<Font> fallbacks_bold;
  134. Ref<FontFile> arabic_font_bold = load_internal_font(_font_NotoNaskhArabicUI_Bold, _font_NotoNaskhArabicUI_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold);
  135. Ref<FontFile> bengali_font_bold = load_internal_font(_font_NotoSansBengaliUI_Bold, _font_NotoSansBengaliUI_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold);
  136. Ref<FontFile> devanagari_font_bold = load_internal_font(_font_NotoSansDevanagariUI_Bold, _font_NotoSansDevanagariUI_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold);
  137. Ref<FontFile> georgian_font_bold = load_internal_font(_font_NotoSansGeorgian_Bold, _font_NotoSansGeorgian_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold);
  138. Ref<FontFile> hebrew_font_bold = load_internal_font(_font_NotoSansHebrew_Bold, _font_NotoSansHebrew_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold);
  139. Ref<FontFile> malayalam_font_bold = load_internal_font(_font_NotoSansMalayalamUI_Bold, _font_NotoSansMalayalamUI_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold);
  140. Ref<FontFile> oriya_font_bold = load_internal_font(_font_NotoSansOriyaUI_Bold, _font_NotoSansOriyaUI_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold);
  141. Ref<FontFile> sinhala_font_bold = load_internal_font(_font_NotoSansSinhalaUI_Bold, _font_NotoSansSinhalaUI_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold);
  142. Ref<FontFile> tamil_font_bold = load_internal_font(_font_NotoSansTamilUI_Bold, _font_NotoSansTamilUI_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold);
  143. Ref<FontFile> telugu_font_bold = load_internal_font(_font_NotoSansTeluguUI_Bold, _font_NotoSansTeluguUI_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold);
  144. Ref<FontFile> thai_font_bold = load_internal_font(_font_NotoSansThaiUI_Bold, _font_NotoSansThaiUI_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, false, &fallbacks_bold);
  145. Ref<FontVariation> fallback_font_bold = make_bold_font(fallback_font, embolden_strength, &fallbacks_bold);
  146. Ref<FontVariation> japanese_font_bold = make_bold_font(japanese_font, embolden_strength, &fallbacks_bold);
  147. default_font_bold->set_fallbacks(fallbacks_bold);
  148. default_font_bold_msdf->set_fallbacks(fallbacks_bold);
  149. Ref<FontFile> default_font_mono = load_internal_font(_font_JetBrainsMono_Regular, _font_JetBrainsMono_Regular_size, font_mono_hinting, font_antialiasing, true, font_subpixel_positioning);
  150. default_font_mono->set_fallbacks(fallbacks);
  151. // Init base font configs and load custom fonts.
  152. String custom_font_path = EDITOR_GET("interface/editor/main_font");
  153. String custom_font_path_bold = EDITOR_GET("interface/editor/main_font_bold");
  154. String custom_font_path_source = EDITOR_GET("interface/editor/code_font");
  155. Ref<FontVariation> default_fc;
  156. default_fc.instantiate();
  157. if (custom_font_path.length() > 0 && dir->file_exists(custom_font_path)) {
  158. Ref<FontFile> custom_font = load_external_font(custom_font_path, font_hinting, font_antialiasing, true, font_subpixel_positioning);
  159. {
  160. TypedArray<Font> fallback_custom;
  161. fallback_custom.push_back(default_font);
  162. custom_font->set_fallbacks(fallback_custom);
  163. }
  164. default_fc->set_base_font(custom_font);
  165. } else {
  166. EditorSettings::get_singleton()->set_manually("interface/editor/main_font", "");
  167. default_fc->set_base_font(default_font);
  168. }
  169. default_fc->set_spacing(TextServer::SPACING_TOP, -EDSCALE);
  170. default_fc->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE);
  171. Ref<FontVariation> default_fc_msdf;
  172. default_fc_msdf.instantiate();
  173. if (custom_font_path.length() > 0 && dir->file_exists(custom_font_path)) {
  174. Ref<FontFile> custom_font = load_external_font(custom_font_path, font_hinting, font_antialiasing, true, font_subpixel_positioning);
  175. {
  176. TypedArray<Font> fallback_custom;
  177. fallback_custom.push_back(default_font_msdf);
  178. custom_font->set_fallbacks(fallback_custom);
  179. }
  180. default_fc_msdf->set_base_font(custom_font);
  181. } else {
  182. EditorSettings::get_singleton()->set_manually("interface/editor/main_font", "");
  183. default_fc_msdf->set_base_font(default_font_msdf);
  184. }
  185. default_fc_msdf->set_spacing(TextServer::SPACING_TOP, -EDSCALE);
  186. default_fc_msdf->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE);
  187. Ref<FontVariation> bold_fc;
  188. bold_fc.instantiate();
  189. if (custom_font_path_bold.length() > 0 && dir->file_exists(custom_font_path_bold)) {
  190. Ref<FontFile> custom_font = load_external_font(custom_font_path_bold, font_hinting, font_antialiasing, true, font_subpixel_positioning);
  191. {
  192. TypedArray<Font> fallback_custom;
  193. fallback_custom.push_back(default_font_bold);
  194. custom_font->set_fallbacks(fallback_custom);
  195. }
  196. bold_fc->set_base_font(custom_font);
  197. } else if (custom_font_path.length() > 0 && dir->file_exists(custom_font_path)) {
  198. Ref<FontFile> custom_font = load_external_font(custom_font_path, font_hinting, font_antialiasing, true, font_subpixel_positioning);
  199. {
  200. TypedArray<Font> fallback_custom;
  201. fallback_custom.push_back(default_font_bold);
  202. custom_font->set_fallbacks(fallback_custom);
  203. }
  204. bold_fc->set_base_font(custom_font);
  205. bold_fc->set_variation_embolden(embolden_strength);
  206. } else {
  207. EditorSettings::get_singleton()->set_manually("interface/editor/main_font_bold", "");
  208. bold_fc->set_base_font(default_font_bold);
  209. }
  210. bold_fc->set_spacing(TextServer::SPACING_TOP, -EDSCALE);
  211. bold_fc->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE);
  212. Ref<FontVariation> bold_fc_msdf;
  213. bold_fc_msdf.instantiate();
  214. if (custom_font_path_bold.length() > 0 && dir->file_exists(custom_font_path_bold)) {
  215. Ref<FontFile> custom_font = load_external_font(custom_font_path_bold, font_hinting, font_antialiasing, true, font_subpixel_positioning);
  216. {
  217. TypedArray<Font> fallback_custom;
  218. fallback_custom.push_back(default_font_bold_msdf);
  219. custom_font->set_fallbacks(fallback_custom);
  220. }
  221. bold_fc_msdf->set_base_font(custom_font);
  222. } else if (custom_font_path.length() > 0 && dir->file_exists(custom_font_path)) {
  223. Ref<FontFile> custom_font = load_external_font(custom_font_path, font_hinting, font_antialiasing, true, font_subpixel_positioning);
  224. {
  225. TypedArray<Font> fallback_custom;
  226. fallback_custom.push_back(default_font_bold_msdf);
  227. custom_font->set_fallbacks(fallback_custom);
  228. }
  229. bold_fc_msdf->set_base_font(custom_font);
  230. bold_fc_msdf->set_variation_embolden(embolden_strength);
  231. } else {
  232. EditorSettings::get_singleton()->set_manually("interface/editor/main_font_bold", "");
  233. bold_fc_msdf->set_base_font(default_font_bold_msdf);
  234. }
  235. bold_fc_msdf->set_spacing(TextServer::SPACING_TOP, -EDSCALE);
  236. bold_fc_msdf->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE);
  237. Ref<FontVariation> mono_fc;
  238. mono_fc.instantiate();
  239. if (custom_font_path_source.length() > 0 && dir->file_exists(custom_font_path_source)) {
  240. Ref<FontFile> custom_font = load_external_font(custom_font_path_source, font_mono_hinting, font_antialiasing, true, font_subpixel_positioning);
  241. {
  242. TypedArray<Font> fallback_custom;
  243. fallback_custom.push_back(default_font_mono);
  244. custom_font->set_fallbacks(fallback_custom);
  245. }
  246. mono_fc->set_base_font(custom_font);
  247. } else {
  248. EditorSettings::get_singleton()->set_manually("interface/editor/code_font", "");
  249. mono_fc->set_base_font(default_font_mono);
  250. }
  251. mono_fc->set_spacing(TextServer::SPACING_TOP, -EDSCALE);
  252. mono_fc->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE);
  253. Ref<FontVariation> mono_other_fc = mono_fc->duplicate();
  254. // Enable contextual alternates (coding ligatures) and custom features for the source editor font.
  255. int ot_mode = EDITOR_GET("interface/editor/code_font_contextual_ligatures");
  256. switch (ot_mode) {
  257. case 1: { // Disable ligatures.
  258. Dictionary ftrs;
  259. ftrs[TS->name_to_tag("calt")] = 0;
  260. mono_fc->set_opentype_features(ftrs);
  261. } break;
  262. case 2: { // Custom.
  263. Vector<String> subtag = String(EDITOR_GET("interface/editor/code_font_custom_opentype_features")).split(",");
  264. Dictionary ftrs;
  265. for (int i = 0; i < subtag.size(); i++) {
  266. Vector<String> subtag_a = subtag[i].split("=");
  267. if (subtag_a.size() == 2) {
  268. ftrs[TS->name_to_tag(subtag_a[0])] = subtag_a[1].to_int();
  269. } else if (subtag_a.size() == 1) {
  270. ftrs[TS->name_to_tag(subtag_a[0])] = 1;
  271. }
  272. }
  273. mono_fc->set_opentype_features(ftrs);
  274. } break;
  275. default: { // Default.
  276. Dictionary ftrs;
  277. ftrs[TS->name_to_tag("calt")] = 1;
  278. mono_fc->set_opentype_features(ftrs);
  279. } break;
  280. }
  281. {
  282. // Disable contextual alternates (coding ligatures).
  283. Dictionary ftrs;
  284. ftrs[TS->name_to_tag("calt")] = 0;
  285. mono_other_fc->set_opentype_features(ftrs);
  286. }
  287. // Use fake bold/italics to style the editor log's `print_rich()` output.
  288. // Use stronger embolden strength to make bold easier to distinguish from regular text.
  289. Ref<FontVariation> mono_other_fc_bold = mono_other_fc->duplicate();
  290. mono_other_fc_bold->set_variation_embolden(0.8);
  291. Ref<FontVariation> mono_other_fc_italic = mono_other_fc->duplicate();
  292. mono_other_fc_italic->set_variation_transform(Transform2D(1.0, 0.2, 0.0, 1.0, 0.0, 0.0));
  293. Ref<FontVariation> mono_other_fc_bold_italic = mono_other_fc->duplicate();
  294. mono_other_fc_bold_italic->set_variation_embolden(0.8);
  295. mono_other_fc_bold_italic->set_variation_transform(Transform2D(1.0, 0.2, 0.0, 1.0, 0.0, 0.0));
  296. Ref<FontVariation> mono_other_fc_mono = mono_other_fc->duplicate();
  297. // Use a different font style to distinguish `[code]` in rich prints.
  298. // This emulates the "faint" styling used in ANSI escape codes by using a slightly thinner font.
  299. mono_other_fc_mono->set_variation_embolden(-0.25);
  300. mono_other_fc_mono->set_variation_transform(Transform2D(1.0, 0.1, 0.0, 1.0, 0.0, 0.0));
  301. Ref<FontVariation> italic_fc = default_fc->duplicate();
  302. italic_fc->set_variation_transform(Transform2D(1.0, 0.2, 0.0, 1.0, 0.0, 0.0));
  303. // Setup theme.
  304. p_theme->set_default_font(default_fc); // Default theme font config.
  305. p_theme->set_default_font_size(default_font_size);
  306. // Main font.
  307. p_theme->set_font("main", "EditorFonts", default_fc);
  308. p_theme->set_font("main_msdf", "EditorFonts", default_fc_msdf);
  309. p_theme->set_font_size("main_size", "EditorFonts", default_font_size);
  310. p_theme->set_font("bold", "EditorFonts", bold_fc);
  311. p_theme->set_font("main_bold_msdf", "EditorFonts", bold_fc_msdf);
  312. p_theme->set_font_size("bold_size", "EditorFonts", default_font_size);
  313. // Title font.
  314. p_theme->set_font("title", "EditorFonts", bold_fc);
  315. p_theme->set_font_size("title_size", "EditorFonts", default_font_size + 1 * EDSCALE);
  316. p_theme->set_font("main_button_font", "EditorFonts", bold_fc);
  317. p_theme->set_font_size("main_button_font_size", "EditorFonts", default_font_size + 1 * EDSCALE);
  318. p_theme->set_font("font", "Label", default_fc);
  319. p_theme->set_type_variation("HeaderSmall", "Label");
  320. p_theme->set_font("font", "HeaderSmall", bold_fc);
  321. p_theme->set_font_size("font_size", "HeaderSmall", default_font_size);
  322. p_theme->set_type_variation("HeaderMedium", "Label");
  323. p_theme->set_font("font", "HeaderMedium", bold_fc);
  324. p_theme->set_font_size("font_size", "HeaderMedium", default_font_size + 1 * EDSCALE);
  325. p_theme->set_type_variation("HeaderLarge", "Label");
  326. p_theme->set_font("font", "HeaderLarge", bold_fc);
  327. p_theme->set_font_size("font_size", "HeaderLarge", default_font_size + 3 * EDSCALE);
  328. // Documentation fonts
  329. p_theme->set_font_size("doc_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE);
  330. p_theme->set_font("doc", "EditorFonts", default_fc);
  331. p_theme->set_font("doc_bold", "EditorFonts", bold_fc);
  332. p_theme->set_font("doc_italic", "EditorFonts", italic_fc);
  333. p_theme->set_font_size("doc_title_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_title_font_size")) * EDSCALE);
  334. p_theme->set_font("doc_title", "EditorFonts", bold_fc);
  335. p_theme->set_font_size("doc_source_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_source_font_size")) * EDSCALE);
  336. p_theme->set_font("doc_source", "EditorFonts", mono_fc);
  337. p_theme->set_font_size("doc_keyboard_size", "EditorFonts", (int(EDITOR_GET("text_editor/help/help_source_font_size")) - 1) * EDSCALE);
  338. p_theme->set_font("doc_keyboard", "EditorFonts", mono_fc);
  339. // Ruler font
  340. p_theme->set_font_size("rulers_size", "EditorFonts", 8 * EDSCALE);
  341. p_theme->set_font("rulers", "EditorFonts", default_fc);
  342. // Rotation widget font
  343. p_theme->set_font_size("rotation_control_size", "EditorFonts", 14 * EDSCALE);
  344. p_theme->set_font("rotation_control", "EditorFonts", default_fc);
  345. // Code font
  346. p_theme->set_font_size("source_size", "EditorFonts", int(EDITOR_GET("interface/editor/code_font_size")) * EDSCALE);
  347. p_theme->set_font("source", "EditorFonts", mono_fc);
  348. p_theme->set_font_size("expression_size", "EditorFonts", (int(EDITOR_GET("interface/editor/code_font_size")) - 1) * EDSCALE);
  349. p_theme->set_font("expression", "EditorFonts", mono_other_fc);
  350. p_theme->set_font_size("output_source_size", "EditorFonts", int(EDITOR_GET("run/output/font_size")) * EDSCALE);
  351. p_theme->set_font("output_source", "EditorFonts", mono_other_fc);
  352. p_theme->set_font("output_source_bold", "EditorFonts", mono_other_fc_bold);
  353. p_theme->set_font("output_source_italic", "EditorFonts", mono_other_fc_italic);
  354. p_theme->set_font("output_source_bold_italic", "EditorFonts", mono_other_fc_bold_italic);
  355. p_theme->set_font("output_source_mono", "EditorFonts", mono_other_fc_mono);
  356. p_theme->set_font_size("status_source_size", "EditorFonts", default_font_size);
  357. p_theme->set_font("status_source", "EditorFonts", mono_other_fc);
  358. }