diff --git a/scene/resources/font/dynamic_font.cpp b/modules/freetype/dynamic_font.cpp similarity index 99% rename from scene/resources/font/dynamic_font.cpp rename to modules/freetype/dynamic_font.cpp index 817b402..c7860ed 100644 --- a/scene/resources/font/dynamic_font.cpp +++ b/modules/freetype/dynamic_font.cpp @@ -28,8 +28,6 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "modules/modules_enabled.gen.h" // For freetype. -#ifdef MODULE_FREETYPE_ENABLED #include "dynamic_font.h" @@ -1462,5 +1460,3 @@ String ResourceFormatLoaderDynamicFont::get_resource_type(const String &p_path) } return ""; } - -#endif diff --git a/scene/resources/font/dynamic_font.h b/modules/freetype/dynamic_font.h similarity index 98% rename from scene/resources/font/dynamic_font.h rename to modules/freetype/dynamic_font.h index 61db650..0f96ac1 100644 --- a/scene/resources/font/dynamic_font.h +++ b/modules/freetype/dynamic_font.h @@ -30,9 +30,6 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "modules/modules_enabled.gen.h" // For freetype. -#ifdef MODULE_FREETYPE_ENABLED - #include "core/io/resource_loader.h" #include "core/os/mutex.h" #include "core/os/thread_safe.h" @@ -397,6 +394,4 @@ public: virtual String get_resource_type(const String &p_path) const; }; -#endif // MODULE_FREETYPE_ENABLED - #endif // DYNAMIC_FONT_H diff --git a/modules/freetype/register_types.cpp b/modules/freetype/register_types.cpp index a86d79f..bc9acd8 100644 --- a/modules/freetype/register_types.cpp +++ b/modules/freetype/register_types.cpp @@ -30,6 +30,29 @@ #include "register_types.h" -void register_freetype_types(ModuleRegistrationLevel p_level) {} +#include "dynamic_font.h" -void unregister_freetype_types(ModuleRegistrationLevel p_level) {} +static Ref resource_loader_dynamic_font; + +void register_freetype_types(ModuleRegistrationLevel p_level) { + if (p_level == MODULE_REGISTRATION_LEVEL_SINGLETON) { + resource_loader_dynamic_font.instance(); + ResourceLoader::add_resource_format_loader(resource_loader_dynamic_font); + } + + if (p_level == MODULE_REGISTRATION_LEVEL_SCENE) { + ClassDB::register_class(); + ClassDB::register_class(); + + DynamicFont::initialize_dynamic_fonts(); + } +} + +void unregister_freetype_types(ModuleRegistrationLevel p_level) { + if (p_level == MODULE_REGISTRATION_LEVEL_SINGLETON) { + ResourceLoader::remove_resource_format_loader(resource_loader_dynamic_font); + resource_loader_dynamic_font.unref(); + + DynamicFont::finish_dynamic_fonts(); + } +} diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index b9f6b43..7e3a265 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -41,13 +41,11 @@ #include "core/string/print_string.h" #include "core/variant/variant_parser.h" #include "main/input_default.h" -#include "modules/modules_enabled.gen.h" // For freetype. #include "node.h" #include "scene/animation/scene_tree_tween.h" #include "scene/debugger/script_debugger_remote.h" #include "scene/main/control.h" #include "scene/main/scene_string_names.h" -#include "scene/resources/font/dynamic_font.h" #include "scene/resources/material/material.h" #include "scene/resources/material/shader_material.h" #include "scene/resources/mesh/mesh.h" @@ -57,6 +55,12 @@ #include "servers/physics_2d_server.h" #include "viewport.h" +#include "modules/modules_enabled.gen.h" // For freetype. + +#ifdef MODULE_FREETYPE_ENABLED +#include "modules/freetype/dynamic_font.h" +#endif + #include #include diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 2080e9a..2bf0364 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -129,7 +129,6 @@ #include "scene/resources/shapes_2d/concave_polygon_shape_2d.h" #include "scene/resources/shapes_2d/convex_polygon_shape_2d.h" #include "scene/resources/default_theme/default_theme.h" -#include "scene/resources/font/dynamic_font.h" #include "scene/resources/gradient.h" #include "scene/resources/mesh/immediate_mesh.h" #include "scene/resources/shapes_2d/line_shape_2d.h" @@ -158,10 +157,6 @@ 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; @@ -177,11 +172,6 @@ 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); @@ -441,13 +431,6 @@ 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(); ClassDB::register_class(); @@ -535,13 +518,6 @@ void initialize_theme() { 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();