Skip to content

Commit

Permalink
Merge pull request #51046 from aaronfranke/3.x-freetype
Browse files Browse the repository at this point in the history
[3.x] Fix building with the FreeType module disabled
  • Loading branch information
akien-mga authored Jul 30, 2021
2 parents 896e7a4 + e47018f commit 7075bb6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions scene/main/scene_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down
12 changes: 10 additions & 2 deletions scene/register_scene_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@
static Ref<ResourceFormatSaverText> resource_saver_text;
static Ref<ResourceFormatLoaderText> resource_loader_text;

#ifdef MODULE_FREETYPE_ENABLED
static Ref<ResourceFormatLoaderDynamicFont> resource_loader_dynamic_font;
#endif // MODULE_FREETYPE_ENABLED

static Ref<ResourceFormatLoaderStreamTexture> resource_loader_stream_texture;
static Ref<ResourceFormatLoaderTextureLayered> resource_loader_texture_layered;
Expand All @@ -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);
Expand Down Expand Up @@ -681,10 +685,12 @@ void register_scene_types() {

ClassDB::register_class<TextFile>();

#ifdef MODULE_FREETYPE_ENABLED
ClassDB::register_class<DynamicFontData>();
ClassDB::register_class<DynamicFont>();

DynamicFont::initialize_dynamic_fonts();
#endif // MODULE_FREETYPE_ENABLED

ClassDB::register_virtual_class<StyleBox>();
ClassDB::register_class<StyleBoxEmpty>();
Expand Down Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions scene/resources/dynamic_font.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,6 @@ class ResourceFormatLoaderDynamicFont : public ResourceFormatLoader {
virtual String get_resource_type(const String &p_path) const;
};

#endif
#endif // MODULE_FREETYPE_ENABLED

#endif
#endif // DYNAMIC_FONT_H

0 comments on commit 7075bb6

Please sign in to comment.