Browse Source

FontLayer

Patryk Konopka 10 years ago
parent
commit
ef425b35bc

+ 70 - 71
Source/Core/BitmapFont/FontFace.cpp

@@ -47,77 +47,76 @@ FontFace::~FontFace()
 // Returns a handle for positioning and rendering this face at the given size.
 // Returns a handle for positioning and rendering this face at the given size.
 Rocket::Core::FontFaceHandle* FontFace::GetHandle(const String& _raw_charset, int size)
 Rocket::Core::FontFaceHandle* FontFace::GetHandle(const String& _raw_charset, int size)
 {
 {
-//    UnicodeRangeList charset;
-
-//    HandleMap::iterator iterator = handles.find(size);
-//    if (iterator != handles.end())
-//    {
-//        const HandleList& handles = (*iterator).second;
-
-//        // Check all the handles if their charsets match the requested one exactly (ie, were specified by the same
-//        // string).
-//        String raw_charset(_raw_charset);
-//        for (size_t i = 0; i < handles.size(); ++i)
-//        {
-//            if (handles[i]->GetRawCharset() == _raw_charset)
-//            {
-//                handles[i]->AddReference();
-//                return (FontFaceHandle*)handles[i];
-//            }
-//        }
-
-//        // Check all the handles if their charsets contain the requested charset.
-//        if (!UnicodeRange::BuildList(charset, raw_charset))
-//        {
-//            Log::Message(Log::LT_ERROR, "Invalid font charset '%s'.", _raw_charset.CString());
-//            return NULL;
-//        }
-
-//        for (size_t i = 0; i < handles.size(); ++i)
-//        {
-//            bool range_contained = true;
-
-//            const UnicodeRangeList& handle_charset = handles[i]->GetCharset();
-//            for (size_t j = 0; j < charset.size() && range_contained; ++j)
-//            {
-//                if (!charset[j].IsContained(handle_charset))
-//                    range_contained = false;
-//            }
-
-//            if (range_contained)
-//            {
-//                handles[i]->AddReference();
-//                return (FontFaceHandle*)handles[i];
-//            }
-//        }
-//    }
-
-//    // See if this face has been released.
-//    if (face == NULL)
-//    {
-//        Log::Message(Log::LT_WARNING, "Font face has been released, unable to generate new handle.");
-//        return NULL;
-//    }
-
-//    // Construct and initialise the new handle.
-//    FontFaceHandle* handle = new FontFaceHandle();
-//    if (!handle->Initialise(face, _raw_charset, size))
-//    {
-//        handle->RemoveReference();
-//        return NULL;
-//    }
-
-//    // Save the handle, and add a reference for the callee. The initial reference will be removed when the font face
-//    // releases it.
-//    if (iterator != handles.end())
-//        (*iterator).second.push_back(handle);
-//    else
-//        handles[size] = HandleList(1, handle);
-
-//    handle->AddReference();
-
-//    return handle;
-    return 0;
+    UnicodeRangeList charset;
+
+    HandleMap::iterator iterator = handles.find(size);
+    if (iterator != handles.end())
+    {
+        const HandleList& handles = (*iterator).second;
+
+        // Check all the handles if their charsets match the requested one exactly (ie, were specified by the same
+        // string).
+        String raw_charset(_raw_charset);
+        for (size_t i = 0; i < handles.size(); ++i)
+        {
+            if (handles[i]->GetRawCharset() == _raw_charset)
+            {
+                handles[i]->AddReference();
+                return (FontFaceHandle*)handles[i];
+            }
+        }
+
+        // Check all the handles if their charsets contain the requested charset.
+        if (!UnicodeRange::BuildList(charset, raw_charset))
+        {
+            Log::Message(Log::LT_ERROR, "Invalid font charset '%s'.", _raw_charset.CString());
+            return NULL;
+        }
+
+        for (size_t i = 0; i < handles.size(); ++i)
+        {
+            bool range_contained = true;
+
+            const UnicodeRangeList& handle_charset = handles[i]->GetCharset();
+            for (size_t j = 0; j < charset.size() && range_contained; ++j)
+            {
+                if (!charset[j].IsContained(handle_charset))
+                    range_contained = false;
+            }
+
+            if (range_contained)
+            {
+                handles[i]->AddReference();
+                return (FontFaceHandle*)handles[i];
+            }
+        }
+    }
+
+    // See if this face has been released.
+    if (face == NULL)
+    {
+        Log::Message(Log::LT_WARNING, "Font face has been released, unable to generate new handle.");
+        return NULL;
+    }
+
+    // Construct and initialise the new handle.
+    FontFaceHandle* handle = new FontFaceHandle();
+    if (!handle->Initialise(face, _raw_charset, size))
+    {
+        handle->RemoveReference();
+        return NULL;
+    }
+
+    // Save the handle, and add a reference for the callee. The initial reference will be removed when the font face
+    // releases it.
+    if (iterator != handles.end())
+        (*iterator).second.push_back(handle);
+    else
+        handles[size] = HandleList(1, handle);
+
+    handle->AddReference();
+
+    return handle;
 }
 }
 
 
 // Releases the face's structure.
 // Releases the face's structure.

