From e47018ffa4aa7598f785a2f3afc8914cc70ac5d7 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 29 Jul 2021 21:47:16 -0500 Subject: [PATCH] [3.x] Fix building with the FreeType module disabled --- scene/main/scene_tree.cpp | 4 ++++ scene/register_scene_types.cpp | 12 ++++++++++-- scene/resources/dynamic_font.h | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 5207ce1f461..ae6db582142 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -30,6 +30,8 @@ #include "scene_tree.h" +#include "modules/modules_enabled.gen.h" + #include "core/io/marshalls.h" #include "core/io/resource_loader.h" #include "core/message_queue.h" @@ -493,10 +495,12 @@ bool SceneTree::iteration(float p_time) { } void SceneTree::_update_font_oversampling(float p_ratio) { +#ifdef MODULE_FREETYPE_ENABLED if (use_font_oversampling) { DynamicFontAtSize::font_oversampling = p_ratio; DynamicFont::update_oversampling(); } +#endif // MODULE_FREETYPE_ENABLED } bool SceneTree::idle(float p_time) { diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 19b84a27d63..3949b76de8a 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -218,7 +218,9 @@ static Ref resource_saver_text; static Ref resource_loader_text; +#ifdef MODULE_FREETYPE_ENABLED static Ref resource_loader_dynamic_font; +#endif // MODULE_FREETYPE_ENABLED static Ref resource_loader_stream_texture; static Ref resource_loader_texture_layered; @@ -235,8 +237,10 @@ void register_scene_types() { Node::init_node_hrcr(); +#ifdef MODULE_FREETYPE_ENABLED resource_loader_dynamic_font.instance(); ResourceLoader::add_resource_format_loader(resource_loader_dynamic_font); +#endif // MODULE_FREETYPE_ENABLED resource_loader_stream_texture.instance(); ResourceLoader::add_resource_format_loader(resource_loader_stream_texture); @@ -681,10 +685,12 @@ void register_scene_types() { ClassDB::register_class(); +#ifdef MODULE_FREETYPE_ENABLED ClassDB::register_class(); ClassDB::register_class(); DynamicFont::initialize_dynamic_fonts(); +#endif // MODULE_FREETYPE_ENABLED ClassDB::register_virtual_class(); ClassDB::register_class(); @@ -784,17 +790,19 @@ void register_scene_types() { void unregister_scene_types() { clear_default_theme(); +#ifdef MODULE_FREETYPE_ENABLED ResourceLoader::remove_resource_format_loader(resource_loader_dynamic_font); resource_loader_dynamic_font.unref(); + DynamicFont::finish_dynamic_fonts(); +#endif // MODULE_FREETYPE_ENABLED + ResourceLoader::remove_resource_format_loader(resource_loader_texture_layered); resource_loader_texture_layered.unref(); ResourceLoader::remove_resource_format_loader(resource_loader_stream_texture); resource_loader_stream_texture.unref(); - DynamicFont::finish_dynamic_fonts(); - ResourceSaver::remove_resource_format_saver(resource_saver_text); resource_saver_text.unref(); diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h index 2cd56676c72..591e9aeadac 100644 --- a/scene/resources/dynamic_font.h +++ b/scene/resources/dynamic_font.h @@ -307,6 +307,6 @@ public: virtual String get_resource_type(const String &p_path) const; }; -#endif +#endif // MODULE_FREETYPE_ENABLED -#endif +#endif // DYNAMIC_FONT_H