Browse Source

I have no idea why this commit fixes #15392

(cherry picked from commit 8daf5491ab6bc60434e4d952830bdd258eaf0e53)
Juan Linietsky 7 years ago
parent
commit
2c47116a3c
2 changed files with 11 additions and 14 deletions
  1. 2 7
      scene/resources/dynamic_font.cpp
  2. 9 7
      scene/resources/dynamic_font.h

+ 2 - 7
scene/resources/dynamic_font.cpp

@@ -34,13 +34,7 @@
 
 bool DynamicFontData::CacheID::operator<(CacheID right) const {
 
-	if (size < right.size)
-		return true;
-	if (mipmaps != right.mipmaps)
-		return right.mipmaps;
-	if (filter != right.filter)
-		return right.filter;
-	return false;
+	return key < right.key;
 }
 
 Ref<DynamicFontAtSize> DynamicFontData::_get_dynamic_font_at_size(CacheID p_id) {
@@ -616,6 +610,7 @@ DynamicFontAtSize::~DynamicFontAtSize() {
 		FT_Done_FreeType(library);
 	}
 	font->size_cache.erase(id);
+	font.unref();
 }
 
 /////////////////////////

+ 9 - 7
scene/resources/dynamic_font.h

@@ -48,15 +48,17 @@ class DynamicFontData : public Resource {
 public:
 	struct CacheID {
 
-		int size;
-		bool mipmaps;
-		bool filter;
-
+		union {
+			struct {
+				uint32_t size : 16;
+				bool mipmaps : 1;
+				bool filter : 1;
+			};
+			uint32_t key;
+		};
 		bool operator<(CacheID right) const;
 		CacheID() {
-			size = 16;
-			mipmaps = false;
-			filter = false;
+			key = 0;
 		}
 	};