|
|
@@ -30,10 +30,10 @@
|
|
|
#include "../FontFaceHandle.h"
|
|
|
#include <Rocket/Core/FontDatabase.h>
|
|
|
#include <Rocket/Core/StreamMemory.h>
|
|
|
-//#include "../FontFamily.h"
|
|
|
+#include "FontFamily.h"
|
|
|
#include <Rocket/Core.h>
|
|
|
-//#include "BM_Font.h"
|
|
|
-//#include "FontParser.h"
|
|
|
+#include "BM_Font.h"
|
|
|
+#include "FontParser.h"
|
|
|
|
|
|
namespace Rocket {
|
|
|
namespace Core {
|
|
|
@@ -79,27 +79,27 @@ void FontProvider::Shutdown()
|
|
|
// Adds a new font face to the database, ignoring any family, style and weight information stored in the face itself.
|
|
|
bool FontProvider::LoadFontFace(const String& file_name)
|
|
|
{
|
|
|
-// BM_Font *bm_font = (BM_Font*) instance->LoadFace(file_name);
|
|
|
+ BM_Font *bm_font = (BM_Font*) instance->LoadFace(file_name);
|
|
|
|
|
|
-// if (bm_font == NULL)
|
|
|
-// {
|
|
|
-// Log::Message(Log::LT_ERROR, "Failed to load font face from %s.", file_name.CString());
|
|
|
-// return false;
|
|
|
-// }
|
|
|
+ if (bm_font == NULL)
|
|
|
+ {
|
|
|
+ Log::Message(Log::LT_ERROR, "Failed to load font face from %s.", file_name.CString());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
-// Font::Style style = bm_font->Face.Style;
|
|
|
-// Font::Weight weight = bm_font->Face.Weight;
|
|
|
+ Font::Style style = bm_font->Face.Style;
|
|
|
+ Font::Weight weight = bm_font->Face.Weight;
|
|
|
|
|
|
-// if (instance->AddFace(bm_font, bm_font->Face.FamilyName, style, weight, true))
|
|
|
-// {
|
|
|
-// Log::Message(Log::LT_INFO, "Loaded font face %s (from %s).", bm_font->Face.FamilyName.CString(), file_name.CString());
|
|
|
-// return true;
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// Log::Message(Log::LT_ERROR, "Failed to load font face %s (from %s).", bm_font->Face.FamilyName.CString(), file_name.CString());
|
|
|
-// return false;
|
|
|
-// }
|
|
|
+ if (instance->AddFace(bm_font, bm_font->Face.FamilyName, style, weight, true))
|
|
|
+ {
|
|
|
+ Log::Message(Log::LT_INFO, "Loaded font face %s (from %s).", bm_font->Face.FamilyName.CString(), file_name.CString());
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Log::Message(Log::LT_ERROR, "Failed to load font face %s (from %s).", bm_font->Face.FamilyName.CString(), file_name.CString());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
@@ -107,23 +107,23 @@ bool FontProvider::LoadFontFace(const String& file_name)
|
|
|
// Loads a new font face.
|
|
|
bool FontProvider::LoadFontFace(const String& file_name, const String& family, Font::Style style, Font::Weight weight)
|
|
|
{
|
|
|
-// BM_Font *bm_font = (BM_Font*) instance->LoadFace(file_name);
|
|
|
-// if (bm_font == NULL)
|
|
|
-// {
|
|
|
-// Log::Message(Log::LT_ERROR, "Failed to load font face from %s.", file_name.CString());
|
|
|
-// return false;
|
|
|
-// }
|
|
|
+ BM_Font *bm_font = (BM_Font*) instance->LoadFace(file_name);
|
|
|
+ if (bm_font == NULL)
|
|
|
+ {
|
|
|
+ Log::Message(Log::LT_ERROR, "Failed to load font face from %s.", file_name.CString());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
-// if (instance->AddFace(bm_font, bm_font->Face.FamilyName, style, weight, true))
|
|
|
-// {
|
|
|
-// Log::Message(Log::LT_INFO, "Loaded font face %s (from %s).", bm_font->Face.FamilyName.CString(), file_name.CString());
|
|
|
-// return true;
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// Log::Message(Log::LT_ERROR, "Failed to load font face %s (from %s).", bm_font->Face.FamilyName.CString(), file_name.CString());
|
|
|
-// return false;
|
|
|
-// }
|
|
|
+ if (instance->AddFace(bm_font, family, style, weight, true))
|
|
|
+ {
|
|
|
+ Log::Message(Log::LT_INFO, "Loaded font face %s (from %s).", bm_font->Face.FamilyName.CString(), file_name.CString());
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Log::Message(Log::LT_ERROR, "Failed to load font face %s (from %s).", bm_font->Face.FamilyName.CString(), file_name.CString());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
@@ -175,71 +175,69 @@ bool FontProvider::LoadFontFace(const byte* data, int data_length, const String&
|
|
|
// Adds a loaded face to the appropriate font family.
|
|
|
bool FontProvider::AddFace(void* face, const String& family, Font::Style style, Font::Weight weight, bool release_stream)
|
|
|
{
|
|
|
-// FontFamily* font_family = NULL;
|
|
|
-// FontFamilyMap::iterator iterator = instance->font_families.find(family);
|
|
|
-// if (iterator != instance->font_families.end())
|
|
|
-// font_family = (*iterator).second;
|
|
|
-// else
|
|
|
-// {
|
|
|
-// font_family = new FontFamily(family);
|
|
|
-// instance->font_families[family] = font_family;
|
|
|
-// }
|
|
|
+ Rocket::Core::FontFamily* font_family = NULL;
|
|
|
+ FontFamilyMap::iterator iterator = instance->font_families.find(family);
|
|
|
+ if (iterator != instance->font_families.end())
|
|
|
+ font_family = (*iterator).second;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ font_family = new FontFamily(family);
|
|
|
+ instance->font_families[family] = font_family;
|
|
|
+ }
|
|
|
|
|
|
-// return font_family->AddFace((BM_Font *) face, style, weight, release_stream);
|
|
|
+ return font_family->AddFace((BM_Font *) face, style, weight, release_stream);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
// Loads a FreeType face.
|
|
|
void* FontProvider::LoadFace(const String& file_name)
|
|
|
{
|
|
|
-// BM_Font *bm_face = new BM_Font();
|
|
|
-// FontParser parser( bm_face );
|
|
|
+ BM_Font *bm_face = new BM_Font();
|
|
|
+ FontParser parser( bm_face );
|
|
|
|
|
|
-// FileInterface* file_interface = GetFileInterface();
|
|
|
-// FileHandle handle = file_interface->Open(file_name);
|
|
|
+ FileInterface* file_interface = GetFileInterface();
|
|
|
+ FileHandle handle = file_interface->Open(file_name);
|
|
|
|
|
|
-// if (!handle)
|
|
|
-// {
|
|
|
-// return NULL;
|
|
|
-// }
|
|
|
+ if (!handle)
|
|
|
+ {
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
|
|
|
-// size_t length = file_interface->Length(handle);
|
|
|
+ size_t length = file_interface->Length(handle);
|
|
|
|
|
|
-// byte* buffer = new byte[length];
|
|
|
-// file_interface->Read(buffer, length, handle);
|
|
|
-// file_interface->Close(handle);
|
|
|
+ byte* buffer = new byte[length];
|
|
|
+ file_interface->Read(buffer, length, handle);
|
|
|
+ file_interface->Close(handle);
|
|
|
|
|
|
-// StreamMemory* stream = new StreamMemory( buffer, length );
|
|
|
-// stream->SetSourceURL( file_name );
|
|
|
+ StreamMemory* stream = new StreamMemory( buffer, length );
|
|
|
+ stream->SetSourceURL( file_name );
|
|
|
|
|
|
-// parser.Parse( stream );
|
|
|
+ parser.Parse( stream );
|
|
|
|
|
|
-// URL file_url = file_name;
|
|
|
+ URL file_url = file_name;
|
|
|
|
|
|
-// bm_face->Face.Source = file_url.GetFileName();
|
|
|
-// bm_face->Face.Directory = file_url.GetPath();
|
|
|
+ bm_face->Face.Source = file_url.GetFileName();
|
|
|
+ bm_face->Face.Directory = file_url.GetPath();
|
|
|
|
|
|
-// return bm_face;
|
|
|
- return 0;
|
|
|
+ return bm_face;
|
|
|
}
|
|
|
|
|
|
// Loads a FreeType face from memory.
|
|
|
void* FontProvider::LoadFace(const byte* data, int data_length, const String& source, bool local_data)
|
|
|
{
|
|
|
-// URL file_url = source + ".fnt";
|
|
|
+ URL file_url = source + ".fnt";
|
|
|
|
|
|
-// BM_Font *bm_face = new BM_Font();
|
|
|
-// FontParser parser( bm_face );
|
|
|
-// StreamMemory* stream = new StreamMemory( data, data_length );
|
|
|
-// stream->SetSourceURL( file_url );
|
|
|
+ BM_Font *bm_face = new BM_Font();
|
|
|
+ FontParser parser( bm_face );
|
|
|
+ StreamMemory* stream = new StreamMemory( data, data_length );
|
|
|
+ stream->SetSourceURL( file_url );
|
|
|
|
|
|
-// parser.Parse( stream );
|
|
|
+ parser.Parse( stream );
|
|
|
|
|
|
-// bm_face->Face.Source = file_url.GetFileName();
|
|
|
-// bm_face->Face.Directory = file_url.GetPath();
|
|
|
+ bm_face->Face.Source = file_url.GetFileName();
|
|
|
+ bm_face->Face.Directory = file_url.GetPath();
|
|
|
|
|
|
-// return bm_face;
|
|
|
- return 0;
|
|
|
+ return bm_face;
|
|
|
}
|
|
|
|
|
|
}
|