+ 3 - 1
Source/Core/BitmapFont/FontFaceHandle.cpp

@@ -318,6 +318,8 @@ void FontFaceHandle::GenerateMetrics(BM_Font *bm_face)
 
 
 void FontFaceHandle::BuildGlyphMap(BM_Font *bm_face, const UnicodeRange& unicode_range)
 void FontFaceHandle::BuildGlyphMap(BM_Font *bm_face, const UnicodeRange& unicode_range)
 {
 {
+    glyphs.resize(unicode_range.max_codepoint + 1);
+
     for (word character_code = (word) (Math::Max< unsigned int >(unicode_range.min_codepoint, 32)); character_code <= unicode_range.max_codepoint; ++character_code)
     for (word character_code = (word) (Math::Max< unsigned int >(unicode_range.min_codepoint, 32)); character_code <= unicode_range.max_codepoint; ++character_code)
     {
     {
         int index = bm_face->BM_Helper_GetCharacterTableIndex( character_code );
         int index = bm_face->BM_Helper_GetCharacterTableIndex( character_code );
@@ -368,7 +370,7 @@ void Rocket::Core::BitmapFont::FontFaceHandle::BuildKerning(BM_Font *bm_face)
 //        {
 //        {
 //            for (word rhs = (word) (Math::Max< unsigned int >(charset[i].min_codepoint, 32)); rhs <= charset[i].max_codepoint; ++rhs)
 //            for (word rhs = (word) (Math::Max< unsigned int >(charset[i].min_codepoint, 32)); rhs <= charset[i].max_codepoint; ++rhs)
 //            {
 //            {
-//                GlyphKerningMap& glyph_kerning = kerning.insert(FontKerningMap::value_type(rhs, GlyphKerningMap())).first->second;
+//                GlyphKerningList& glyph_kerning = kerning.insert(FontKerningList::value_type(rhs, GlyphKerningList())).first->second;
 
 
 //                for (size_t j = 0; j < charset.size(); ++j)
 //                for (size_t j = 0; j < charset.size(); ++j)
 //                {
 //                {

+ 10 - 2
Source/Core/BitmapFont/FontFaceLayer.cpp

@@ -41,8 +41,8 @@ FontFaceLayer::FontFaceLayer() : Rocket::Core::FontFaceLayer()
 
 
 FontFaceLayer::~FontFaceLayer()
 FontFaceLayer::~FontFaceLayer()
 {
 {
-    if (effect != NULL)
-        effect->RemoveReference();
+    //if (effect != NULL)
+    //    effect->RemoveReference();
 }
 }
 
 
 // Generates the character and texture data for the layer.
 // Generates the character and texture data for the layer.
@@ -77,6 +77,14 @@ bool FontFaceLayer::Initialise(const Rocket::Core::FontFaceHandle* _handle, Font
     else
     else
     {
     {
         // Initialise the texture layout for the glyphs.
         // Initialise the texture layout for the glyphs.
+        unsigned int size = glyphs.size();
+        if(size == 0)
+        {
+            return false;
+        }
+
+        characters.resize(glyphs[size - 1].character);
+
         for (FontGlyphList::const_iterator i = glyphs.begin(); i != glyphs.end(); ++i)
         for (FontGlyphList::const_iterator i = glyphs.begin(); i != glyphs.end(); ++i)
         {
         {
             const FontGlyph& glyph = *i;
             const FontGlyph& glyph = *i;

+ 2 - 2
Source/Core/BitmapFont/FontFamily.cpp

@@ -42,9 +42,9 @@ FontFamily::~FontFamily()
 }
 }
 
 
 // Adds a new face to the family.
 // Adds a new face to the family.
-bool FontFamily::AddFace( BM_Font *bm_face, Font::Style style, Font::Weight weight, bool release_stream)
+bool FontFamily::AddFace( void *bm_face, Font::Style style, Font::Weight weight, bool release_stream)
 {
 {
-    Rocket::Core::FontFace* face = new FontFace(bm_face, style, weight, release_stream);
+    Rocket::Core::FontFace* face = new FontFace((BM_Font*)bm_face, style, weight, release_stream);
     font_faces.push_back(face);
     font_faces.push_back(face);
 
 
     return true;
     return true;

+ 1 - 1
Source/Core/BitmapFont/FontFamily.h

@@ -56,7 +56,7 @@ public:
     /// @param[in] weight The weight of the new face.
     /// @param[in] weight The weight of the new face.
     /// @param[in] release_stream True if the application must free the face's memory stream.
     /// @param[in] release_stream True if the application must free the face's memory stream.
     /// @return True if the face was loaded successfully, false otherwise.
     /// @return True if the face was loaded successfully, false otherwise.
-    bool AddFace( BM_Font *bm_face, Font::Style style, Font::Weight weight, bool release_stream);
+    bool AddFace( void *bm_face, Font::Style style, Font::Weight weight, bool release_stream);
 };
 };
 
 
 }
 }

+ 136 - 0
Source/Core/BitmapFont/FontParser.cpp

@@ -0,0 +1,136 @@
+/*
+ * This source file is part of libRocket, the HTML/CSS Interface Middleware
+ *
+ * For the latest information, see http://www.librocket.com
+ *
+ * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+#include "../precompiled.h"
+#include "FontParser.h"
+
+namespace Rocket {
+namespace Core {
+namespace BitmapFont {
+
+FontParser::FontParser( BM_Font *face )
+    : BaseXMLParser()
+{
+    BM_face = face;
+    char_id = 0;
+    kern_id = 0;
+}
+
+FontParser::~FontParser()
+{
+}
+
+// Called when the parser finds the beginning of an element tag.
+void FontParser::HandleElementStart(const String& name, const XMLAttributes& attributes)
+{
+    if ( name == "info" )
+    {
+        BM_face->Face.FamilyName = "Arial";//attributes.Get( "face" )->Get< String >();
+        BM_face->Face.Size = attributes.Get( "size" )->Get< int >();
+        BM_face->Face.Weight = attributes.Get( "bold" )->Get< bool >() ? Font::WEIGHT_BOLD : Font::WEIGHT_NORMAL;
+        BM_face->Face.Style = attributes.Get( "italic" )->Get< bool >() ? Font::STYLE_ITALIC : Font::STYLE_NORMAL;
+        BM_face->Face.CharsetName = "";//attributes.Get( "charset" )->Get< String >();
+        BM_face->Face.IsUnicode = attributes.Get( "unicode" )->Get< bool >();
+        BM_face->Face.StretchHeight = attributes.Get( "stretchH" )->Get< int >();
+        BM_face->Face.IsSmoothed = attributes.Get( "smooth" )->Get< bool >();
+        BM_face->Face.SuperSamplingLevel = attributes.Get( "aa" )->Get< int >();
+        //:TODO:
+        //BM_face->Face.FamilyName = attributes.Get( "padding" )->Get< String >();
+        //BM_face->Face.FamilyName = attributes.Get( "spacing" )->Get< String >();
+        BM_face->Face.Outline = attributes.Get( "outline" )->Get< int >();
+    }
+    else if ( name == "common" )
+    {
+
+        BM_face->CommonCharactersInfo.LineHeight = attributes.Get( "lineHeight" )->Get< int >();
+        BM_face->CommonCharactersInfo.BaseLine = attributes.Get( "base" )->Get< int >();
+        BM_face->CommonCharactersInfo.ScaleWidth = attributes.Get( "scaleW" )->Get< int >();
+        BM_face->CommonCharactersInfo.ScaleHeight = attributes.Get( "scaleH" )->Get< int >();
+        BM_face->CommonCharactersInfo.PageCount = attributes.Get( "pages" )->Get< int >();
+        BM_face->CommonCharactersInfo.IsPacked = attributes.Get( "packed" )->Get< bool >();
+        BM_face->CommonCharactersInfo.AlphaChanelUsage = attributes.Get( "alphaChnl" )->Get< int >();
+        BM_face->CommonCharactersInfo.RedChanelUsage = attributes.Get( "redChnl" )->Get< int >();
+        BM_face->CommonCharactersInfo.GreenChanelUsage = attributes.Get( "greenChnl" )->Get< int >();
+        BM_face->CommonCharactersInfo.BlueChanelUsage = attributes.Get( "blueChnl" )->Get< int >();
+
+        BM_face->PagesInfo = new PageInfo[BM_face->CommonCharactersInfo.PageCount];
+        BM_face->CommonCharactersInfo.CharacterCount = 0;
+        BM_face->CommonCharactersInfo.KerningCount = 0;
+    }
+    else if ( name == "page" )
+    {
+        BM_face->PagesInfo[ attributes.Get( "id" )->Get< int >() ].Id = attributes.Get( "id" )->Get< int >();
+        BM_face->PagesInfo[ attributes.Get( "id" )->Get< int >() ].FileName = "Arial_0.tga";//attributes.Get( "file" )->Get< String >();
+    }
+    else if ( name == "chars" )
+    {
+        BM_face->CommonCharactersInfo.CharacterCount = attributes.Get( "count" )->Get< int >();
+        BM_face->CharactersInfo = new CharacterInfo[ attributes.Get( "count" )->Get< int >() ];
+    }
+    else if ( name == "char" )
+    {
+        BM_face->CharactersInfo[ char_id ].Id = attributes.Get( "id" )->Get< int >();
+        BM_face->CharactersInfo[ char_id ].X = attributes.Get( "x" )->Get< int >(); //The left position of the character image in the texture.
+        BM_face->CharactersInfo[ char_id ].Y = attributes.Get( "y" )->Get< int >(); //The top position of the character image in the texture.
+        BM_face->CharactersInfo[ char_id ].Width = attributes.Get( "width" )->Get< int >(); //The width of the character image in the texture.
+        BM_face->CharactersInfo[ char_id ].Height = attributes.Get( "height" )->Get< int >(); //The height of the character image in the texture.
+        BM_face->CharactersInfo[ char_id ].XOffset = attributes.Get( "xoffset" )->Get< int >();
+        BM_face->CharactersInfo[ char_id ].YOffset = attributes.Get( "yoffset" )->Get< int >();
+        BM_face->CharactersInfo[ char_id ].Advance = attributes.Get( "xadvance" )->Get< int >();
+        BM_face->CharactersInfo[ char_id ].PageId = attributes.Get( "page" )->Get< int >();
+        BM_face->CharactersInfo[ char_id ].ChannelUsed = attributes.Get( "chnl" )->Get< int >();
+
+        char_id++;
+    }
+    else if ( name == "kernings" )
+    {
+        BM_face->CommonCharactersInfo.KerningCount = attributes.Get( "count" )->Get< int >();
+        BM_face->KerningsInfo = new KerningInfo[ attributes.Get( "count" )->Get< int >() ];
+    }
+    else if ( name == "kerning" )
+    {
+        BM_face->KerningsInfo[ kern_id ].FirstCharacterId = attributes.Get( "first" )->Get< int >();
+        BM_face->KerningsInfo[ kern_id ].SecondCharacterId = attributes.Get( "second" )->Get< int >();
+        BM_face->KerningsInfo[ kern_id ].KerningAmount = attributes.Get( "amount" )->Get< int >();
+
+        kern_id++;
+    }
+}
+
+// Called when the parser finds the end of an element tag.
+void FontParser::HandleElementEnd(const String& ROCKET_UNUSED(name))
+{
+}
+
+// Called when the parser encounters data.
+void FontParser::HandleData(const String& ROCKET_UNUSED(data))
+{
+}
+
+}
+}
+}

+ 68 - 0
Source/Core/BitmapFont/FontParser.h

@@ -0,0 +1,68 @@
+/*
+ * This source file is part of libRocket, the HTML/CSS Interface Middleware
+ *
+ * For the latest information, see http://www.librocket.com
+ *
+ * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+#ifndef BITMAPFONTPARSER_H
+#define BITMAPFONTPARSER_H
+
+#include <Rocket/Core/Header.h>
+#include <Rocket/Core/Types.h>
+#include <Rocket/Core/Dictionary.h>
+#include "BM_Font.h"
+#include <set>
+
+namespace Rocket {
+namespace Core {
+namespace BitmapFont {
+
+/**
+    @author Peter Curry
+ */
+
+class FontParser : public BaseXMLParser
+{
+    public:
+        FontParser( BM_Font *face );
+        virtual ~FontParser();
+
+        /// Called when the parser finds the beginning of an element tag.
+        virtual void HandleElementStart(const String& name, const XMLAttributes& attributes);
+        /// Called when the parser finds the end of an element tag.
+        virtual void HandleElementEnd(const String& name);
+        /// Called when the parser encounters data.
+        virtual void HandleData(const String& data);
+
+    private:
+        FontParser();
+        BM_Font *BM_face;
+        int char_id;
+        int kern_id;
+};
+
+}
+}
+}
+#endif

+ 75 - 77
Source/Core/BitmapFont/FontProvider.cpp

@@ -30,10 +30,10 @@
 #include "../FontFaceHandle.h"
 #include "../FontFaceHandle.h"
 #include <Rocket/Core/FontDatabase.h>
 #include <Rocket/Core/FontDatabase.h>
 #include <Rocket/Core/StreamMemory.h>
 #include <Rocket/Core/StreamMemory.h>
-//#include "../FontFamily.h"
+#include "FontFamily.h"
 #include <Rocket/Core.h>
 #include <Rocket/Core.h>
-//#include "BM_Font.h"
-//#include "FontParser.h"
+#include "BM_Font.h"
+#include "FontParser.h"
 
 
 namespace Rocket {
 namespace Rocket {
 namespace Core {
 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.
 // 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)
 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;
     return true;
 }
 }
@@ -107,23 +107,23 @@ bool FontProvider::LoadFontFace(const String& file_name)
 // Loads a new font face.
 // Loads a new font face.
 bool FontProvider::LoadFontFace(const String& file_name, const String& family, Font::Style style, Font::Weight weight)
 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;
     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.
 // 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)
 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;
     return true;
 }
 }
 
 
 // Loads a FreeType face.
 // Loads a FreeType face.
 void* FontProvider::LoadFace(const String& file_name)
 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.
 // Loads a FreeType face from memory.
 void* FontProvider::LoadFace(const byte* data, int data_length, const String& source, bool local_data)
 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;
 }
 }
 
 
 }
 }