Преглед изворни кода

add font_size method to FontResource

mikymod пре 12 година
родитељ
комит
caadd5c82f
2 измењених фајлова са 13 додато и 4 уклоњено
  1. 3 1
      engine/resource/FontResource.cpp
  2. 10 3
      engine/resource/FontResource.h

+ 3 - 1
engine/resource/FontResource.cpp

@@ -77,6 +77,7 @@ void compile(Filesystem& fs, const char* resource_path, File* out_file)
 	JSONElement mat = root.key("material");
 	JSONElement count = root.key("count");
 	JSONElement size = root.key("size");
+	JSONElement font_size = root.key("font_size");
 	JSONElement glyphs = root.key("glyphs");
 
 	DynamicString material_name;
@@ -97,7 +98,8 @@ void compile(Filesystem& fs, const char* resource_path, File* out_file)
 
 	h.material.id = hash::murmur2_64(material_name.c_str(), string::strlen(material_name.c_str()), 0);
 	h.num_glyphs = m_glyphs.size();
-	h.size = size.to_int();
+	h.texture_size = size.to_int();
+	h.font_size = font_size.to_int();
 
 	out_file->write((char*) &h, sizeof(FontHeader));
 

+ 10 - 3
engine/resource/FontResource.h

@@ -72,7 +72,8 @@ struct FontHeader
 {
 	ResourceId material;
 	uint32_t num_glyphs;
-	uint32_t size;			// Font texture size -- pow of 2
+	uint32_t texture_size;			// Font texture size -- pow of 2
+	uint32_t font_size;
 };
 
 //-----------------------------------------------------------------------------
@@ -140,9 +141,15 @@ public:
 	}
 
 	//-----------------------------------------------------------------------------
-	uint32_t size() const
+	uint32_t texture_size() const
 	{
-		return ((FontHeader*)this)->size;
+		return ((FontHeader*)this)->texture_size;
+	}
+
+	//-----------------------------------------------------------------------------
+	uint32_t font_size() const
+	{
+		return ((FontHeader*)this)->font_size;
 	}
 
 	//-----------------------------------------------------------------------------