Pārlūkot izejas kodu

tabs instead of spaces

Patryk Konopka 10 gadi atpakaļ
vecāks
revīzija
96ff48d53b

+ 93 - 93
Source/Core/BitmapFont/BitmapFontDefinitions.h

@@ -37,109 +37,109 @@ namespace Rocket {
 namespace Core {
 namespace Core {
 namespace BitmapFont {
 namespace BitmapFont {
 
 
-    struct FontInfo
-    {
-        String FamilyName;
-        String Source;
-        String BitmapSource;
-        int Size;
-        Font::Style Style;
-        Font::Weight Weight;
-    };
+	struct FontInfo
+	{
+		String FamilyName;
+		String Source;
+		String BitmapSource;
+		int Size;
+		Font::Style Style;
+		Font::Weight Weight;
+	};
 
 
-    struct CharacterCommonInfo
-    {
-        int LineHeight;
-        int BaseLine;
-        int ScaleWidth;
-        int ScaleHeight;
-        int CharacterCount;
-        int KerningCount;
-    };
+	struct CharacterCommonInfo
+	{
+		int LineHeight;
+		int BaseLine;
+		int ScaleWidth;
+		int ScaleHeight;
+		int CharacterCount;
+		int KerningCount;
+	};
 
 
-    struct CharacterInfo
-    {
-        int Id;
-        int X;
-        int Y;
-        int Width;
-        int Height;
-        int XOffset;
-        int YOffset;
-        int Advance;
-    };
+	struct CharacterInfo
+	{
+		int Id;
+		int X;
+		int Y;
+		int Width;
+		int Height;
+		int XOffset;
+		int YOffset;
+		int Advance;
+	};
 
 
-    struct KerningInfo
-    {
-        int FirstCharacterId;
-        int SecondCharacterId;
-        int KerningAmount;
-    };
+	struct KerningInfo
+	{
+		int FirstCharacterId;
+		int SecondCharacterId;
+		int KerningAmount;
+	};
 
 
-    class BitmapFontDefinitions
-    {
-    public:
-        FontInfo Face;
-        CharacterCommonInfo CommonCharactersInfo;
-        CharacterInfo *CharactersInfo;
-        KerningInfo *KerningsInfo;
+	class BitmapFontDefinitions
+	{
+	public:
+		FontInfo Face;
+		CharacterCommonInfo CommonCharactersInfo;
+		CharacterInfo *CharactersInfo;
+		KerningInfo *KerningsInfo;
 
 
-        int BM_Helper_GetCharacterTableIndex( int unicode_code )
-        {
-            return BinarySearch( unicode_code, 0, CommonCharactersInfo.CharacterCount );
-        }
+		int BM_Helper_GetCharacterTableIndex( int unicode_code )
+		{
+			return BinarySearch( unicode_code, 0, CommonCharactersInfo.CharacterCount );
+		}
 
 
-        int BM_Helper_GetXKerning( int left_uni_id, int right_uni_id )
-        {
-            for ( int i = 0; i < this->CommonCharactersInfo.KerningCount; i++ )
-            {
-                if ( this->KerningsInfo[i].FirstCharacterId == left_uni_id && this->KerningsInfo[i].SecondCharacterId == right_uni_id )
-                {
-                    return this->KerningsInfo[i].KerningAmount;
-                }
-            }
+		int BM_Helper_GetXKerning( int left_uni_id, int right_uni_id )
+		{
+			for ( int i = 0; i < this->CommonCharactersInfo.KerningCount; i++ )
+			{
+				if ( this->KerningsInfo[i].FirstCharacterId == left_uni_id && this->KerningsInfo[i].SecondCharacterId == right_uni_id )
+				{
+					return this->KerningsInfo[i].KerningAmount;
+				}
+			}
 
 
-            return 0;
-        }
+			return 0;
+		}
 
 
-    private:
+	private:
 
 
-        int BinarySearch( int unicode_code, int min_index, int max_index )
-        {
-            if ( abs( max_index - min_index ) <= 1 )
-            {
-                if ( this->CharactersInfo[ min_index ].Id == unicode_code )
-                {
-                    return min_index;
-                }
-                else if ( this->CharactersInfo[ max_index ].Id == unicode_code )
-                {
-                    return max_index;
-                }
-                else
-                {
-                    return -1;
-                }
-            }
-            else
-            {
-                int mid_index = ( min_index + max_index ) / 2;
+		int BinarySearch( int unicode_code, int min_index, int max_index )
+		{
+			if ( abs( max_index - min_index ) <= 1 )
+			{
+				if ( this->CharactersInfo[ min_index ].Id == unicode_code )
+				{
+					return min_index;
+				}
+				else if ( this->CharactersInfo[ max_index ].Id == unicode_code )
+				{
+					return max_index;
+				}
+				else
+				{
+					return -1;
+				}
+			}
+			else
+			{
+				int mid_index = ( min_index + max_index ) / 2;
 
 
-                if ( this->CharactersInfo[ mid_index ].Id == unicode_code )
-                {
-                    return mid_index;
-                }
-                else if ( this->CharactersInfo[ mid_index ].Id > unicode_code )
-                {
-                    return BinarySearch( unicode_code, min_index, mid_index );
-                }
-                else
-                {
-                    return BinarySearch( unicode_code, mid_index, max_index );
-                }
-            }
-        }
-    };
+				if ( this->CharactersInfo[ mid_index ].Id == unicode_code )
+				{
+					return mid_index;
+				}
+				else if ( this->CharactersInfo[ mid_index ].Id > unicode_code )
+				{
+					return BinarySearch( unicode_code, min_index, mid_index );
+				}
+				else
+				{
+					return BinarySearch( unicode_code, mid_index, max_index );
+				}
+			}
+		}
+	};
 
 
 }
 }
 }
 }

+ 73 - 73
Source/Core/BitmapFont/FontFace.cpp

@@ -36,93 +36,93 @@ namespace BitmapFont {
 
 
 FontFace::FontFace(BitmapFontDefinitions *_face, Font::Style _style, Font::Weight _weight, bool _release_stream) : Rocket::Core::FontFace(_style, _weight, _release_stream)
 FontFace::FontFace(BitmapFontDefinitions *_face, Font::Style _style, Font::Weight _weight, bool _release_stream) : Rocket::Core::FontFace(_style, _weight, _release_stream)
 {
 {
-    face = _face;
+	face = _face;
 }
 }
 
 
 FontFace::~FontFace()
 FontFace::~FontFace()
 {
 {
-    ReleaseFace();
+	ReleaseFace();
 }
 }
 
 
 // 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;
+	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.
 void FontFace::ReleaseFace()
 void FontFace::ReleaseFace()
 {
 {
-    delete face;
+	delete face;
 }
 }
 
 
 }
 }

+ 12 - 12
Source/Core/BitmapFont/FontFace.h

@@ -38,27 +38,27 @@ namespace BitmapFont {
 class FontFaceHandle;
 class FontFaceHandle;
 
 
 /**
 /**
-    @author Peter Curry
+	@author Peter Curry
  */
  */
 
 
 class FontFace : public Rocket::Core::FontFace
 class FontFace : public Rocket::Core::FontFace
 {
 {
 public:
 public:
-    FontFace(BitmapFontDefinitions *_face, Font::Style style, Font::Weight weight, bool release_stream);
-    ~FontFace();
+	FontFace(BitmapFontDefinitions *_face, Font::Style style, Font::Weight weight, bool release_stream);
+	~FontFace();
 
 
-    /// Returns a handle for positioning and rendering this face at the given size.
-    /// @param[in] charset The set of characters in the handle, as a comma-separated list of unicode ranges.
-    /// @param[in] size The size of the desired handle, in points.
-    /// @return The shared font handle.
-    Rocket::Core::FontFaceHandle* GetHandle(const String& charset, int size);
+	/// Returns a handle for positioning and rendering this face at the given size.
+	/// @param[in] charset The set of characters in the handle, as a comma-separated list of unicode ranges.
+	/// @param[in] size The size of the desired handle, in points.
+	/// @return The shared font handle.
+	Rocket::Core::FontFaceHandle* GetHandle(const String& charset, int size);
 
 
-    /// Releases the face's FreeType face structure. This will mean handles for new sizes cannot be constructed,
-    /// but existing ones can still be fetched.
-    void ReleaseFace();
+	/// Releases the face's FreeType face structure. This will mean handles for new sizes cannot be constructed,
+	/// but existing ones can still be fetched.
+	void ReleaseFace();
 
 
 private:
 private:
-    BitmapFontDefinitions *face;
+	BitmapFontDefinitions *face;
 };
 };
 
 
 }
 }

+ 287 - 287
Source/Core/BitmapFont/FontFaceHandle.cpp

@@ -38,24 +38,24 @@ namespace BitmapFont {
 class FontEffectSort
 class FontEffectSort
 {
 {
 public:
 public:
-    bool operator()(const Rocket::Core::FontEffect* lhs, const Rocket::Core::FontEffect* rhs)
-    {
-        return lhs->GetZIndex() < rhs->GetZIndex();
-    }
+	bool operator()(const Rocket::Core::FontEffect* lhs, const Rocket::Core::FontEffect* rhs)
+	{
+		return lhs->GetZIndex() < rhs->GetZIndex();
+	}
 };
 };
 
 
 FontFaceHandle::FontFaceHandle()
 FontFaceHandle::FontFaceHandle()
 {
 {
-    size = 0;
-    average_advance = 0;
-    x_height = 0;
-    line_height = 0;
-    baseline = 0;
+	size = 0;
+	average_advance = 0;
+	x_height = 0;
+	line_height = 0;
+	baseline = 0;
 
 
-    underline_position = 0;
-    underline_thickness = 0;
+	underline_position = 0;
+	underline_thickness = 0;
 
 
-    base_layer = NULL;
+	base_layer = NULL;
 }
 }
 
 
 FontFaceHandle::~FontFaceHandle()
 FontFaceHandle::~FontFaceHandle()
@@ -65,362 +65,362 @@ FontFaceHandle::~FontFaceHandle()
 // Initialises the handle so it is able to render text.
 // Initialises the handle so it is able to render text.
 bool FontFaceHandle::Initialise(BitmapFontDefinitions *bm_face, const String& _charset, int _size)
 bool FontFaceHandle::Initialise(BitmapFontDefinitions *bm_face, const String& _charset, int _size)
 {
 {
-    this->bm_face = bm_face;
-    size = _size;
-    line_height = _size;
-    texture_width = bm_face->CommonCharactersInfo.ScaleWidth;
-    texture_height = bm_face->CommonCharactersInfo.ScaleHeight;
-    raw_charset = _charset;
-
-    // Construct proper path to texture
-    URL fnt_source = bm_face->Face.Source;
-    URL bitmap_source = bm_face->Face.BitmapSource;
-    if(bitmap_source.GetPath().Empty())
-    {
-        texture_source = fnt_source.GetPath() + bitmap_source.GetFileName();
-        if(!bitmap_source.GetExtension().Empty())
-        {
-            texture_source += "." + bitmap_source.GetExtension();
-        }
-    }
-    else
-    {
-        texture_source = bitmap_source.GetPathedFileName();
-    }
-
-    if (!UnicodeRange::BuildList(charset, raw_charset))
-    {
-        Log::Message(Log::LT_ERROR, "Invalid font charset '%s'.", raw_charset.CString());
-        return false;
-    }
-
-    // Construct the list of the characters specified by the charset.
-    for (size_t i = 0; i < charset.size(); ++i)
-        BuildGlyphMap(bm_face, charset[i]);
-
-    // Generate the metrics for the handle.
-    GenerateMetrics(bm_face);
-
-    // Generate the default layer and layer configuration.
-    base_layer = GenerateLayer(NULL);
-    layer_configurations.push_back(LayerConfiguration());
-    layer_configurations.back().push_back(base_layer);
-
-    return true;
+	this->bm_face = bm_face;
+	size = _size;
+	line_height = _size;
+	texture_width = bm_face->CommonCharactersInfo.ScaleWidth;
+	texture_height = bm_face->CommonCharactersInfo.ScaleHeight;
+	raw_charset = _charset;
+
+	// Construct proper path to texture
+	URL fnt_source = bm_face->Face.Source;
+	URL bitmap_source = bm_face->Face.BitmapSource;
+	if(bitmap_source.GetPath().Empty())
+	{
+		texture_source = fnt_source.GetPath() + bitmap_source.GetFileName();
+		if(!bitmap_source.GetExtension().Empty())
+		{
+			texture_source += "." + bitmap_source.GetExtension();
+		}
+	}
+	else
+	{
+		texture_source = bitmap_source.GetPathedFileName();
+	}
+
+	if (!UnicodeRange::BuildList(charset, raw_charset))
+	{
+		Log::Message(Log::LT_ERROR, "Invalid font charset '%s'.", raw_charset.CString());
+		return false;
+	}
+
+	// Construct the list of the characters specified by the charset.
+	for (size_t i = 0; i < charset.size(); ++i)
+		BuildGlyphMap(bm_face, charset[i]);
+
+	// Generate the metrics for the handle.
+	GenerateMetrics(bm_face);
+
+	// Generate the default layer and layer configuration.
+	base_layer = GenerateLayer(NULL);
+	layer_configurations.push_back(LayerConfiguration());
+	layer_configurations.back().push_back(base_layer);
+
+	return true;
 }
 }
 
 
 // Returns the width a string will take up if rendered with this handle.
 // Returns the width a string will take up if rendered with this handle.
 int FontFaceHandle::GetStringWidth(const WString& string, word prior_character) const
 int FontFaceHandle::GetStringWidth(const WString& string, word prior_character) const
 {
 {
-    int width = 0;
+	int width = 0;
 
 
-    for (size_t i = 0; i < string.Length(); i++)
-    {
-        word character_code = string[i];
+	for (size_t i = 0; i < string.Length(); i++)
+	{
+		word character_code = string[i];
 
 
-        if (character_code >= glyphs.size())
-            continue;
-        const FontGlyph &glyph = glyphs[character_code];
+		if (character_code >= glyphs.size())
+			continue;
+		const FontGlyph &glyph = glyphs[character_code];
 
 
-        // Adjust the cursor for the kerning between this character and the previous one.
-        if (prior_character != 0)
-            width += GetKerning(prior_character, string[i]);
-        // Adjust the cursor for this character's advance.
-        width += glyph.advance;
+		// Adjust the cursor for the kerning between this character and the previous one.
+		if (prior_character != 0)
+			width += GetKerning(prior_character, string[i]);
+		// Adjust the cursor for this character's advance.
+		width += glyph.advance;
 
 
-        prior_character = character_code;
-    }
+		prior_character = character_code;
+	}
 
 
-    return width;
+	return width;
 }
 }
 
 
 // Generates, if required, the layer configuration for a given array of font effects.
 // Generates, if required, the layer configuration for a given array of font effects.
 int FontFaceHandle::GenerateLayerConfiguration(FontEffectMap& font_effects)
 int FontFaceHandle::GenerateLayerConfiguration(FontEffectMap& font_effects)
 {
 {
-    if (font_effects.empty())
-        return 0;
-
-    // Prepare a list of effects, sorted by z-index.
-    FontEffectList sorted_effects;
-    for (FontEffectMap::const_iterator i = font_effects.begin(); i != font_effects.end(); ++i)
-        sorted_effects.push_back(i->second);
-
-    std::sort(sorted_effects.begin(), sorted_effects.end(), FontEffectSort());
-
-    // Check each existing configuration for a match with this arrangement of effects.
-    int configuration_index = 1;
-    for (; configuration_index < (int) layer_configurations.size(); ++configuration_index)
-    {
-        const LayerConfiguration& configuration = layer_configurations[configuration_index];
-
-        // Check the size is correct. For a math, there should be one layer in the configuration
-        // plus an extra for the base layer.
-        if (configuration.size() != sorted_effects.size() + 1)
-            continue;
-
-        // Check through each layer, checking it was created by the same effect as the one we're
-        // checking.
-        size_t effect_index = 0;
-        for (size_t i = 0; i < configuration.size(); ++i)
-        {
-            // Skip the base layer ...
-            if (configuration[i]->GetFontEffect() == NULL)
-                continue;
-
-            // If the ith layer's effect doesn't match the equivalent effect, then this
-            // configuration can't match.
-            if (configuration[i]->GetFontEffect() != sorted_effects[effect_index])
-                break;
-
-            // Check the next one ...
-            ++effect_index;
-        }
-
-        if (effect_index == sorted_effects.size())
-            return configuration_index;
-    }
-
-    // No match, so we have to generate a new layer configuration.
-    layer_configurations.push_back(LayerConfiguration());
-    LayerConfiguration& layer_configuration = layer_configurations.back();
-
-    bool added_base_layer = false;
-
-    for (size_t i = 0; i < sorted_effects.size(); ++i)
-    {
-        if (!added_base_layer &&
-            sorted_effects[i]->GetZIndex() >= 0)
-        {
-            layer_configuration.push_back(base_layer);
-            added_base_layer = true;
-        }
-
-        layer_configuration.push_back(GenerateLayer(sorted_effects[i]));
-    }
-
-    // Add the base layer now if we still haven't added it.
-    if (!added_base_layer)
-        layer_configuration.push_back(base_layer);
-
-    return (int) (layer_configurations.size() - 1);
+	if (font_effects.empty())
+		return 0;
+
+	// Prepare a list of effects, sorted by z-index.
+	FontEffectList sorted_effects;
+	for (FontEffectMap::const_iterator i = font_effects.begin(); i != font_effects.end(); ++i)
+		sorted_effects.push_back(i->second);
+
+	std::sort(sorted_effects.begin(), sorted_effects.end(), FontEffectSort());
+
+	// Check each existing configuration for a match with this arrangement of effects.
+	int configuration_index = 1;
+	for (; configuration_index < (int) layer_configurations.size(); ++configuration_index)
+	{
+		const LayerConfiguration& configuration = layer_configurations[configuration_index];
+
+		// Check the size is correct. For a math, there should be one layer in the configuration
+		// plus an extra for the base layer.
+		if (configuration.size() != sorted_effects.size() + 1)
+			continue;
+
+		// Check through each layer, checking it was created by the same effect as the one we're
+		// checking.
+		size_t effect_index = 0;
+		for (size_t i = 0; i < configuration.size(); ++i)
+		{
+			// Skip the base layer ...
+			if (configuration[i]->GetFontEffect() == NULL)
+				continue;
+
+			// If the ith layer's effect doesn't match the equivalent effect, then this
+			// configuration can't match.
+			if (configuration[i]->GetFontEffect() != sorted_effects[effect_index])
+				break;
+
+			// Check the next one ...
+			++effect_index;
+		}
+
+		if (effect_index == sorted_effects.size())
+			return configuration_index;
+	}
+
+	// No match, so we have to generate a new layer configuration.
+	layer_configurations.push_back(LayerConfiguration());
+	LayerConfiguration& layer_configuration = layer_configurations.back();
+
+	bool added_base_layer = false;
+
+	for (size_t i = 0; i < sorted_effects.size(); ++i)
+	{
+		if (!added_base_layer &&
+			sorted_effects[i]->GetZIndex() >= 0)
+		{
+			layer_configuration.push_back(base_layer);
+			added_base_layer = true;
+		}
+
+		layer_configuration.push_back(GenerateLayer(sorted_effects[i]));
+	}
+
+	// Add the base layer now if we still haven't added it.
+	if (!added_base_layer)
+		layer_configuration.push_back(base_layer);
+
+	return (int) (layer_configurations.size() - 1);
 }
 }
 
 
 // Generates the texture data for a layer (for the texture database).
 // Generates the texture data for a layer (for the texture database).
 bool FontFaceHandle::GenerateLayerTexture(const byte*& texture_data, Vector2i& texture_dimensions, Rocket::Core::FontEffect* layer_id, int texture_id)
 bool FontFaceHandle::GenerateLayerTexture(const byte*& texture_data, Vector2i& texture_dimensions, Rocket::Core::FontEffect* layer_id, int texture_id)
 {
 {
-    FontLayerMap::iterator layer_iterator = layers.find(layer_id);
-    if (layer_iterator == layers.end())
-        return false;
+	FontLayerMap::iterator layer_iterator = layers.find(layer_id);
+	if (layer_iterator == layers.end())
+		return false;
 
 
-    return layer_iterator->second->GenerateTexture(texture_data, texture_dimensions, texture_id);
+	return layer_iterator->second->GenerateTexture(texture_data, texture_dimensions, texture_id);
 }
 }
 
 
 // Generates the geometry required to render a single line of text.
 // Generates the geometry required to render a single line of text.
 int FontFaceHandle::GenerateString(GeometryList& geometry, const WString& string, const Vector2f& position, const Colourb& colour, int layer_configuration_index) const
 int FontFaceHandle::GenerateString(GeometryList& geometry, const WString& string, const Vector2f& position, const Colourb& colour, int layer_configuration_index) const
 {
 {
-    int geometry_index = 0;
-    int line_width = 0;
+	int geometry_index = 0;
+	int line_width = 0;
 
 
-    ROCKET_ASSERT(layer_configuration_index >= 0);
-    ROCKET_ASSERT(layer_configuration_index < (int) layer_configurations.size());
+	ROCKET_ASSERT(layer_configuration_index >= 0);
+	ROCKET_ASSERT(layer_configuration_index < (int) layer_configurations.size());
 
 
-    // Fetch the requested configuration and generate the geometry for each one.
-    const LayerConfiguration& layer_configuration = layer_configurations[layer_configuration_index];
-    for (size_t i = 0; i < layer_configuration.size(); ++i)
-    {
-        Rocket::Core::FontFaceLayer* layer = layer_configuration[i];
+	// Fetch the requested configuration and generate the geometry for each one.
+	const LayerConfiguration& layer_configuration = layer_configurations[layer_configuration_index];
+	for (size_t i = 0; i < layer_configuration.size(); ++i)
+	{
+		Rocket::Core::FontFaceLayer* layer = layer_configuration[i];
 
 
-        Colourb layer_colour;
-        if (layer == base_layer)
-            layer_colour = colour;
-        else
-            layer_colour = layer->GetColour();
+		Colourb layer_colour;
+		if (layer == base_layer)
+			layer_colour = colour;
+		else
+			layer_colour = layer->GetColour();
 
 
-        // Resize the geometry list if required.
-        if ((int) geometry.size() < geometry_index + layer->GetNumTextures())
-            geometry.resize(geometry_index + layer->GetNumTextures());
+		// Resize the geometry list if required.
+		if ((int) geometry.size() < geometry_index + layer->GetNumTextures())
+			geometry.resize(geometry_index + layer->GetNumTextures());
 
 
-        // Bind the textures to the geometries.
-        for (int i = 0; i < layer->GetNumTextures(); ++i)
-            geometry[geometry_index + i].SetTexture(layer->GetTexture(i));
+		// Bind the textures to the geometries.
+		for (int i = 0; i < layer->GetNumTextures(); ++i)
+			geometry[geometry_index + i].SetTexture(layer->GetTexture(i));
 
 
-        line_width = 0;
-        word prior_character = 0;
+		line_width = 0;
+		word prior_character = 0;
 
 
-        const word* string_iterator = string.CString();
-        const word* string_end = string.CString() + string.Length();
+		const word* string_iterator = string.CString();
+		const word* string_end = string.CString() + string.Length();
 
 
-        for (; string_iterator != string_end; string_iterator++)
-        {
-            if (*string_iterator >= glyphs.size())
-                continue;
-            const FontGlyph &glyph = glyphs[*string_iterator];
+		for (; string_iterator != string_end; string_iterator++)
+		{
+			if (*string_iterator >= glyphs.size())
+				continue;
+			const FontGlyph &glyph = glyphs[*string_iterator];
 
 
-            // Adjust the cursor for the kerning between this character and the previous one.
-            if (prior_character != 0)
-                line_width += GetKerning(prior_character, *string_iterator);
+			// Adjust the cursor for the kerning between this character and the previous one.
+			if (prior_character != 0)
+				line_width += GetKerning(prior_character, *string_iterator);
 
 
-            layer->GenerateGeometry(&geometry[geometry_index], *string_iterator, Vector2f(position.x + line_width, position.y), layer_colour);
+			layer->GenerateGeometry(&geometry[geometry_index], *string_iterator, Vector2f(position.x + line_width, position.y), layer_colour);
 
 
-            line_width += glyph.advance;
-            prior_character = *string_iterator;
-        }
+			line_width += glyph.advance;
+			prior_character = *string_iterator;
+		}
 
 
-        geometry_index += layer->GetNumTextures();
-    }
+		geometry_index += layer->GetNumTextures();
+	}
 
 
-    // Cull any excess geometry from a previous generation.
-    geometry.resize(geometry_index);
+	// Cull any excess geometry from a previous generation.
+	geometry.resize(geometry_index);
 
 
-    return line_width;
+	return line_width;
 }
 }
 
 
 // Generates the geometry required to render a line above, below or through a line of text.
 // Generates the geometry required to render a line above, below or through a line of text.
 void FontFaceHandle::GenerateLine(Geometry* geometry, const Vector2f& position, int width, Font::Line height, const Colourb& colour) const
 void FontFaceHandle::GenerateLine(Geometry* geometry, const Vector2f& position, int width, Font::Line height, const Colourb& colour) const
 {
 {
-    std::vector< Vertex >& line_vertices = geometry->GetVertices();
-    std::vector< int >& line_indices = geometry->GetIndices();
-
-    float offset;
-    switch (height)
-    {
-        case Font::UNDERLINE:			offset = -underline_position; break;
-        case Font::OVERLINE:			// where to place? offset = -line_height - underline_position; break;
-        case Font::STRIKE_THROUGH:		// where to place? offset = -line_height * 0.5f; break;
-        default:						return;
-    }
-
-    line_vertices.resize(line_vertices.size() + 4);
-    line_indices.resize(line_indices.size() + 6);
-    GeometryUtilities::GenerateQuad(&line_vertices[0] + (line_vertices.size() - 4), &line_indices[0] + (line_indices.size() - 6), Vector2f(position.x, position.y + offset), Vector2f((float) width, underline_thickness), colour, line_vertices.size() - 4);
+	std::vector< Vertex >& line_vertices = geometry->GetVertices();
+	std::vector< int >& line_indices = geometry->GetIndices();
+
+	float offset;
+	switch (height)
+	{
+		case Font::UNDERLINE:			offset = -underline_position; break;
+		case Font::OVERLINE:			// where to place? offset = -line_height - underline_position; break;
+		case Font::STRIKE_THROUGH:		// where to place? offset = -line_height * 0.5f; break;
+		default:						return;
+	}
+
+	line_vertices.resize(line_vertices.size() + 4);
+	line_indices.resize(line_indices.size() + 6);
+	GeometryUtilities::GenerateQuad(&line_vertices[0] + (line_vertices.size() - 4), &line_indices[0] + (line_indices.size() - 6), Vector2f(position.x, position.y + offset), Vector2f((float) width, underline_thickness), colour, line_vertices.size() - 4);
 }
 }
 
 
 // Destroys the handle.
 // Destroys the handle.
 void FontFaceHandle::OnReferenceDeactivate()
 void FontFaceHandle::OnReferenceDeactivate()
 {
 {
-    delete this;
+	delete this;
 }
 }
 
 
 void FontFaceHandle::GenerateMetrics(BitmapFontDefinitions *bm_face)
 void FontFaceHandle::GenerateMetrics(BitmapFontDefinitions *bm_face)
 {
 {
-    line_height = bm_face->CommonCharactersInfo.LineHeight;
-    baseline = bm_face->CommonCharactersInfo.BaseLine;
+	line_height = bm_face->CommonCharactersInfo.LineHeight;
+	baseline = bm_face->CommonCharactersInfo.BaseLine;
 
 
-    underline_position = (float)line_height - bm_face->CommonCharactersInfo.BaseLine;
-    baseline += int( underline_position / 1.6f );
-    underline_thickness = 1.0f;
+	underline_position = (float)line_height - bm_face->CommonCharactersInfo.BaseLine;
+	baseline += int( underline_position / 1.6f );
+	underline_thickness = 1.0f;
 
 
-    average_advance = 0;
-    for (FontGlyphList::iterator i = glyphs.begin(); i != glyphs.end(); ++i)
-        average_advance += i->advance;
+	average_advance = 0;
+	for (FontGlyphList::iterator i = glyphs.begin(); i != glyphs.end(); ++i)
+		average_advance += i->advance;
 
 
-    // Bring the total advance down to the average advance, but scaled up 10%, just to be on the safe side.
-    average_advance = Math::RealToInteger((float) average_advance / (glyphs.size() * 0.9f));
+	// Bring the total advance down to the average advance, but scaled up 10%, just to be on the safe side.
+	average_advance = Math::RealToInteger((float) average_advance / (glyphs.size() * 0.9f));
 
 
-    // Determine the x-height of this font face.
-    word x = (word) 'x';
-    int index = bm_face->BM_Helper_GetCharacterTableIndex( x );// FT_Get_Char_Index(ft_face, x);
+	// Determine the x-height of this font face.
+	word x = (word) 'x';
+	int index = bm_face->BM_Helper_GetCharacterTableIndex( x );// FT_Get_Char_Index(ft_face, x);
 
 
-    if ( index >= 0)
-        x_height = bm_face->CharactersInfo[ index ].Height;
-    else
-        x_height = 0;
+	if ( index >= 0)
+		x_height = bm_face->CharactersInfo[ index ].Height;
+	else
+		x_height = 0;
 }
 }
 
 
 void FontFaceHandle::BuildGlyphMap(BitmapFontDefinitions *bm_face, const UnicodeRange& unicode_range)
 void FontFaceHandle::BuildGlyphMap(BitmapFontDefinitions *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)
-    {
-        int index = bm_face->BM_Helper_GetCharacterTableIndex( character_code );
-
-        if ( index < 0 )
-        {
-            continue;
-        }
-
-        FontGlyph glyph;
-        glyph.character = character_code;
-        BuildGlyph(glyph, &bm_face->CharactersInfo[ index ] );
-        glyphs[character_code] = glyph;
-    }
+	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)
+	{
+		int index = bm_face->BM_Helper_GetCharacterTableIndex( character_code );
+
+		if ( index < 0 )
+		{
+			continue;
+		}
+
+		FontGlyph glyph;
+		glyph.character = character_code;
+		BuildGlyph(glyph, &bm_face->CharactersInfo[ index ] );
+		glyphs[character_code] = glyph;
+	}
 }
 }
 
 
 void Rocket::Core::BitmapFont::FontFaceHandle::BuildGlyph(FontGlyph& glyph, CharacterInfo *bm_glyph)
 void Rocket::Core::BitmapFont::FontFaceHandle::BuildGlyph(FontGlyph& glyph, CharacterInfo *bm_glyph)
 {
 {
-    // Set the glyph's dimensions.
-    glyph.dimensions.x = bm_glyph->Width;
-    glyph.dimensions.y = bm_glyph->Height;
+	// Set the glyph's dimensions.
+	glyph.dimensions.x = bm_glyph->Width;
+	glyph.dimensions.y = bm_glyph->Height;
 
 
-    // Set the glyph's bearing.
-    glyph.bearing.x = bm_glyph->XOffset;
-    glyph.bearing.y = bm_glyph->YOffset;
+	// Set the glyph's bearing.
+	glyph.bearing.x = bm_glyph->XOffset;
+	glyph.bearing.y = bm_glyph->YOffset;
 
 
-    // Set the glyph's advance.
-    glyph.advance = bm_glyph->Advance;
+	// Set the glyph's advance.
+	glyph.advance = bm_glyph->Advance;
 
 
-    // Set the glyph's bitmap position.
-    glyph.bitmap_dimensions.x = bm_glyph->X;
-    glyph.bitmap_dimensions.y = bm_glyph->Y;
+	// Set the glyph's bitmap position.
+	glyph.bitmap_dimensions.x = bm_glyph->X;
+	glyph.bitmap_dimensions.y = bm_glyph->Y;
 
 
-    glyph.bitmap_data = NULL;
+	glyph.bitmap_data = NULL;
 }
 }
 
 
 int Rocket::Core::BitmapFont::FontFaceHandle::GetKerning(word lhs, word rhs) const
 int Rocket::Core::BitmapFont::FontFaceHandle::GetKerning(word lhs, word rhs) const
 {
 {
-    if( bm_face != NULL)
-    {
-        return bm_face->BM_Helper_GetXKerning(lhs, rhs);
-    }
+	if( bm_face != NULL)
+	{
+		return bm_face->BM_Helper_GetXKerning(lhs, rhs);
+	}
 
 
-    return 0;
+	return 0;
 }
 }
 
 
 // Generates (or shares) a layer derived from a font effect.
 // Generates (or shares) a layer derived from a font effect.
 Rocket::Core::FontFaceLayer* FontFaceHandle::GenerateLayer( FontEffect* font_effect)
 Rocket::Core::FontFaceLayer* FontFaceHandle::GenerateLayer( FontEffect* font_effect)
 {
 {
-    // See if this effect has been instanced before, as part of a different configuration.
-    FontLayerMap::iterator i = layers.find(font_effect);
-    if (i != layers.end())
-        return i->second;
-
-    Rocket::Core::FontFaceLayer* layer = new Rocket::Core::BitmapFont::FontFaceLayer();
-    layers[font_effect] = layer;
-
-    if (font_effect == NULL)
-    {
-        layer->Initialise(this);
-    }
-    else
-    {
-        // Determine which, if any, layer the new layer should copy its geometry and textures from.
-        Rocket::Core::FontFaceLayer* clone = NULL;
-        bool deep_clone = true;
-        String generation_key;
-
-        if (!font_effect->HasUniqueTexture())
-        {
-            clone = base_layer;
-            deep_clone = false;
-        }
-        else
-        {
-            generation_key = font_effect->GetName() + ";" + font_effect->GetGenerationKey();
-            FontLayerCache::iterator cache_iterator = layer_cache.find(generation_key);
-            if (cache_iterator != layer_cache.end())
-                clone = cache_iterator->second;
-        }
-
-        // Create a new layer.
-        layer->Initialise(this, font_effect, clone, deep_clone);
-
-        // Cache the layer in the layer cache if it generated its own textures (ie, didn't clone).
-        if (clone == NULL)
-            layer_cache[generation_key] = (Rocket::Core::FontFaceLayer*) layer;
-    }
-
-    return (Rocket::Core::FontFaceLayer*)layer;
+	// See if this effect has been instanced before, as part of a different configuration.
+	FontLayerMap::iterator i = layers.find(font_effect);
+	if (i != layers.end())
+		return i->second;
+
+	Rocket::Core::FontFaceLayer* layer = new Rocket::Core::BitmapFont::FontFaceLayer();
+	layers[font_effect] = layer;
+
+	if (font_effect == NULL)
+	{
+		layer->Initialise(this);
+	}
+	else
+	{
+		// Determine which, if any, layer the new layer should copy its geometry and textures from.
+		Rocket::Core::FontFaceLayer* clone = NULL;
+		bool deep_clone = true;
+		String generation_key;
+
+		if (!font_effect->HasUniqueTexture())
+		{
+			clone = base_layer;
+			deep_clone = false;
+		}
+		else
+		{
+			generation_key = font_effect->GetName() + ";" + font_effect->GetGenerationKey();
+			FontLayerCache::iterator cache_iterator = layer_cache.find(generation_key);
+			if (cache_iterator != layer_cache.end())
+				clone = cache_iterator->second;
+		}
+
+		// Create a new layer.
+		layer->Initialise(this, font_effect, clone, deep_clone);
+
+		// Cache the layer in the layer cache if it generated its own textures (ie, didn't clone).
+		if (clone == NULL)
+			layer_cache[generation_key] = (Rocket::Core::FontFaceLayer*) layer;
+	}
+
+	return (Rocket::Core::FontFaceLayer*)layer;
 }
 }
 
 
 }
 }

+ 72 - 72
Source/Core/BitmapFont/FontFaceHandle.h

@@ -43,90 +43,90 @@ namespace Core {
 namespace BitmapFont {
 namespace BitmapFont {
 
 
 /**
 /**
-    @author Peter Curry
+	@author Peter Curry
  */
  */
 
 
 class FontFaceHandle : public Rocket::Core::FontFaceHandle
 class FontFaceHandle : public Rocket::Core::FontFaceHandle
 {
 {
 public:
 public:
-    FontFaceHandle();
-    virtual ~FontFaceHandle();
-
-    /// Initialises the handle so it is able to render text.
-    /// @param[in] ft_face The FreeType face that this handle is rendering.
-    /// @param[in] charset The comma-separated list of unicode ranges this handle must support.
-    /// @param[in] size The size, in points, of the face this handle should render at.
-    /// @return True if the handle initialised successfully and is ready for rendering, false if an error occured.
-    bool Initialise(BitmapFontDefinitions *bm_face, const String& charset, int size);
-
-    /// Returns the width a string will take up if rendered with this handle.
-    /// @param[in] string The string to measure.
-    /// @param[in] prior_character The optionally-specified character that immediately precedes the string. This may have an impact on the string width due to kerning.
-    /// @return The width, in pixels, this string will occupy if rendered with this handle.
-    int GetStringWidth(const WString& string, word prior_character = 0) const;
-
-    /// Generates, if required, the layer configuration for a given array of font effects.
-    /// @param[in] font_effects The list of font effects to generate the configuration for.
-    /// @return The index to use when generating geometry using this configuration.
-    int GenerateLayerConfiguration(Rocket::Core::FontEffectMap& font_effects);
-
-    /// Generates the texture data for a layer (for the texture database).
-    /// @param[out] texture_data The pointer to be set to the generated texture data.
-    /// @param[out] texture_dimensions The dimensions of the texture.
-    /// @param[in] layer_id The id of the layer to request the texture data from.
-    /// @param[in] texture_id The index of the texture within the layer to generate.
-    bool GenerateLayerTexture(const byte*& texture_data, Vector2i& texture_dimensions, FontEffect* layer_id, int texture_id);
-
-    /// Generates the geometry required to render a single line of text.
-    /// @param[out] geometry An array of geometries to generate the geometry into.
-    /// @param[in] string The string to render.
-    /// @param[in] position The position of the baseline of the first character to render.
-    /// @param[in] colour The colour to render the text.
-    /// @return The width, in pixels, of the string geometry.
-    int GenerateString(GeometryList& geometry, const WString& string, const Vector2f& position, const Colourb& colour, int layer_configuration = 0) const;
-
-    /// Generates the geometry required to render a line above, below or through a line of text.
-    /// @param[out] geometry The geometry to append the newly created geometry into.
-    /// @param[in] position The position of the baseline of the lined text.
-    /// @param[in] width The width of the string to line.
-    /// @param[in] height The height to render the line at.
-    /// @param[in] colour The colour to draw the line in.
-    void GenerateLine(Geometry* geometry, const Vector2f& position, int width, Font::Line height, const Colourb& colour) const;
-
-    const String & GetTextureSource() const
-    {
-        return texture_source;
-    }
-
-    unsigned int GetTextureWidth() const
-    {
-        return texture_width;
-    }
-
-    unsigned int GetTextureHeight() const
-    {
-        return texture_height;
-    }
+	FontFaceHandle();
+	virtual ~FontFaceHandle();
+
+	/// Initialises the handle so it is able to render text.
+	/// @param[in] ft_face The FreeType face that this handle is rendering.
+	/// @param[in] charset The comma-separated list of unicode ranges this handle must support.
+	/// @param[in] size The size, in points, of the face this handle should render at.
+	/// @return True if the handle initialised successfully and is ready for rendering, false if an error occured.
+	bool Initialise(BitmapFontDefinitions *bm_face, const String& charset, int size);
+
+	/// Returns the width a string will take up if rendered with this handle.
+	/// @param[in] string The string to measure.
+	/// @param[in] prior_character The optionally-specified character that immediately precedes the string. This may have an impact on the string width due to kerning.
+	/// @return The width, in pixels, this string will occupy if rendered with this handle.
+	int GetStringWidth(const WString& string, word prior_character = 0) const;
+
+	/// Generates, if required, the layer configuration for a given array of font effects.
+	/// @param[in] font_effects The list of font effects to generate the configuration for.
+	/// @return The index to use when generating geometry using this configuration.
+	int GenerateLayerConfiguration(Rocket::Core::FontEffectMap& font_effects);
+
+	/// Generates the texture data for a layer (for the texture database).
+	/// @param[out] texture_data The pointer to be set to the generated texture data.
+	/// @param[out] texture_dimensions The dimensions of the texture.
+	/// @param[in] layer_id The id of the layer to request the texture data from.
+	/// @param[in] texture_id The index of the texture within the layer to generate.
+	bool GenerateLayerTexture(const byte*& texture_data, Vector2i& texture_dimensions, FontEffect* layer_id, int texture_id);
+
+	/// Generates the geometry required to render a single line of text.
+	/// @param[out] geometry An array of geometries to generate the geometry into.
+	/// @param[in] string The string to render.
+	/// @param[in] position The position of the baseline of the first character to render.
+	/// @param[in] colour The colour to render the text.
+	/// @return The width, in pixels, of the string geometry.
+	int GenerateString(GeometryList& geometry, const WString& string, const Vector2f& position, const Colourb& colour, int layer_configuration = 0) const;
+
+	/// Generates the geometry required to render a line above, below or through a line of text.
+	/// @param[out] geometry The geometry to append the newly created geometry into.
+	/// @param[in] position The position of the baseline of the lined text.
+	/// @param[in] width The width of the string to line.
+	/// @param[in] height The height to render the line at.
+	/// @param[in] colour The colour to draw the line in.
+	void GenerateLine(Geometry* geometry, const Vector2f& position, int width, Font::Line height, const Colourb& colour) const;
+
+	const String & GetTextureSource() const
+	{
+		return texture_source;
+	}
+
+	unsigned int GetTextureWidth() const
+	{
+		return texture_width;
+	}
+
+	unsigned int GetTextureHeight() const
+	{
+		return texture_height;
+	}
 
 
 protected:
 protected:
-    /// Destroys the handle.
-    virtual void OnReferenceDeactivate();
+	/// Destroys the handle.
+	virtual void OnReferenceDeactivate();
 
 
 private:
 private:
-    void GenerateMetrics(BitmapFontDefinitions *bm_face);
+	void GenerateMetrics(BitmapFontDefinitions *bm_face);
 
 
-    void BuildGlyphMap(BitmapFontDefinitions *bm_face, const UnicodeRange& unicode_range);
-    void BuildGlyph(FontGlyph& glyph, CharacterInfo *ft_glyph);
-    int GetKerning(word lhs, word rhs) const;
+	void BuildGlyphMap(BitmapFontDefinitions *bm_face, const UnicodeRange& unicode_range);
+	void BuildGlyph(FontGlyph& glyph, CharacterInfo *ft_glyph);
+	int GetKerning(word lhs, word rhs) const;
 
 
-    // Generates (or shares) a layer derived from a font effect.
-    virtual FontFaceLayer* GenerateLayer(FontEffect* font_effect);
+	// Generates (or shares) a layer derived from a font effect.
+	virtual FontFaceLayer* GenerateLayer(FontEffect* font_effect);
 
 
-    BitmapFontDefinitions * bm_face;
-    String texture_source;
-    String texture_directory;
-    unsigned int texture_width;
-    unsigned int texture_height;
+	BitmapFontDefinitions * bm_face;
+	String texture_source;
+	String texture_directory;
+	unsigned int texture_width;
+	unsigned int texture_height;
 };
 };
 
 
 }
 }

+ 54 - 54
Source/Core/BitmapFont/FontFaceLayer.cpp

@@ -35,8 +35,8 @@ namespace BitmapFont {
 
 
 FontFaceLayer::FontFaceLayer() : Rocket::Core::FontFaceLayer()
 FontFaceLayer::FontFaceLayer() : Rocket::Core::FontFaceLayer()
 {
 {
-    handle = NULL;
-    effect = NULL;
+	handle = NULL;
+	effect = NULL;
 }
 }
 
 
 FontFaceLayer::~FontFaceLayer()
 FontFaceLayer::~FontFaceLayer()
@@ -46,80 +46,80 @@ FontFaceLayer::~FontFaceLayer()
 // Generates the character and texture data for the layer.
 // Generates the character and texture data for the layer.
 bool FontFaceLayer::Initialise(const Rocket::Core::FontFaceHandle* _handle, FontEffect* _effect, const Rocket::Core::FontFaceLayer* clone, bool deep_clone)
 bool FontFaceLayer::Initialise(const Rocket::Core::FontFaceHandle* _handle, FontEffect* _effect, const Rocket::Core::FontFaceLayer* clone, bool deep_clone)
 {
 {
-    (void)(_effect);
+	(void)(_effect);
 
 
-    Rocket::Core::BitmapFont::FontFaceHandle
-        * bm_font_face_handle;
+	Rocket::Core::BitmapFont::FontFaceHandle
+		* bm_font_face_handle;
 
 
-    handle = _handle;
+	handle = _handle;
 
 
-    bm_font_face_handle = ( Rocket::Core::BitmapFont::FontFaceHandle * ) handle;
+	bm_font_face_handle = ( Rocket::Core::BitmapFont::FontFaceHandle * ) handle;
 
 
-    const FontGlyphList& glyphs = handle->GetGlyphs();
+	const FontGlyphList& glyphs = handle->GetGlyphs();
 
 
-    // Clone the geometry and textures from the clone layer.
-    if (clone != NULL)
-    {
-        // Copy the cloned layer's characters.
-        characters = clone->characters;
+	// Clone the geometry and textures from the clone layer.
+	if (clone != NULL)
+	{
+		// Copy the cloned layer's characters.
+		characters = clone->characters;
 
 
-        // Copy (and reference) the cloned layer's textures.
-        for (size_t i = 0; i < clone->textures.size(); ++i)
-            textures.push_back(clone->textures[i]);
-    }
-    else
-    {
-        // Load texture from file
-        Texture texture;
-        if (!texture.Load( bm_font_face_handle->GetTextureSource() ))
-            return false;
+		// Copy (and reference) the cloned layer's textures.
+		for (size_t i = 0; i < clone->textures.size(); ++i)
+			textures.push_back(clone->textures[i]);
+	}
+	else
+	{
+		// Load texture from file
+		Texture texture;
+		if (!texture.Load( bm_font_face_handle->GetTextureSource() ))
+			return false;
 
 
-        textures.push_back(texture);
+		textures.push_back(texture);
 
 
-        // Initialise the texture layout for the glyphs.
-        characters.resize(glyphs.size(), Character());
-        for (FontGlyphList::const_iterator i = glyphs.begin(); i != glyphs.end(); ++i)
-        {            
-            const FontGlyph& glyph = *i;
+		// Initialise the texture layout for the glyphs.
+		characters.resize(glyphs.size(), Character());
+		for (FontGlyphList::const_iterator i = glyphs.begin(); i != glyphs.end(); ++i)
+		{
+			const FontGlyph& glyph = *i;
 
 
-            if(glyph.dimensions.x <= 0 || glyph.dimensions.y <= 0)
-                continue;
+			if(glyph.dimensions.x <= 0 || glyph.dimensions.y <= 0)
+				continue;
 
 
-            Vector2i glyph_origin( glyph.bitmap_dimensions.x, glyph.bitmap_dimensions.y ); // position in texture
-            Vector2i glyph_dimensions = glyph.dimensions; // size of char
+			Vector2i glyph_origin( glyph.bitmap_dimensions.x, glyph.bitmap_dimensions.y ); // position in texture
+			Vector2i glyph_dimensions = glyph.dimensions; // size of char
 
 
-            Character character;
-            character.origin = Vector2f((float) (glyph.bearing.x), (float) (glyph.bearing.y) - handle->GetBaseline()*3 );
-            character.dimensions = Vector2f((float) glyph.dimensions.x, (float) glyph.dimensions.y);
+			Character character;
+			character.origin = Vector2f((float) (glyph.bearing.x), (float) (glyph.bearing.y) - handle->GetBaseline()*3 );
+			character.dimensions = Vector2f((float) glyph.dimensions.x, (float) glyph.dimensions.y);
 
 
-            // Set the character's texture index.
-            character.texture_index = 0;
+			// Set the character's texture index.
+			character.texture_index = 0;
 
 
-            // Generate the character's texture coordinates.
-            character.texcoords[0].x = float(glyph_origin.x) / float(bm_font_face_handle->GetTextureWidth());
-            character.texcoords[0].y = float(glyph_origin.y) / float(bm_font_face_handle->GetTextureHeight());
-            character.texcoords[1].x = float(glyph_origin.x + character.dimensions.x) / float(bm_font_face_handle->GetTextureWidth());
-            character.texcoords[1].y = float(glyph_origin.y + character.dimensions.y) / float(bm_font_face_handle->GetTextureHeight());
+			// Generate the character's texture coordinates.
+			character.texcoords[0].x = float(glyph_origin.x) / float(bm_font_face_handle->GetTextureWidth());
+			character.texcoords[0].y = float(glyph_origin.y) / float(bm_font_face_handle->GetTextureHeight());
+			character.texcoords[1].x = float(glyph_origin.x + character.dimensions.x) / float(bm_font_face_handle->GetTextureWidth());
+			character.texcoords[1].y = float(glyph_origin.y + character.dimensions.y) / float(bm_font_face_handle->GetTextureHeight());
 
 
-            characters[glyph.character] = character;
+			characters[glyph.character] = character;
 
 
-            // Add the character's dimensions into the texture layout engine.
-            texture_layout.AddRectangle(glyph.character, glyph_dimensions);
-        }
+			// Add the character's dimensions into the texture layout engine.
+			texture_layout.AddRectangle(glyph.character, glyph_dimensions);
+		}
 
 
-        // Generate the texture layout; this will position the glyph rectangles efficiently and
-        // allocate the texture data ready for writing.
-        if (!texture_layout.GenerateLayout(512))
-            return false;
+		// Generate the texture layout; this will position the glyph rectangles efficiently and
+		// allocate the texture data ready for writing.
+		if (!texture_layout.GenerateLayout(512))
+			return false;
 
 
-    }
-    return true;
+	}
+	return true;
 }
 }
 
 
 // Generates the texture data for a layer (for the texture database).
 // Generates the texture data for a layer (for the texture database).
 bool FontFaceLayer::GenerateTexture(const byte*& texture_data, Vector2i& texture_dimensions, int texture_id)
 bool FontFaceLayer::GenerateTexture(const byte*& texture_data, Vector2i& texture_dimensions, int texture_id)
 {
 {
-    return true;
+	return true;
 }
 }
 
 
 }
 }

+ 19 - 19
Source/Core/BitmapFont/FontFaceLayer.h

@@ -38,36 +38,36 @@
 namespace Rocket {
 namespace Rocket {
 namespace Core {
 namespace Core {
 
 
-    class TextureLayout;
+	class TextureLayout;
 
 
 namespace BitmapFont {
 namespace BitmapFont {
 
 
 /**
 /**
-    A textured layer stored as part of a font face handle. Each handle will have at least a base
-    layer for the standard font. Further layers can be added to allow to rendering of text effects.
-    @author Peter Curry
+	A textured layer stored as part of a font face handle. Each handle will have at least a base
+	layer for the standard font. Further layers can be added to allow to rendering of text effects.
+	@author Peter Curry
  */
  */
 
 
 class FontFaceLayer : public Rocket::Core::FontFaceLayer
 class FontFaceLayer : public Rocket::Core::FontFaceLayer
 {
 {
 public:
 public:
-    FontFaceLayer();
-    virtual ~FontFaceLayer();
+	FontFaceLayer();
+	virtual ~FontFaceLayer();
 
 
-    /// Generates the character and texture data for the layer.
-    /// @param[in] handle The handle generating this layer.
-    /// @param[in] effect The effect to initialise the layer with.
-    /// @param[in] clone The layer to optionally clone geometry and texture data from.
-    /// @param[in] deep_clone If true, the clones geometry will be completely cloned and the effect will have no option to affect even the glyph origins.
-    /// @return True if the layer was generated successfully, false if not.
-    virtual bool Initialise(const FontFaceHandle* handle, FontEffect* effect = NULL, const Rocket::Core::FontFaceLayer* clone = NULL, bool deep_clone = false);
+	/// Generates the character and texture data for the layer.
+	/// @param[in] handle The handle generating this layer.
+	/// @param[in] effect The effect to initialise the layer with.
+	/// @param[in] clone The layer to optionally clone geometry and texture data from.
+	/// @param[in] deep_clone If true, the clones geometry will be completely cloned and the effect will have no option to affect even the glyph origins.
+	/// @return True if the layer was generated successfully, false if not.
+	virtual bool Initialise(const FontFaceHandle* handle, FontEffect* effect = NULL, const Rocket::Core::FontFaceLayer* clone = NULL, bool deep_clone = false);
 
 
-    /// Generates the texture data for a layer (for the texture database).
-    /// @param[out] texture_data The pointer to be set to the generated texture data.
-    /// @param[out] texture_dimensions The dimensions of the texture.
-    /// @param[in] glyphs The glyphs required by the font face handle.
-    /// @param[in] texture_id The index of the texture within the layer to generate.
-    virtual bool GenerateTexture(const byte*& texture_data, Vector2i& texture_dimensions, int texture_id);
+	/// Generates the texture data for a layer (for the texture database).
+	/// @param[out] texture_data The pointer to be set to the generated texture data.
+	/// @param[out] texture_dimensions The dimensions of the texture.
+	/// @param[in] glyphs The glyphs required by the font face handle.
+	/// @param[in] texture_id The index of the texture within the layer to generate.
+	virtual bool GenerateTexture(const byte*& texture_data, Vector2i& texture_dimensions, int texture_id);
 
 
 };
 };
 
 

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

@@ -44,10 +44,10 @@ FontFamily::~FontFamily()
 // Adds a new face to the family.
 // Adds a new face to the family.
 bool FontFamily::AddFace( void *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((BitmapFontDefinitions*)bm_face, style, weight, release_stream);
-    font_faces.push_back(face);
+	Rocket::Core::FontFace* face = new FontFace((BitmapFontDefinitions*)bm_face, style, weight, release_stream);
+	font_faces.push_back(face);
 
 
-    return true;
+	return true;
 }
 }
 
 
 }
 }

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

@@ -41,22 +41,22 @@ class FontFaceHandle;
 namespace BitmapFont {
 namespace BitmapFont {
 
 
 /**
 /**
-    @author Peter Curry
+	@author Peter Curry
  */
  */
 
 
 class FontFamily : public Rocket::Core::FontFamily
 class FontFamily : public Rocket::Core::FontFamily
 {
 {
 public:
 public:
-    FontFamily(const String& name);
-    ~FontFamily();
+	FontFamily(const String& name);
+	~FontFamily();
 
 
-    /// Adds a new face to the family.
-    /// @param[in] ft_face The previously loaded FreeType face.
-    /// @param[in] style The style 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.
-    /// @return True if the face was loaded successfully, false otherwise.
-    bool AddFace( void *bm_face, Font::Style style, Font::Weight weight, bool release_stream);
+	/// Adds a new face to the family.
+	/// @param[in] ft_face The previously loaded FreeType face.
+	/// @param[in] style The style 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.
+	/// @return True if the face was loaded successfully, false otherwise.
+	bool AddFace( void *bm_face, Font::Style style, Font::Weight weight, bool release_stream);
 };
 };
 
 
 }
 }

+ 50 - 50
Source/Core/BitmapFont/FontParser.cpp

@@ -33,11 +33,11 @@ namespace Core {
 namespace BitmapFont {
 namespace BitmapFont {
 
 
 FontParser::FontParser( BitmapFontDefinitions *face )
 FontParser::FontParser( BitmapFontDefinitions *face )
-    : BaseXMLParser()
+	: BaseXMLParser()
 {
 {
-    bm_face = face;
-    char_id = 0;
-    kern_id = 0;
+	bm_face = face;
+	char_id = 0;
+	kern_id = 0;
 }
 }
 
 
 FontParser::~FontParser()
 FontParser::~FontParser()
@@ -47,54 +47,54 @@ FontParser::~FontParser()
 // Called when the parser finds the beginning of an element tag.
 // Called when the parser finds the beginning of an element tag.
 void FontParser::HandleElementStart(const String& name, const XMLAttributes& attributes)
 void FontParser::HandleElementStart(const String& name, const XMLAttributes& attributes)
 {
 {
-    if ( name == "info" )
-    {
-        bm_face->Face.FamilyName = 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.BitmapSource = attributes.Get( "src" )->Get< String >();
-    }
-    else if ( name == "common" )
-    {
-        bm_face->CommonCharactersInfo.LineHeight = attributes.Get( "lineHeight" )->Get< int >();
-        bm_face->CommonCharactersInfo.BaseLine = attributes.Get( "base" )->Get< int >() * -1;
-        bm_face->CommonCharactersInfo.ScaleWidth = attributes.Get( "scaleW" )->Get< int >();
-        bm_face->CommonCharactersInfo.ScaleHeight = attributes.Get( "scaleH" )->Get< int >();
-        bm_face->CommonCharactersInfo.CharacterCount = 0;
-        bm_face->CommonCharactersInfo.KerningCount = 0;
-    }
-    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 >();
+	if ( name == "info" )
+	{
+		bm_face->Face.FamilyName = 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.BitmapSource = attributes.Get( "src" )->Get< String >();
+	}
+	else if ( name == "common" )
+	{
+		bm_face->CommonCharactersInfo.LineHeight = attributes.Get( "lineHeight" )->Get< int >();
+		bm_face->CommonCharactersInfo.BaseLine = attributes.Get( "base" )->Get< int >() * -1;
+		bm_face->CommonCharactersInfo.ScaleWidth = attributes.Get( "scaleW" )->Get< int >();
+		bm_face->CommonCharactersInfo.ScaleHeight = attributes.Get( "scaleH" )->Get< int >();
+		bm_face->CommonCharactersInfo.CharacterCount = 0;
+		bm_face->CommonCharactersInfo.KerningCount = 0;
+	}
+	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 >();
 
 
-        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 >();
+		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++;
-    }
+		kern_id++;
+	}
 }
 }
 
 
 // Called when the parser finds the end of an element tag.
 // Called when the parser finds the end of an element tag.

+ 15 - 15
Source/Core/BitmapFont/FontParser.h

@@ -39,27 +39,27 @@ namespace Core {
 namespace BitmapFont {
 namespace BitmapFont {
 
 
 /**
 /**
-    @author Peter Curry
+	@author Peter Curry
  */
  */
 
 
 class FontParser : public BaseXMLParser
 class FontParser : public BaseXMLParser
 {
 {
-    public:
-        FontParser( BitmapFontDefinitions *face );
-        virtual ~FontParser();
+	public:
+		FontParser( BitmapFontDefinitions *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);
+		/// 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();
-        BitmapFontDefinitions *bm_face;
-        int char_id;
-        int kern_id;
+	private:
+		FontParser();
+		BitmapFontDefinitions *bm_face;
+		int char_id;
+		int kern_id;
 };
 };
 
 
 }
 }

+ 99 - 99
Source/Core/BitmapFont/FontProvider.cpp

@@ -44,163 +44,163 @@ FontProvider* FontProvider::instance = NULL;
 
 
 FontProvider::FontProvider()
 FontProvider::FontProvider()
 {
 {
-    ROCKET_ASSERT(instance == NULL);
-    instance = this;
+	ROCKET_ASSERT(instance == NULL);
+	instance = this;
 }
 }
 
 
 FontProvider::~FontProvider()
 FontProvider::~FontProvider()
 {
 {
-    ROCKET_ASSERT(instance == this);
-    instance = NULL;
+	ROCKET_ASSERT(instance == this);
+	instance = NULL;
 }
 }
 
 
 bool FontProvider::Initialise()
 bool FontProvider::Initialise()
 {
 {
-    if (instance == NULL)
-    {
-        new FontProvider();
+	if (instance == NULL)
+	{
+		new FontProvider();
 
 
-        FontDatabase::AddFontProvider(instance);
-    }
+		FontDatabase::AddFontProvider(instance);
+	}
 
 
-    return true;
+	return true;
 }
 }
 
 
 void FontProvider::Shutdown()
 void FontProvider::Shutdown()
 {
 {
-    if (instance != NULL)
-    {
-        FontDatabase::RemoveFontProvider(instance);
-        delete instance;
-        instance = NULL;
-    }
+	if (instance != NULL)
+	{
+		FontDatabase::RemoveFontProvider(instance);
+		delete instance;
+		instance = NULL;
+	}
 }
 }
 
 
 // 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)
 {
 {
-    BitmapFontDefinitions *bm_font = (BitmapFontDefinitions*) 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;
-    }
-
-    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;
-    }
-
-    return true;
+	BitmapFontDefinitions *bm_font = (BitmapFontDefinitions*) 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;
+	}
+
+	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;
+	}
+
+	return true;
 }
 }
 
 
 // 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)
 {
 {
-    BitmapFontDefinitions *bm_font = (BitmapFontDefinitions*) 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, 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;
+	BitmapFontDefinitions *bm_font = (BitmapFontDefinitions*) 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, 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;
 }
 }
 
 
 bool FontProvider::LoadFontFace(const byte* data, int data_length)
 bool FontProvider::LoadFontFace(const byte* data, int data_length)
 {
 {
-    // TODO: Loading from memory
-    return false;
+	// TODO: Loading from memory
+	return false;
 }
 }
 
 
 // Adds a new font face to the database, loading from memory.
 // Adds a new font face to the database, loading from memory.
 bool FontProvider::LoadFontFace(const byte* data, int data_length, const String& family, Font::Style style, Font::Weight weight)
 bool FontProvider::LoadFontFace(const byte* data, int data_length, const String& family, Font::Style style, Font::Weight weight)
 {
 {
-    // TODO Loading from memory
-    return false;
+	// TODO Loading from memory
+	return false;
 }
 }
 
 
 // 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)
 {
 {
-    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((BitmapFontDefinitions *) face, style, weight, release_stream);
-    return true;
+	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((BitmapFontDefinitions *) face, style, weight, release_stream);
+	return true;
 }
 }
 
 
 // Loads a FreeType face.
 // Loads a FreeType face.
 void* FontProvider::LoadFace(const String& file_name)
 void* FontProvider::LoadFace(const String& file_name)
 {
 {
-    BitmapFontDefinitions *bm_face = new BitmapFontDefinitions();
-    FontParser parser( bm_face );
+	BitmapFontDefinitions *bm_face = new BitmapFontDefinitions();
+	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 );
 
 
-    bm_face->Face.Source = file_name;
-    return bm_face;
+	bm_face->Face.Source = file_name;
+	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";
 
 
-    BitmapFontDefinitions *bm_face = new BitmapFontDefinitions();
-    FontParser parser( bm_face );
-    StreamMemory* stream = new StreamMemory( data, data_length );
-    stream->SetSourceURL( file_url );
+	BitmapFontDefinitions *bm_face = new BitmapFontDefinitions();
+	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.GetPathedFileName();
-    return bm_face;
+	bm_face->Face.Source = file_url.GetPathedFileName();
+	return bm_face;
 }
 }
 
 
 }
 }

+ 0 - 18
Source/Core/FontFaceHandle.cpp

@@ -307,24 +307,6 @@ void FontFaceHandle::OnReferenceDeactivate()
 	delete this;
 	delete this;
 }
 }
 
 
-int FontFaceHandle::GetKerning(word lhs, word rhs) const
-{
-    /*if(rhs >= kerning.size())
-        return 0;
-
-    FontKerningList::const_iterator rhs_iterator = kerning.find(rhs);
-    if (rhs_iterator == kerning.end())
-        return 0;
-
-    GlyphKerningList::const_iterator lhs_iterator = rhs_iterator->find(lhs);
-    if (lhs_iterator == (*rhs_iterator).end())
-        return 0;
-
-    return *lhs_iterator;*/
-
-    return 0;
-}
-
 // Generates (or shares) a layer derived from a font effect.
 // Generates (or shares) a layer derived from a font effect.
 FontFaceLayer* FontFaceHandle::GenerateLayer(FontEffect* font_effect)
 FontFaceLayer* FontFaceHandle::GenerateLayer(FontEffect* font_effect)
 {
 {

+ 16 - 16
Source/Core/FontFaceHandle.h

@@ -54,42 +54,42 @@ public:
 
 
 	/// Returns the average advance of all glyphs in this font face.
 	/// Returns the average advance of all glyphs in this font face.
 	/// @return An approximate width of the characters in this font face.
 	/// @return An approximate width of the characters in this font face.
-    int GetCharacterWidth() const;
+	int GetCharacterWidth() const;
 
 
 	/// Returns the point size of this font face.
 	/// Returns the point size of this font face.
 	/// @return The face's point size.
 	/// @return The face's point size.
-    int GetSize() const;
+	int GetSize() const;
 	/// Returns the pixel height of a lower-case x in this font face.
 	/// Returns the pixel height of a lower-case x in this font face.
 	/// @return The height of a lower-case x.
 	/// @return The height of a lower-case x.
-    int GetXHeight() const;
+	int GetXHeight() const;
 	/// Returns the default height between this font face's baselines.
 	/// Returns the default height between this font face's baselines.
 	/// @return The default line height.
 	/// @return The default line height.
-    int GetLineHeight() const;
+	int GetLineHeight() const;
 
 
 	/// Returns the font's baseline, as a pixel offset from the bottom of the font.
 	/// Returns the font's baseline, as a pixel offset from the bottom of the font.
 	/// @return The font's baseline.
 	/// @return The font's baseline.
-    int GetBaseline() const;
+	int GetBaseline() const;
 
 
 	/// Returns the font's glyphs.
 	/// Returns the font's glyphs.
 	/// @return The font's glyphs.
 	/// @return The font's glyphs.
-    const FontGlyphList& GetGlyphs() const;
+	const FontGlyphList& GetGlyphs() const;
 
 
 	/// Returns the width a string will take up if rendered with this handle.
 	/// Returns the width a string will take up if rendered with this handle.
 	/// @param[in] string The string to measure.
 	/// @param[in] string The string to measure.
 	/// @param[in] prior_character The optionally-specified character that immediately precedes the string. This may have an impact on the string width due to kerning.
 	/// @param[in] prior_character The optionally-specified character that immediately precedes the string. This may have an impact on the string width due to kerning.
 	/// @return The width, in pixels, this string will occupy if rendered with this handle.
 	/// @return The width, in pixels, this string will occupy if rendered with this handle.
-    virtual int GetStringWidth(const WString& string, word prior_character = 0) const = 0;
+	virtual int GetStringWidth(const WString& string, word prior_character = 0) const = 0;
 
 
 	/// Generates, if required, the layer configuration for a given array of font effects.
 	/// Generates, if required, the layer configuration for a given array of font effects.
 	/// @param[in] font_effects The list of font effects to generate the configuration for.
 	/// @param[in] font_effects The list of font effects to generate the configuration for.
 	/// @return The index to use when generating geometry using this configuration.
 	/// @return The index to use when generating geometry using this configuration.
-    virtual int GenerateLayerConfiguration(FontEffectMap& font_effects) = 0;
+	virtual int GenerateLayerConfiguration(FontEffectMap& font_effects) = 0;
 	/// Generates the texture data for a layer (for the texture database).
 	/// Generates the texture data for a layer (for the texture database).
 	/// @param[out] texture_data The pointer to be set to the generated texture data.
 	/// @param[out] texture_data The pointer to be set to the generated texture data.
 	/// @param[out] texture_dimensions The dimensions of the texture.
 	/// @param[out] texture_dimensions The dimensions of the texture.
 	/// @param[in] layer_id The id of the layer to request the texture data from.
 	/// @param[in] layer_id The id of the layer to request the texture data from.
 	/// @param[in] texture_id The index of the texture within the layer to generate.
 	/// @param[in] texture_id The index of the texture within the layer to generate.
-    virtual bool GenerateLayerTexture(const byte*& texture_data, Vector2i& texture_dimensions, FontEffect* layer_id, int texture_id) = 0;
+	virtual bool GenerateLayerTexture(const byte*& texture_data, Vector2i& texture_dimensions, FontEffect* layer_id, int texture_id) = 0;
 
 
 	/// Generates the geometry required to render a single line of text.
 	/// Generates the geometry required to render a single line of text.
 	/// @param[out] geometry An array of geometries to generate the geometry into.
 	/// @param[out] geometry An array of geometries to generate the geometry into.
@@ -97,33 +97,33 @@ public:
 	/// @param[in] position The position of the baseline of the first character to render.
 	/// @param[in] position The position of the baseline of the first character to render.
 	/// @param[in] colour The colour to render the text.
 	/// @param[in] colour The colour to render the text.
 	/// @return The width, in pixels, of the string geometry.
 	/// @return The width, in pixels, of the string geometry.
-    virtual int GenerateString(GeometryList& geometry, const WString& string, const Vector2f& position, const Colourb& colour, int layer_configuration = 0) const = 0;
+	virtual int GenerateString(GeometryList& geometry, const WString& string, const Vector2f& position, const Colourb& colour, int layer_configuration = 0) const = 0;
 	/// Generates the geometry required to render a line above, below or through a line of text.
 	/// Generates the geometry required to render a line above, below or through a line of text.
 	/// @param[out] geometry The geometry to append the newly created geometry into.
 	/// @param[out] geometry The geometry to append the newly created geometry into.
 	/// @param[in] position The position of the baseline of the lined text.
 	/// @param[in] position The position of the baseline of the lined text.
 	/// @param[in] width The width of the string to line.
 	/// @param[in] width The width of the string to line.
 	/// @param[in] height The height to render the line at.
 	/// @param[in] height The height to render the line at.
 	/// @param[in] colour The colour to draw the line in.
 	/// @param[in] colour The colour to draw the line in.
-    virtual void GenerateLine(Geometry* geometry, const Vector2f& position, int width, Font::Line height, const Colourb& colour) const = 0;
+	virtual void GenerateLine(Geometry* geometry, const Vector2f& position, int width, Font::Line height, const Colourb& colour) const = 0;
 
 
 	/// Returns the font face's raw charset (the charset range as a string).
 	/// Returns the font face's raw charset (the charset range as a string).
 	/// @return The font face's charset.
 	/// @return The font face's charset.
-    const String& GetRawCharset() const;
+	const String& GetRawCharset() const;
 	/// Returns the font face's charset.
 	/// Returns the font face's charset.
 	/// @return The font face's charset.
 	/// @return The font face's charset.
-    const UnicodeRangeList& GetCharset() const;
+	const UnicodeRangeList& GetCharset() const;
 
 
 protected:
 protected:
 	/// Destroys the handle.
 	/// Destroys the handle.
 	virtual void OnReferenceDeactivate();
 	virtual void OnReferenceDeactivate();
-    FontFaceLayer* GenerateLayer(FontEffect* font_effect);
-    virtual int GetKerning(word lhs, word rhs) const;
+	FontFaceLayer* GenerateLayer(FontEffect* font_effect);
+	virtual int GetKerning(word lhs, word rhs) const = 0;
 
 
 	typedef std::vector< int > GlyphKerningList;
 	typedef std::vector< int > GlyphKerningList;
 	typedef std::vector< GlyphKerningList > FontKerningList;
 	typedef std::vector< GlyphKerningList > FontKerningList;
 
 
 	FontGlyphList glyphs;
 	FontGlyphList glyphs;
-    FontKerningList kerning;
+	FontKerningList kerning;
 
 
 	typedef std::map< const FontEffect*, FontFaceLayer* > FontLayerMap;
 	typedef std::map< const FontEffect*, FontFaceLayer* > FontLayerMap;
 	typedef std::map< String, FontFaceLayer* > FontLayerCache;
 	typedef std::map< String, FontFaceLayer* > FontLayerCache;

+ 2 - 2
Source/Core/FontFaceLayer.h

@@ -60,14 +60,14 @@ public:
 	/// @param[in] clone The layer to optionally clone geometry and texture data from.
 	/// @param[in] clone The layer to optionally clone geometry and texture data from.
 	/// @param[in] deep_clone If true, the clones geometry will be completely cloned and the effect will have no option to affect even the glyph origins.
 	/// @param[in] deep_clone If true, the clones geometry will be completely cloned and the effect will have no option to affect even the glyph origins.
 	/// @return True if the layer was generated successfully, false if not.
 	/// @return True if the layer was generated successfully, false if not.
-    virtual bool Initialise(const FontFaceHandle* handle, FontEffect* effect = NULL, const FontFaceLayer* clone = NULL, bool deep_clone = false);
+	virtual bool Initialise(const FontFaceHandle* handle, FontEffect* effect = NULL, const FontFaceLayer* clone = NULL, bool deep_clone = false);
 
 
 	/// Generates the texture data for a layer (for the texture database).
 	/// Generates the texture data for a layer (for the texture database).
 	/// @param[out] texture_data The pointer to be set to the generated texture data.
 	/// @param[out] texture_data The pointer to be set to the generated texture data.
 	/// @param[out] texture_dimensions The dimensions of the texture.
 	/// @param[out] texture_dimensions The dimensions of the texture.
 	/// @param[in] glyphs The glyphs required by the font face handle.
 	/// @param[in] glyphs The glyphs required by the font face handle.
 	/// @param[in] texture_id The index of the texture within the layer to generate.
 	/// @param[in] texture_id The index of the texture within the layer to generate.
-    virtual bool GenerateTexture(const byte*& texture_data, Vector2i& texture_dimensions, int texture_id);
+	virtual bool GenerateTexture(const byte*& texture_data, Vector2i& texture_dimensions, int texture_id);
 	/// Generates the geometry required to render a single character.
 	/// Generates the geometry required to render a single character.
 	/// @param[out] geometry An array of geometries this layer will write to. It must be at least as big as the number of textures in this layer.
 	/// @param[out] geometry An array of geometries this layer will write to. It must be at least as big as the number of textures in this layer.
 	/// @param[in] character_code The character to generate geometry for.
 	/// @param[in] character_code The character to generate geometry for.

+ 4 - 4
Source/Core/FontProvider.cpp

@@ -34,11 +34,11 @@ namespace Core {
 // Returns a handle to a font face that can be used to position and render text.
 // Returns a handle to a font face that can be used to position and render text.
 Rocket::Core::FontFaceHandle* FontProvider::GetFontFaceHandle(const String& family, const String& charset, Font::Style style, Font::Weight weight, int size)
 Rocket::Core::FontFaceHandle* FontProvider::GetFontFaceHandle(const String& family, const String& charset, Font::Style style, Font::Weight weight, int size)
 {
 {
-    FontFamilyMap::iterator iterator = font_families.find(family);
-    if (iterator == font_families.end())
-        return NULL;
+	FontFamilyMap::iterator iterator = font_families.find(family);
+	if (iterator == font_families.end())
+		return NULL;
 
 
-    return (*iterator).second->GetFaceHandle(charset, style, weight, size);
+	return (*iterator).second->GetFaceHandle(charset, style, weight, size);
 }
 }
 
 
 }
 }

+ 80 - 80
Source/Core/FreeType/FontFace.cpp

@@ -36,102 +36,102 @@ namespace FreeType {
 
 
 FontFace::FontFace(FT_Face _face, Font::Style _style, Font::Weight _weight, bool _release_stream) : Rocket::Core::FontFace(_style, _weight, _release_stream)
 FontFace::FontFace(FT_Face _face, Font::Style _style, Font::Weight _weight, bool _release_stream) : Rocket::Core::FontFace(_style, _weight, _release_stream)
 {
 {
-    face = _face;
+	face = _face;
 }
 }
 
 
 FontFace::~FontFace()
 FontFace::~FontFace()
 {
 {
-    ReleaseFace();
+	ReleaseFace();
 }
 }
 
 
 // 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 (Rocket::Core::FreeType::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 (Rocket::Core::FreeType::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;
+	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 (Rocket::Core::FreeType::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 (Rocket::Core::FreeType::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 FreeType face structure.
 // Releases the face's FreeType face structure.
 void FontFace::ReleaseFace()
 void FontFace::ReleaseFace()
 {
 {
-    if (face != NULL)
-    {
-        FT_Byte* face_memory = face->stream->base;
-        FT_Done_Face(face);
+	if (face != NULL)
+	{
+		FT_Byte* face_memory = face->stream->base;
+		FT_Done_Face(face);
 
 
-        if (release_stream)
-            delete[] face_memory;
+		if (release_stream)
+			delete[] face_memory;
 
 
-        face = NULL;
-    }
+		face = NULL;
+	}
 }
 }
 
 
 }
 }

+ 12 - 12
Source/Core/FreeType/FontFace.h

@@ -36,7 +36,7 @@ namespace Rocket {
 namespace Core {
 namespace Core {
 namespace FreeType {
 namespace FreeType {
 /**
 /**
-    @author Peter Curry
+	@author Peter Curry
  */
  */
 
 
 class FontFaceHandle;
 class FontFaceHandle;
@@ -44,21 +44,21 @@ class FontFaceHandle;
 class FontFace : public Rocket::Core::FontFace
 class FontFace : public Rocket::Core::FontFace
 {
 {
 public:
 public:
-    FontFace(FT_Face face, Font::Style style, Font::Weight weight, bool release_stream);
-    ~FontFace();
+	FontFace(FT_Face face, Font::Style style, Font::Weight weight, bool release_stream);
+	~FontFace();
 
 
-    /// Returns a handle for positioning and rendering this face at the given size.
-    /// @param[in] charset The set of characters in the handle, as a comma-separated list of unicode ranges.
-    /// @param[in] size The size of the desired handle, in points.
-    /// @return The shared font handle.
-    Rocket::Core::FontFaceHandle* GetHandle(const String& charset, int size);
+	/// Returns a handle for positioning and rendering this face at the given size.
+	/// @param[in] charset The set of characters in the handle, as a comma-separated list of unicode ranges.
+	/// @param[in] size The size of the desired handle, in points.
+	/// @return The shared font handle.
+	Rocket::Core::FontFaceHandle* GetHandle(const String& charset, int size);
 
 
-    /// Releases the face's FreeType face structure. This will mean handles for new sizes cannot be constructed,
-    /// but existing ones can still be fetched.
-    void ReleaseFace();
+	/// Releases the face's FreeType face structure. This will mean handles for new sizes cannot be constructed,
+	/// but existing ones can still be fetched.
+	void ReleaseFace();
 
 
 private:
 private:
-    FT_Face face;
+	FT_Face face;
 };
 };
 
 
 }
 }

+ 320 - 320
Source/Core/FreeType/FontFaceHandle.cpp

@@ -39,15 +39,15 @@ namespace FreeType {
 class FontEffectSort
 class FontEffectSort
 {
 {
 public:
 public:
-    bool operator()(const FontEffect* lhs, const FontEffect* rhs)
-    {
-        return lhs->GetZIndex() < rhs->GetZIndex();
-    }
+	bool operator()(const FontEffect* lhs, const FontEffect* rhs)
+	{
+		return lhs->GetZIndex() < rhs->GetZIndex();
+	}
 };
 };
 
 
 FontFaceHandle::FontFaceHandle()
 FontFaceHandle::FontFaceHandle()
 {
 {
-    ft_face = NULL;
+	ft_face = NULL;
 }
 }
 
 
 FontFaceHandle::~FontFaceHandle()
 FontFaceHandle::~FontFaceHandle()
@@ -57,400 +57,400 @@ FontFaceHandle::~FontFaceHandle()
 // Initialises the handle so it is able to render text.
 // Initialises the handle so it is able to render text.
 bool FontFaceHandle::Initialise(FT_Face ft_face, const String& _charset, int _size)
 bool FontFaceHandle::Initialise(FT_Face ft_face, const String& _charset, int _size)
 {
 {
-    size = _size;
+	size = _size;
 
 
-    raw_charset = _charset;
-    if (!UnicodeRange::BuildList(charset, raw_charset))
-    {
-        Log::Message(Log::LT_ERROR, "Invalid font charset '%s'.", raw_charset.CString());
-        return false;
-    }
+	raw_charset = _charset;
+	if (!UnicodeRange::BuildList(charset, raw_charset))
+	{
+		Log::Message(Log::LT_ERROR, "Invalid font charset '%s'.", raw_charset.CString());
+		return false;
+	}
 
 
-    // Set the character size on the font face.
-    FT_Error error = FT_Set_Char_Size(ft_face, 0, size << 6, 0, 0);
-    if (error != 0)
-    {
-        Log::Message(Log::LT_ERROR, "Unable to set the character size '%d' on the font face '%s %s'.", size, ft_face->family_name, ft_face->style_name);
-        return false;
-    }
+	// Set the character size on the font face.
+	FT_Error error = FT_Set_Char_Size(ft_face, 0, size << 6, 0, 0);
+	if (error != 0)
+	{
+		Log::Message(Log::LT_ERROR, "Unable to set the character size '%d' on the font face '%s %s'.", size, ft_face->family_name, ft_face->style_name);
+		return false;
+	}
 
 
-    this->ft_face = ft_face;
+	this->ft_face = ft_face;
 
 
-    // find the maximum character we are interested in
-    max_codepoint = 0;
-    for (size_t i = 0; i < charset.size(); ++i)
-        max_codepoint = Math::Max(max_codepoint, charset[i].max_codepoint);
+	// find the maximum character we are interested in
+	max_codepoint = 0;
+	for (size_t i = 0; i < charset.size(); ++i)
+		max_codepoint = Math::Max(max_codepoint, charset[i].max_codepoint);
 
 
-    // Construct the list of the characters specified by the charset.
-    glyphs.resize(max_codepoint+1, FontGlyph());
-    for (size_t i = 0; i < charset.size(); ++i)
-        BuildGlyphMap(charset[i]);
+	// Construct the list of the characters specified by the charset.
+	glyphs.resize(max_codepoint+1, FontGlyph());
+	for (size_t i = 0; i < charset.size(); ++i)
+		BuildGlyphMap(charset[i]);
 
 
-    // Generate the metrics for the handle.
-    GenerateMetrics();
+	// Generate the metrics for the handle.
+	GenerateMetrics();
 
 
-    // Generate the default layer and layer configuration.
-    base_layer = GenerateLayer(NULL);
-    layer_configurations.push_back(LayerConfiguration());
-    layer_configurations.back().push_back(base_layer);
+	// Generate the default layer and layer configuration.
+	base_layer = GenerateLayer(NULL);
+	layer_configurations.push_back(LayerConfiguration());
+	layer_configurations.back().push_back(base_layer);
 
 
 
 
-    return true;
+	return true;
 }
 }
 
 
 // Returns the width a string will take up if rendered with this handle.
 // Returns the width a string will take up if rendered with this handle.
 int FontFaceHandle::GetStringWidth(const WString& string, word prior_character) const
 int FontFaceHandle::GetStringWidth(const WString& string, word prior_character) const
 {
 {
-    int width = 0;
+	int width = 0;
 
 
-    for (size_t i = 0; i < string.Length(); i++)
-    {
-        word character_code = string[i];
+	for (size_t i = 0; i < string.Length(); i++)
+	{
+		word character_code = string[i];
 
 
-        if (character_code >= glyphs.size())
-            continue;
-        const FontGlyph &glyph = glyphs[character_code];
+		if (character_code >= glyphs.size())
+			continue;
+		const FontGlyph &glyph = glyphs[character_code];
 
 
-        // Adjust the cursor for the kerning between this character and the previous one.
-        if (prior_character != 0)
-            width += GetKerning(prior_character, string[i]);
-        // Adjust the cursor for this character's advance.
-        width += glyph.advance;
+		// Adjust the cursor for the kerning between this character and the previous one.
+		if (prior_character != 0)
+			width += GetKerning(prior_character, string[i]);
+		// Adjust the cursor for this character's advance.
+		width += glyph.advance;
 
 
-        prior_character = character_code;
-    }
+		prior_character = character_code;
+	}
 
 
-    return width;
+	return width;
 }
 }
 
 
 // Generates, if required, the layer configuration for a given array of font effects.
 // Generates, if required, the layer configuration for a given array of font effects.
 int FontFaceHandle::GenerateLayerConfiguration(FontEffectMap& font_effects)
 int FontFaceHandle::GenerateLayerConfiguration(FontEffectMap& font_effects)
 {
 {
-    if (font_effects.empty())
-        return 0;
-
-    // Prepare a list of effects, sorted by z-index.
-    FontEffectList sorted_effects;
-    for (FontEffectMap::const_iterator i = font_effects.begin(); i != font_effects.end(); ++i)
-        sorted_effects.push_back(i->second);
-
-    std::sort(sorted_effects.begin(), sorted_effects.end(), FontEffectSort());
-
-    // Check each existing configuration for a match with this arrangement of effects.
-    int configuration_index = 1;
-    for (; configuration_index < (int) layer_configurations.size(); ++configuration_index)
-    {
-        const LayerConfiguration& configuration = layer_configurations[configuration_index];
-
-        // Check the size is correct. For a math, there should be one layer in the configuration
-        // plus an extra for the base layer.
-        if (configuration.size() != sorted_effects.size() + 1)
-            continue;
-
-        // Check through each layer, checking it was created by the same effect as the one we're
-        // checking.
-        size_t effect_index = 0;
-        for (size_t i = 0; i < configuration.size(); ++i)
-        {
-            // Skip the base layer ...
-            if (configuration[i]->GetFontEffect() == NULL)
-                continue;
-
-            // If the ith layer's effect doesn't match the equivalent effect, then this
-            // configuration can't match.
-            if (configuration[i]->GetFontEffect() != sorted_effects[effect_index])
-                break;
-
-            // Check the next one ...
-            ++effect_index;
-        }
-
-        if (effect_index == sorted_effects.size())
-            return configuration_index;
-    }
-
-    // No match, so we have to generate a new layer configuration.
-    layer_configurations.push_back(LayerConfiguration());
-    LayerConfiguration& layer_configuration = layer_configurations.back();
-
-    bool added_base_layer = false;
-
-    for (size_t i = 0; i < sorted_effects.size(); ++i)
-    {
-        if (!added_base_layer &&
-            sorted_effects[i]->GetZIndex() >= 0)
-        {
-            layer_configuration.push_back(base_layer);
-            added_base_layer = true;
-        }
-
-        layer_configuration.push_back(GenerateLayer(sorted_effects[i]));
-    }
-
-    // Add the base layer now if we still haven't added it.
-    if (!added_base_layer)
-        layer_configuration.push_back(base_layer);
-
-    return (int) (layer_configurations.size() - 1);
+	if (font_effects.empty())
+		return 0;
+
+	// Prepare a list of effects, sorted by z-index.
+	FontEffectList sorted_effects;
+	for (FontEffectMap::const_iterator i = font_effects.begin(); i != font_effects.end(); ++i)
+		sorted_effects.push_back(i->second);
+
+	std::sort(sorted_effects.begin(), sorted_effects.end(), FontEffectSort());
+
+	// Check each existing configuration for a match with this arrangement of effects.
+	int configuration_index = 1;
+	for (; configuration_index < (int) layer_configurations.size(); ++configuration_index)
+	{
+		const LayerConfiguration& configuration = layer_configurations[configuration_index];
+
+		// Check the size is correct. For a math, there should be one layer in the configuration
+		// plus an extra for the base layer.
+		if (configuration.size() != sorted_effects.size() + 1)
+			continue;
+
+		// Check through each layer, checking it was created by the same effect as the one we're
+		// checking.
+		size_t effect_index = 0;
+		for (size_t i = 0; i < configuration.size(); ++i)
+		{
+			// Skip the base layer ...
+			if (configuration[i]->GetFontEffect() == NULL)
+				continue;
+
+			// If the ith layer's effect doesn't match the equivalent effect, then this
+			// configuration can't match.
+			if (configuration[i]->GetFontEffect() != sorted_effects[effect_index])
+				break;
+
+			// Check the next one ...
+			++effect_index;
+		}
+
+		if (effect_index == sorted_effects.size())
+			return configuration_index;
+	}
+
+	// No match, so we have to generate a new layer configuration.
+	layer_configurations.push_back(LayerConfiguration());
+	LayerConfiguration& layer_configuration = layer_configurations.back();
+
+	bool added_base_layer = false;
+
+	for (size_t i = 0; i < sorted_effects.size(); ++i)
+	{
+		if (!added_base_layer &&
+			sorted_effects[i]->GetZIndex() >= 0)
+		{
+			layer_configuration.push_back(base_layer);
+			added_base_layer = true;
+		}
+
+		layer_configuration.push_back(GenerateLayer(sorted_effects[i]));
+	}
+
+	// Add the base layer now if we still haven't added it.
+	if (!added_base_layer)
+		layer_configuration.push_back(base_layer);
+
+	return (int) (layer_configurations.size() - 1);
 }
 }
 
 
 // Generates the texture data for a layer (for the texture database).
 // Generates the texture data for a layer (for the texture database).
 bool FontFaceHandle::GenerateLayerTexture(const byte*& texture_data, Vector2i& texture_dimensions, FontEffect* layer_id, int texture_id)
 bool FontFaceHandle::GenerateLayerTexture(const byte*& texture_data, Vector2i& texture_dimensions, FontEffect* layer_id, int texture_id)
 {
 {
-    FontLayerMap::iterator layer_iterator = layers.find(layer_id);
-    if (layer_iterator == layers.end())
-        return false;
+	FontLayerMap::iterator layer_iterator = layers.find(layer_id);
+	if (layer_iterator == layers.end())
+		return false;
 
 
-    return layer_iterator->second->GenerateTexture(texture_data, texture_dimensions, texture_id);
+	return layer_iterator->second->GenerateTexture(texture_data, texture_dimensions, texture_id);
 }
 }
 
 
 // Generates the geometry required to render a single line of text.
 // Generates the geometry required to render a single line of text.
 int FontFaceHandle::GenerateString(GeometryList& geometry, const WString& string, const Vector2f& position, const Colourb& colour, int layer_configuration_index) const
 int FontFaceHandle::GenerateString(GeometryList& geometry, const WString& string, const Vector2f& position, const Colourb& colour, int layer_configuration_index) const
 {
 {
-    int geometry_index = 0;
-    int line_width = 0;
+	int geometry_index = 0;
+	int line_width = 0;
 
 
-    ROCKET_ASSERT(layer_configuration_index >= 0);
-    ROCKET_ASSERT(layer_configuration_index < (int) layer_configurations.size());
+	ROCKET_ASSERT(layer_configuration_index >= 0);
+	ROCKET_ASSERT(layer_configuration_index < (int) layer_configurations.size());
 
 
-    // Fetch the requested configuration and generate the geometry for each one.
-    const LayerConfiguration& layer_configuration = layer_configurations[layer_configuration_index];
-    for (size_t i = 0; i < layer_configuration.size(); ++i)
-    {
-        FontFaceLayer* layer = layer_configuration[i];
+	// Fetch the requested configuration and generate the geometry for each one.
+	const LayerConfiguration& layer_configuration = layer_configurations[layer_configuration_index];
+	for (size_t i = 0; i < layer_configuration.size(); ++i)
+	{
+		FontFaceLayer* layer = layer_configuration[i];
 
 
-        Colourb layer_colour;
-        if (layer == base_layer)
-            layer_colour = colour;
-        else
-            layer_colour = layer->GetColour();
+		Colourb layer_colour;
+		if (layer == base_layer)
+			layer_colour = colour;
+		else
+			layer_colour = layer->GetColour();
 
 
-        // Resize the geometry list if required.
-        if ((int) geometry.size() < geometry_index + layer->GetNumTextures())
-            geometry.resize(geometry_index + layer->GetNumTextures());
+		// Resize the geometry list if required.
+		if ((int) geometry.size() < geometry_index + layer->GetNumTextures())
+			geometry.resize(geometry_index + layer->GetNumTextures());
 
 
-        // Bind the textures to the geometries.
-        for (int i = 0; i < layer->GetNumTextures(); ++i)
-            geometry[geometry_index + i].SetTexture(layer->GetTexture(i));
+		// Bind the textures to the geometries.
+		for (int i = 0; i < layer->GetNumTextures(); ++i)
+			geometry[geometry_index + i].SetTexture(layer->GetTexture(i));
 
 
-        line_width = 0;
-        word prior_character = 0;
+		line_width = 0;
+		word prior_character = 0;
 
 
-        const word* string_iterator = string.CString();
-        const word* string_end = string.CString() + string.Length();
+		const word* string_iterator = string.CString();
+		const word* string_end = string.CString() + string.Length();
 
 
-        for (; string_iterator != string_end; string_iterator++)
-        {
-            if (*string_iterator >= glyphs.size())
-                continue;
-            const FontGlyph &glyph = glyphs[*string_iterator];
+		for (; string_iterator != string_end; string_iterator++)
+		{
+			if (*string_iterator >= glyphs.size())
+				continue;
+			const FontGlyph &glyph = glyphs[*string_iterator];
 
 
-            // Adjust the cursor for the kerning between this character and the previous one.
-            if (prior_character != 0)
-                line_width += GetKerning(prior_character, *string_iterator);
+			// Adjust the cursor for the kerning between this character and the previous one.
+			if (prior_character != 0)
+				line_width += GetKerning(prior_character, *string_iterator);
 
 
-            layer->GenerateGeometry(&geometry[geometry_index], *string_iterator, Vector2f(position.x + line_width, position.y), layer_colour);
+			layer->GenerateGeometry(&geometry[geometry_index], *string_iterator, Vector2f(position.x + line_width, position.y), layer_colour);
 
 
-            line_width += glyph.advance;
-            prior_character = *string_iterator;
-        }
+			line_width += glyph.advance;
+			prior_character = *string_iterator;
+		}
 
 
-        geometry_index += layer->GetNumTextures();
-    }
+		geometry_index += layer->GetNumTextures();
+	}
 
 
-    // Cull any excess geometry from a previous generation.
-    geometry.resize(geometry_index);
+	// Cull any excess geometry from a previous generation.
+	geometry.resize(geometry_index);
 
 
-    return line_width;
+	return line_width;
 }
 }
 
 
 // Generates the geometry required to render a line above, below or through a line of text.
 // Generates the geometry required to render a line above, below or through a line of text.
 void FontFaceHandle::GenerateLine(Geometry* geometry, const Vector2f& position, int width, Font::Line height, const Colourb& colour) const
 void FontFaceHandle::GenerateLine(Geometry* geometry, const Vector2f& position, int width, Font::Line height, const Colourb& colour) const
 {
 {
-    std::vector< Vertex >& line_vertices = geometry->GetVertices();
-    std::vector< int >& line_indices = geometry->GetIndices();
-
-    float offset;
-    switch (height)
-    {
-        case Font::UNDERLINE:			offset = -underline_position; break;
-        case Font::OVERLINE:			// where to place? offset = -line_height - underline_position; break;
-        case Font::STRIKE_THROUGH:		// where to place? offset = -line_height * 0.5f; break;
-        default:						return;
-    }
-
-    line_vertices.resize(line_vertices.size() + 4);
-    line_indices.resize(line_indices.size() + 6);
-    GeometryUtilities::GenerateQuad(&line_vertices[0] + (line_vertices.size() - 4), &line_indices[0] + (line_indices.size() - 6), Vector2f(position.x, position.y + offset), Vector2f((float) width, underline_thickness), colour, (int)line_vertices.size() - 4);
+	std::vector< Vertex >& line_vertices = geometry->GetVertices();
+	std::vector< int >& line_indices = geometry->GetIndices();
+
+	float offset;
+	switch (height)
+	{
+		case Font::UNDERLINE:			offset = -underline_position; break;
+		case Font::OVERLINE:			// where to place? offset = -line_height - underline_position; break;
+		case Font::STRIKE_THROUGH:		// where to place? offset = -line_height * 0.5f; break;
+		default:						return;
+	}
+
+	line_vertices.resize(line_vertices.size() + 4);
+	line_indices.resize(line_indices.size() + 6);
+	GeometryUtilities::GenerateQuad(&line_vertices[0] + (line_vertices.size() - 4), &line_indices[0] + (line_indices.size() - 6), Vector2f(position.x, position.y + offset), Vector2f((float) width, underline_thickness), colour, (int)line_vertices.size() - 4);
 }
 }
 
 
 // Destroys the handle.
 // Destroys the handle.
 void FontFaceHandle::OnReferenceDeactivate()
 void FontFaceHandle::OnReferenceDeactivate()
 {
 {
-    delete this;
+	delete this;
 }
 }
 
 
 void FontFaceHandle::GenerateMetrics()
 void FontFaceHandle::GenerateMetrics()
 {
 {
-    line_height = ft_face->size->metrics.height >> 6;
-    baseline = line_height - (ft_face->size->metrics.ascender >> 6);
-
-    underline_position = FT_MulFix(ft_face->underline_position, ft_face->size->metrics.y_scale) / float(1 << 6);
-    underline_thickness = FT_MulFix(ft_face->underline_thickness, ft_face->size->metrics.y_scale) / float(1 << 6);
-    underline_thickness = Math::Max(underline_thickness, 1.0f);
-
-    average_advance = 0;
-    unsigned int num_visible_glyphs = 0;
-    for (FontGlyphList::iterator i = glyphs.begin(); i != glyphs.end(); ++i)
-    {
-        if (i->advance)
-        {
-            average_advance += i->advance;
-            num_visible_glyphs++;
-        }
-    }
-
-    // Bring the total advance down to the average advance, but scaled up 10%, just to be on the safe side.
-    if (num_visible_glyphs)
-        average_advance = Math::RealToInteger((float) average_advance / (num_visible_glyphs * 0.9f));
-
-    // Determine the x-height of this font face.
-    word x = (word) 'x';
-    int index = FT_Get_Char_Index(ft_face, x);
-    if (FT_Load_Glyph(ft_face, index, 0) == 0)
-        x_height = ft_face->glyph->metrics.height >> 6;
-    else
-        x_height = 0;
+	line_height = ft_face->size->metrics.height >> 6;
+	baseline = line_height - (ft_face->size->metrics.ascender >> 6);
+
+	underline_position = FT_MulFix(ft_face->underline_position, ft_face->size->metrics.y_scale) / float(1 << 6);
+	underline_thickness = FT_MulFix(ft_face->underline_thickness, ft_face->size->metrics.y_scale) / float(1 << 6);
+	underline_thickness = Math::Max(underline_thickness, 1.0f);
+
+	average_advance = 0;
+	unsigned int num_visible_glyphs = 0;
+	for (FontGlyphList::iterator i = glyphs.begin(); i != glyphs.end(); ++i)
+	{
+		if (i->advance)
+		{
+			average_advance += i->advance;
+			num_visible_glyphs++;
+		}
+	}
+
+	// Bring the total advance down to the average advance, but scaled up 10%, just to be on the safe side.
+	if (num_visible_glyphs)
+		average_advance = Math::RealToInteger((float) average_advance / (num_visible_glyphs * 0.9f));
+
+	// Determine the x-height of this font face.
+	word x = (word) 'x';
+	int index = FT_Get_Char_Index(ft_face, x);
+	if (FT_Load_Glyph(ft_face, index, 0) == 0)
+		x_height = ft_face->glyph->metrics.height >> 6;
+	else
+		x_height = 0;
 }
 }
 
 
 void FontFaceHandle::BuildGlyphMap(const UnicodeRange& unicode_range)
 void FontFaceHandle::BuildGlyphMap(const UnicodeRange& unicode_range)
 {
 {
-    for (word character_code = (word) (Math::Max< unsigned int >(unicode_range.min_codepoint, 32)); character_code <= unicode_range.max_codepoint; ++character_code)
-    {
-        int index = FT_Get_Char_Index(ft_face, character_code);
-        if (index != 0)
-        {
-            FT_Error error = FT_Load_Glyph(ft_face, index, 0);
-            if (error != 0)
-            {
-                Log::Message(Log::LT_WARNING, "Unable to load glyph for character '%u' on the font face '%s %s'; error code: %d.", character_code, ft_face->family_name, ft_face->style_name, error);
-                continue;
-            }
-
-            error = FT_Render_Glyph(ft_face->glyph, FT_RENDER_MODE_NORMAL);
-            if (error != 0)
-            {
-                Log::Message(Log::LT_WARNING, "Unable to render glyph for character '%u' on the font face '%s %s'; error code: %d.", character_code, ft_face->family_name, ft_face->style_name, error);
-                continue;
-            }
-
-            FontGlyph glyph;
-            glyph.character = character_code;
-            BuildGlyph(glyph, ft_face->glyph);
-            glyphs[character_code] = glyph;
-        }
-    }
+	for (word character_code = (word) (Math::Max< unsigned int >(unicode_range.min_codepoint, 32)); character_code <= unicode_range.max_codepoint; ++character_code)
+	{
+		int index = FT_Get_Char_Index(ft_face, character_code);
+		if (index != 0)
+		{
+			FT_Error error = FT_Load_Glyph(ft_face, index, 0);
+			if (error != 0)
+			{
+				Log::Message(Log::LT_WARNING, "Unable to load glyph for character '%u' on the font face '%s %s'; error code: %d.", character_code, ft_face->family_name, ft_face->style_name, error);
+				continue;
+			}
+
+			error = FT_Render_Glyph(ft_face->glyph, FT_RENDER_MODE_NORMAL);
+			if (error != 0)
+			{
+				Log::Message(Log::LT_WARNING, "Unable to render glyph for character '%u' on the font face '%s %s'; error code: %d.", character_code, ft_face->family_name, ft_face->style_name, error);
+				continue;
+			}
+
+			FontGlyph glyph;
+			glyph.character = character_code;
+			BuildGlyph(glyph, ft_face->glyph);
+			glyphs[character_code] = glyph;
+		}
+	}
 }
 }
 
 
 void FontFaceHandle::BuildGlyph(FontGlyph& glyph, FT_GlyphSlot ft_glyph)
 void FontFaceHandle::BuildGlyph(FontGlyph& glyph, FT_GlyphSlot ft_glyph)
 {
 {
-    // Set the glyph's dimensions.
-    glyph.dimensions.x = ft_glyph->metrics.width >> 6;
-    glyph.dimensions.y = ft_glyph->metrics.height >> 6;
-
-    // Set the glyph's bearing.
-    glyph.bearing.x = ft_glyph->metrics.horiBearingX >> 6;
-    glyph.bearing.y = ft_glyph->metrics.horiBearingY >> 6;
-
-    // Set the glyph's advance.
-    glyph.advance = ft_glyph->metrics.horiAdvance >> 6;
-
-    // Set the glyph's bitmap dimensions.
-    glyph.bitmap_dimensions.x = ft_glyph->bitmap.width;
-    glyph.bitmap_dimensions.y = ft_glyph->bitmap.rows;
-
-    // Copy the glyph's bitmap data from the FreeType glyph handle to our glyph handle.
-    if (glyph.bitmap_dimensions.x * glyph.bitmap_dimensions.y != 0)
-    {
-        // Check the pixel mode is supported.
-        if (ft_glyph->bitmap.pixel_mode != FT_PIXEL_MODE_MONO &&
-            ft_glyph->bitmap.pixel_mode != FT_PIXEL_MODE_GRAY)
-        {
-            glyph.bitmap_data = NULL;
-            Log::Message(Log::LT_WARNING, "Unable to render glyph on the font face '%s %s'; unsupported pixel mode (%d).", ft_glyph->face->family_name, ft_glyph->face->style_name, ft_glyph->bitmap.pixel_mode);
-        }
-        else
-        {
-            glyph.bitmap_data = new byte[glyph.bitmap_dimensions.x * glyph.bitmap_dimensions.y];
-
-            byte* source_bitmap = ft_glyph->bitmap.buffer;
-            byte* destination_bitmap = glyph.bitmap_data;
-
-            // Copy the bitmap data into the newly-allocated space on our glyph.
-            switch (ft_glyph->bitmap.pixel_mode)
-            {
-                // Unpack 1-bit data into 8-bit.
-                case FT_PIXEL_MODE_MONO:
-                {
-                    for (int i = 0; i < glyph.bitmap_dimensions.y; ++i)
-                    {
-                        int mask = 0x80;
-                        byte* source_byte = source_bitmap;
-                        for (int j = 0; j < glyph.bitmap_dimensions.x; ++j)
-                        {
-                            if ((*source_byte & mask) == mask)
-                                destination_bitmap[j] = 255;
-                            else
-                                destination_bitmap[j] = 0;
-
-                            mask >>= 1;
-                            if (mask <= 0)
-                            {
-                                mask = 0x80;
-                                ++source_byte;
-                            }
-                        }
-
-                        destination_bitmap += glyph.bitmap_dimensions.x;
-                        source_bitmap += ft_glyph->bitmap.pitch;
-                    }
-                }
-                break;
-
-                // Directly copy 8-bit data.
-                case FT_PIXEL_MODE_GRAY:
-                {
-                    for (int i = 0; i < glyph.bitmap_dimensions.y; ++i)
-                    {
-                        memcpy(destination_bitmap, source_bitmap, glyph.bitmap_dimensions.x);
-                        destination_bitmap += glyph.bitmap_dimensions.x;
-                        source_bitmap += ft_glyph->bitmap.pitch;
-                    }
-                }
-                break;
-            }
-        }
-    }
-    else
-        glyph.bitmap_data = NULL;
+	// Set the glyph's dimensions.
+	glyph.dimensions.x = ft_glyph->metrics.width >> 6;
+	glyph.dimensions.y = ft_glyph->metrics.height >> 6;
+
+	// Set the glyph's bearing.
+	glyph.bearing.x = ft_glyph->metrics.horiBearingX >> 6;
+	glyph.bearing.y = ft_glyph->metrics.horiBearingY >> 6;
+
+	// Set the glyph's advance.
+	glyph.advance = ft_glyph->metrics.horiAdvance >> 6;
+
+	// Set the glyph's bitmap dimensions.
+	glyph.bitmap_dimensions.x = ft_glyph->bitmap.width;
+	glyph.bitmap_dimensions.y = ft_glyph->bitmap.rows;
+
+	// Copy the glyph's bitmap data from the FreeType glyph handle to our glyph handle.
+	if (glyph.bitmap_dimensions.x * glyph.bitmap_dimensions.y != 0)
+	{
+		// Check the pixel mode is supported.
+		if (ft_glyph->bitmap.pixel_mode != FT_PIXEL_MODE_MONO &&
+			ft_glyph->bitmap.pixel_mode != FT_PIXEL_MODE_GRAY)
+		{
+			glyph.bitmap_data = NULL;
+			Log::Message(Log::LT_WARNING, "Unable to render glyph on the font face '%s %s'; unsupported pixel mode (%d).", ft_glyph->face->family_name, ft_glyph->face->style_name, ft_glyph->bitmap.pixel_mode);
+		}
+		else
+		{
+			glyph.bitmap_data = new byte[glyph.bitmap_dimensions.x * glyph.bitmap_dimensions.y];
+
+			byte* source_bitmap = ft_glyph->bitmap.buffer;
+			byte* destination_bitmap = glyph.bitmap_data;
+
+			// Copy the bitmap data into the newly-allocated space on our glyph.
+			switch (ft_glyph->bitmap.pixel_mode)
+			{
+				// Unpack 1-bit data into 8-bit.
+				case FT_PIXEL_MODE_MONO:
+				{
+					for (int i = 0; i < glyph.bitmap_dimensions.y; ++i)
+					{
+						int mask = 0x80;
+						byte* source_byte = source_bitmap;
+						for (int j = 0; j < glyph.bitmap_dimensions.x; ++j)
+						{
+							if ((*source_byte & mask) == mask)
+								destination_bitmap[j] = 255;
+							else
+								destination_bitmap[j] = 0;
+
+							mask >>= 1;
+							if (mask <= 0)
+							{
+								mask = 0x80;
+								++source_byte;
+							}
+						}
+
+						destination_bitmap += glyph.bitmap_dimensions.x;
+						source_bitmap += ft_glyph->bitmap.pitch;
+					}
+				}
+				break;
+
+				// Directly copy 8-bit data.
+				case FT_PIXEL_MODE_GRAY:
+				{
+					for (int i = 0; i < glyph.bitmap_dimensions.y; ++i)
+					{
+						memcpy(destination_bitmap, source_bitmap, glyph.bitmap_dimensions.x);
+						destination_bitmap += glyph.bitmap_dimensions.x;
+						source_bitmap += ft_glyph->bitmap.pitch;
+					}
+				}
+				break;
+			}
+		}
+	}
+	else
+		glyph.bitmap_data = NULL;
 }
 }
 
 
 int FontFaceHandle::GetKerning(word lhs, word rhs) const
 int FontFaceHandle::GetKerning(word lhs, word rhs) const
 {
 {
-    if (!FT_HAS_KERNING(ft_face))
-        return 0;
+	if (!FT_HAS_KERNING(ft_face))
+		return 0;
 
 
-    FT_Vector ft_kerning;
+	FT_Vector ft_kerning;
 
 
-    FT_Error ft_error = FT_Get_Kerning(ft_face,
-        FT_Get_Char_Index(ft_face, lhs), FT_Get_Char_Index(ft_face, rhs),
-        FT_KERNING_DEFAULT, &ft_kerning);
+	FT_Error ft_error = FT_Get_Kerning(ft_face,
+		FT_Get_Char_Index(ft_face, lhs), FT_Get_Char_Index(ft_face, rhs),
+		FT_KERNING_DEFAULT, &ft_kerning);
 
 
-    if (ft_error != 0)
-        return 0;
+	if (ft_error != 0)
+		return 0;
 
 
-    int kerning = ft_kerning.x >> 6;
-    return kerning;
+	int kerning = ft_kerning.x >> 6;
+	return kerning;
 }
 }
 
 
 }
 }

+ 49 - 49
Source/Core/FreeType/FontFaceHandle.h

@@ -47,67 +47,67 @@ class FontFaceLayer;
 namespace FreeType {
 namespace FreeType {
 
 
 /**
 /**
-    @author Peter Curry
+	@author Peter Curry
  */
  */
 
 
 class FontFaceHandle : public Rocket::Core::FontFaceHandle
 class FontFaceHandle : public Rocket::Core::FontFaceHandle
 {
 {
 public:
 public:
-    FontFaceHandle();
-    virtual ~FontFaceHandle();
-
-    /// Initialises the handle so it is able to render text.
-    /// @param[in] ft_face The FreeType face that this handle is rendering.
-    /// @param[in] charset The comma-separated list of unicode ranges this handle must support.
-    /// @param[in] size The size, in points, of the face this handle should render at.
-    /// @return True if the handle initialised successfully and is ready for rendering, false if an error occured.
-    bool Initialise(FT_Face ft_face, const String& charset, int size);
-
-    /// Returns the width a string will take up if rendered with this handle.
-    /// @param[in] string The string to measure.
-    /// @param[in] prior_character The optionally-specified character that immediately precedes the string. This may have an impact on the string width due to kerning.
-    /// @return The width, in pixels, this string will occupy if rendered with this handle.
-    int GetStringWidth(const WString& string, word prior_character = 0) const;
-
-    /// Generates, if required, the layer configuration for a given array of font effects.
-    /// @param[in] font_effects The list of font effects to generate the configuration for.
-    /// @return The index to use when generating geometry using this configuration.
-    int GenerateLayerConfiguration(FontEffectMap& font_effects);
-    /// Generates the texture data for a layer (for the texture database).
-    /// @param[out] texture_data The pointer to be set to the generated texture data.
-    /// @param[out] texture_dimensions The dimensions of the texture.
-    /// @param[in] layer_id The id of the layer to request the texture data from.
-    /// @param[in] texture_id The index of the texture within the layer to generate.
-    bool GenerateLayerTexture(const byte*& texture_data, Vector2i& texture_dimensions, FontEffect* layer_id, int texture_id);
-
-    /// Generates the geometry required to render a single line of text.
-    /// @param[out] geometry An array of geometries to generate the geometry into.
-    /// @param[in] string The string to render.
-    /// @param[in] position The position of the baseline of the first character to render.
-    /// @param[in] colour The colour to render the text.
-    /// @return The width, in pixels, of the string geometry.
-    int GenerateString(GeometryList& geometry, const WString& string, const Vector2f& position, const Colourb& colour, int layer_configuration = 0) const;
-    /// Generates the geometry required to render a line above, below or through a line of text.
-    /// @param[out] geometry The geometry to append the newly created geometry into.
-    /// @param[in] position The position of the baseline of the lined text.
-    /// @param[in] width The width of the string to line.
-    /// @param[in] height The height to render the line at.
-    /// @param[in] colour The colour to draw the line in.
-    void GenerateLine(Geometry* geometry, const Vector2f& position, int width, Font::Line height, const Colourb& colour) const;
+	FontFaceHandle();
+	virtual ~FontFaceHandle();
+
+	/// Initialises the handle so it is able to render text.
+	/// @param[in] ft_face The FreeType face that this handle is rendering.
+	/// @param[in] charset The comma-separated list of unicode ranges this handle must support.
+	/// @param[in] size The size, in points, of the face this handle should render at.
+	/// @return True if the handle initialised successfully and is ready for rendering, false if an error occured.
+	bool Initialise(FT_Face ft_face, const String& charset, int size);
+
+	/// Returns the width a string will take up if rendered with this handle.
+	/// @param[in] string The string to measure.
+	/// @param[in] prior_character The optionally-specified character that immediately precedes the string. This may have an impact on the string width due to kerning.
+	/// @return The width, in pixels, this string will occupy if rendered with this handle.
+	int GetStringWidth(const WString& string, word prior_character = 0) const;
+
+	/// Generates, if required, the layer configuration for a given array of font effects.
+	/// @param[in] font_effects The list of font effects to generate the configuration for.
+	/// @return The index to use when generating geometry using this configuration.
+	int GenerateLayerConfiguration(FontEffectMap& font_effects);
+	/// Generates the texture data for a layer (for the texture database).
+	/// @param[out] texture_data The pointer to be set to the generated texture data.
+	/// @param[out] texture_dimensions The dimensions of the texture.
+	/// @param[in] layer_id The id of the layer to request the texture data from.
+	/// @param[in] texture_id The index of the texture within the layer to generate.
+	bool GenerateLayerTexture(const byte*& texture_data, Vector2i& texture_dimensions, FontEffect* layer_id, int texture_id);
+
+	/// Generates the geometry required to render a single line of text.
+	/// @param[out] geometry An array of geometries to generate the geometry into.
+	/// @param[in] string The string to render.
+	/// @param[in] position The position of the baseline of the first character to render.
+	/// @param[in] colour The colour to render the text.
+	/// @return The width, in pixels, of the string geometry.
+	int GenerateString(GeometryList& geometry, const WString& string, const Vector2f& position, const Colourb& colour, int layer_configuration = 0) const;
+	/// Generates the geometry required to render a line above, below or through a line of text.
+	/// @param[out] geometry The geometry to append the newly created geometry into.
+	/// @param[in] position The position of the baseline of the lined text.
+	/// @param[in] width The width of the string to line.
+	/// @param[in] height The height to render the line at.
+	/// @param[in] colour The colour to draw the line in.
+	void GenerateLine(Geometry* geometry, const Vector2f& position, int width, Font::Line height, const Colourb& colour) const;
 
 
 protected:
 protected:
-    /// Destroys the handle.
-    virtual void OnReferenceDeactivate();
+	/// Destroys the handle.
+	virtual void OnReferenceDeactivate();
 
 
-    int GetKerning(word lhs, word rhs) const;
+	int GetKerning(word lhs, word rhs) const;
 
 
 private:
 private:
-    void GenerateMetrics(void);
+	void GenerateMetrics(void);
 
 
-    void BuildGlyphMap(const UnicodeRange& unicode_range);
-    void BuildGlyph(FontGlyph& glyph, FT_GlyphSlot ft_glyph);
+	void BuildGlyphMap(const UnicodeRange& unicode_range);
+	void BuildGlyph(FontGlyph& glyph, FT_GlyphSlot ft_glyph);
 
 
-    FT_Face ft_face;
+	FT_Face ft_face;
 };
 };
 
 
 }
 }

+ 3 - 3
Source/Core/FreeType/FontFamily.cpp

@@ -47,10 +47,10 @@ FontFamily::~FontFamily()
 // Adds a new face to the family.
 // Adds a new face to the family.
 bool FontFamily::AddFace(void* ft_face, Font::Style style, Font::Weight weight, bool release_stream)
 bool FontFamily::AddFace(void* ft_face, Font::Style style, Font::Weight weight, bool release_stream)
 {
 {
-    FontFace* face = new FontFace((FT_Face)ft_face, style, weight, release_stream);
-    font_faces.push_back(face);
+	FontFace* face = new FontFace((FT_Face)ft_face, style, weight, release_stream);
+	font_faces.push_back(face);
 
 
-    return true;
+	return true;
 }
 }
 
 
 }
 }

+ 10 - 10
Source/Core/FreeType/FontFamily.h

@@ -40,7 +40,7 @@ class FontFace;
 class FontFaceHandle;
 class FontFaceHandle;
 
 
 /**
 /**
-    @author Peter Curry
+	@author Peter Curry
  */
  */
 
 
 namespace FreeType {
 namespace FreeType {
@@ -48,16 +48,16 @@ namespace FreeType {
 class FontFamily : public Rocket::Core::FontFamily
 class FontFamily : public Rocket::Core::FontFamily
 {
 {
 public:
 public:
-    FontFamily(const String& name);
-    ~FontFamily();
+	FontFamily(const String& name);
+	~FontFamily();
 
 
-    /// Adds a new face to the family.
-    /// @param[in] ft_face The previously loaded FreeType face.
-    /// @param[in] style The style 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.
-    /// @return True if the face was loaded successfully, false otherwise.
-    bool AddFace(void* ft_face, Font::Style style, Font::Weight weight, bool release_stream);
+	/// Adds a new face to the family.
+	/// @param[in] ft_face The previously loaded FreeType face.
+	/// @param[in] style The style 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.
+	/// @return True if the face was loaded successfully, false otherwise.
+	bool AddFace(void* ft_face, Font::Style style, Font::Weight weight, bool release_stream);
 };
 };
 
 
 }
 }

+ 156 - 156
Source/Core/FreeType/FontProvider.cpp

@@ -44,213 +44,213 @@ static FT_Library ft_library = NULL;
 
 
 FontProvider::FontProvider()
 FontProvider::FontProvider()
 {
 {
-    ROCKET_ASSERT(instance == NULL);
-    instance = this;
+	ROCKET_ASSERT(instance == NULL);
+	instance = this;
 }
 }
 
 
 FontProvider::~FontProvider()
 FontProvider::~FontProvider()
 {
 {
-    ROCKET_ASSERT(instance == this);
-    instance = NULL;
+	ROCKET_ASSERT(instance == this);
+	instance = NULL;
 }
 }
 
 
 bool FontProvider::Initialise()
 bool FontProvider::Initialise()
 {
 {
-    if (instance == NULL)
-    {
-        new FontProvider();
-
-        FontDatabase::AddFontProvider(instance);
-
-        FT_Error result = FT_Init_FreeType(&ft_library);
-        if (result != 0)
-        {
-            Log::Message(Log::LT_ERROR, "Failed to initialise FreeType, error %d.", result);
-            Shutdown();
-            return false;
-        }
-    }
-
-    return true;
+	if (instance == NULL)
+	{
+		new FontProvider();
+
+		FontDatabase::AddFontProvider(instance);
+
+		FT_Error result = FT_Init_FreeType(&ft_library);
+		if (result != 0)
+		{
+			Log::Message(Log::LT_ERROR, "Failed to initialise FreeType, error %d.", result);
+			Shutdown();
+			return false;
+		}
+	}
+
+	return true;
 }
 }
 
 
 void FontProvider::Shutdown()
 void FontProvider::Shutdown()
 {
 {
-    if (instance != NULL)
-    {
-        for (FontFamilyMap::iterator i = instance->font_families.begin(); i != instance->font_families.end(); ++i)
-            delete (*i).second;
-
-        if (ft_library != NULL)
-        {
-            FT_Done_FreeType(ft_library);
-            ft_library = NULL;
-        }
-
-        delete instance;
-    }
+	if (instance != NULL)
+	{
+		for (FontFamilyMap::iterator i = instance->font_families.begin(); i != instance->font_families.end(); ++i)
+			delete (*i).second;
+
+		if (ft_library != NULL)
+		{
+			FT_Done_FreeType(ft_library);
+			ft_library = NULL;
+		}
+
+		delete instance;
+	}
 }
 }
 
 
 // Loads a new font face.
 // Loads a new font face.
 bool FontProvider::LoadFontFace(const String& file_name)
 bool FontProvider::LoadFontFace(const String& file_name)
 {
 {
-    FT_Face ft_face = (FT_Face) instance->LoadFace(file_name);
-    if (ft_face == NULL)
-    {
-        Log::Message(Log::LT_ERROR, "Failed to load font face from %s.", file_name.CString());
-        return false;
-    }
-
-    Font::Style style = ft_face->style_flags & FT_STYLE_FLAG_ITALIC ? Font::STYLE_ITALIC : Font::STYLE_NORMAL;
-    Font::Weight weight = ft_face->style_flags & FT_STYLE_FLAG_BOLD ? Font::WEIGHT_BOLD : Font::WEIGHT_NORMAL;
-
-    if (instance->AddFace(ft_face, ft_face->family_name, style, weight, true))
-    {
-        Log::Message(Log::LT_INFO, "Loaded font face %s %s (from %s).", ft_face->family_name, ft_face->style_name, file_name.CString());
-        return true;
-    }
-    else
-    {
-        Log::Message(Log::LT_ERROR, "Failed to load font face %s %s (from %s).", ft_face->family_name, ft_face->style_name, file_name.CString());
-        return false;
-    }
+	FT_Face ft_face = (FT_Face) instance->LoadFace(file_name);
+	if (ft_face == NULL)
+	{
+		Log::Message(Log::LT_ERROR, "Failed to load font face from %s.", file_name.CString());
+		return false;
+	}
+
+	Font::Style style = ft_face->style_flags & FT_STYLE_FLAG_ITALIC ? Font::STYLE_ITALIC : Font::STYLE_NORMAL;
+	Font::Weight weight = ft_face->style_flags & FT_STYLE_FLAG_BOLD ? Font::WEIGHT_BOLD : Font::WEIGHT_NORMAL;
+
+	if (instance->AddFace(ft_face, ft_face->family_name, style, weight, true))
+	{
+		Log::Message(Log::LT_INFO, "Loaded font face %s %s (from %s).", ft_face->family_name, ft_face->style_name, file_name.CString());
+		return true;
+	}
+	else
+	{
+		Log::Message(Log::LT_ERROR, "Failed to load font face %s %s (from %s).", ft_face->family_name, ft_face->style_name, file_name.CString());
+		return false;
+	}
 }
 }
 
 
 // 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, 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)
 {
 {
-    FT_Face ft_face = (FT_Face) instance->LoadFace(file_name);
-    if (ft_face == NULL)
-    {
-        Log::Message(Log::LT_ERROR, "Failed to load font face from %s.", file_name.CString());
-        return false;
-    }
-
-    if (instance->AddFace(ft_face, family, style, weight, true))
-    {
-        Log::Message(Log::LT_INFO, "Loaded font face %s %s (from %s).", ft_face->family_name, ft_face->style_name, file_name.CString());
-        return true;
-    }
-    else
-    {
-        Log::Message(Log::LT_ERROR, "Failed to load font face %s %s (from %s).", ft_face->family_name, ft_face->style_name, file_name.CString());
-        return false;
-    }
+	FT_Face ft_face = (FT_Face) instance->LoadFace(file_name);
+	if (ft_face == NULL)
+	{
+		Log::Message(Log::LT_ERROR, "Failed to load font face from %s.", file_name.CString());
+		return false;
+	}
+
+	if (instance->AddFace(ft_face, family, style, weight, true))
+	{
+		Log::Message(Log::LT_INFO, "Loaded font face %s %s (from %s).", ft_face->family_name, ft_face->style_name, file_name.CString());
+		return true;
+	}
+	else
+	{
+		Log::Message(Log::LT_ERROR, "Failed to load font face %s %s (from %s).", ft_face->family_name, ft_face->style_name, file_name.CString());
+		return false;
+	}
 }
 }
 
 
 // Adds a new font face to the database, loading from memory.
 // Adds a new font face to the database, loading from memory.
 bool FontProvider::LoadFontFace(const byte* data, int data_length)
 bool FontProvider::LoadFontFace(const byte* data, int data_length)
 {
 {
-    FT_Face ft_face = (FT_Face) instance->LoadFace(data, data_length, "memory", false);
-    if (ft_face == NULL)
-    {
-        Log::Message(Log::LT_ERROR, "Failed to load font face from byte stream.");
-        return false;
-    }
-
-    Font::Style style = ft_face->style_flags & FT_STYLE_FLAG_ITALIC ? Font::STYLE_ITALIC : Font::STYLE_NORMAL;
-    Font::Weight weight = ft_face->style_flags & FT_STYLE_FLAG_BOLD ? Font::WEIGHT_BOLD : Font::WEIGHT_NORMAL;
-
-    if (instance->AddFace(ft_face, ft_face->family_name, style, weight, false))
-    {
-        Log::Message(Log::LT_INFO, "Loaded font face %s %s (from byte stream).", ft_face->family_name, ft_face->style_name);
-        return true;
-    }
-    else
-    {
-        Log::Message(Log::LT_ERROR, "Failed to load font face %s %s (from byte stream).", ft_face->family_name, ft_face->style_name);
-        return false;
-    }
+	FT_Face ft_face = (FT_Face) instance->LoadFace(data, data_length, "memory", false);
+	if (ft_face == NULL)
+	{
+		Log::Message(Log::LT_ERROR, "Failed to load font face from byte stream.");
+		return false;
+	}
+
+	Font::Style style = ft_face->style_flags & FT_STYLE_FLAG_ITALIC ? Font::STYLE_ITALIC : Font::STYLE_NORMAL;
+	Font::Weight weight = ft_face->style_flags & FT_STYLE_FLAG_BOLD ? Font::WEIGHT_BOLD : Font::WEIGHT_NORMAL;
+
+	if (instance->AddFace(ft_face, ft_face->family_name, style, weight, false))
+	{
+		Log::Message(Log::LT_INFO, "Loaded font face %s %s (from byte stream).", ft_face->family_name, ft_face->style_name);
+		return true;
+	}
+	else
+	{
+		Log::Message(Log::LT_ERROR, "Failed to load font face %s %s (from byte stream).", ft_face->family_name, ft_face->style_name);
+		return false;
+	}
 }
 }
 
 
 // Adds a new font face to the database, loading from memory, ignoring any family, style and weight information stored in the face itself.
 // Adds a new font face to the database, loading from memory, ignoring any family, style and weight information stored in the face itself.
 bool FontProvider::LoadFontFace(const byte* data, int data_length, const String& family, Font::Style style, Font::Weight weight)
 bool FontProvider::LoadFontFace(const byte* data, int data_length, const String& family, Font::Style style, Font::Weight weight)
 {
 {
-    FT_Face ft_face = (FT_Face) instance->LoadFace(data, data_length, "memory", false);
-    if (ft_face == NULL)
-    {
-        Log::Message(Log::LT_ERROR, "Failed to load font face from byte stream.");
-        return false;
-    }
-
-    if (instance->AddFace(ft_face, family, style, weight, false))
-    {
-        Log::Message(Log::LT_INFO, "Loaded font face %s %s (from byte stream).", ft_face->family_name, ft_face->style_name);
-        return true;
-    }
-    else
-    {
-        Log::Message(Log::LT_ERROR, "Failed to load font face %s %s (from byte stream).", ft_face->family_name, ft_face->style_name);
-        return false;
-    }
+	FT_Face ft_face = (FT_Face) instance->LoadFace(data, data_length, "memory", false);
+	if (ft_face == NULL)
+	{
+		Log::Message(Log::LT_ERROR, "Failed to load font face from byte stream.");
+		return false;
+	}
+
+	if (instance->AddFace(ft_face, family, style, weight, false))
+	{
+		Log::Message(Log::LT_INFO, "Loaded font face %s %s (from byte stream).", ft_face->family_name, ft_face->style_name);
+		return true;
+	}
+	else
+	{
+		Log::Message(Log::LT_ERROR, "Failed to load font face %s %s (from byte stream).", ft_face->family_name, ft_face->style_name);
+		return false;
+	}
 }
 }
 
 
 // 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 = font_families.find(family);
-    if (iterator != font_families.end())
-        font_family = (FontFamily*)(*iterator).second;
-    else
-    {
-        font_family = new FontFamily(family);
-        font_families[family] = font_family;
-    }
-
-    return font_family->AddFace((FT_Face) face, style, weight, release_stream);
+	FontFamily* font_family = NULL;
+	FontFamilyMap::iterator iterator = font_families.find(family);
+	if (iterator != font_families.end())
+		font_family = (FontFamily*)(*iterator).second;
+	else
+	{
+		font_family = new FontFamily(family);
+		font_families[family] = font_family;
+	}
+
+	return font_family->AddFace((FT_Face) face, style, weight, release_stream);
 }
 }
 
 
 // Loads a FreeType face.
 // Loads a FreeType face.
 void* FontProvider::LoadFace(const String& file_name)
 void* FontProvider::LoadFace(const String& file_name)
 {
 {
-    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);
 
 
-    FT_Byte* buffer = new FT_Byte[length];
-    file_interface->Read(buffer, length, handle);
-    file_interface->Close(handle);
+	FT_Byte* buffer = new FT_Byte[length];
+	file_interface->Read(buffer, length, handle);
+	file_interface->Close(handle);
 
 
-    return LoadFace(buffer, (int)length, file_name, true);
+	return LoadFace(buffer, (int)length, file_name, true);
 }
 }
 
 
 // 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)
 {
 {
-    FT_Face face = NULL;
-    int error = FT_New_Memory_Face(ft_library, (const FT_Byte*) data, data_length, 0, &face);
-    if (error != 0)
-    {
-        Log::Message(Log::LT_ERROR, "FreeType error %d while loading face from %s.", error, source.CString());
-        if (local_data)
-            delete[] data;
-
-        return NULL;
-    }
-
-    // Initialise the character mapping on the face.
-    if (face->charmap == NULL)
-    {
-        FT_Select_Charmap(face, FT_ENCODING_APPLE_ROMAN);
-        if (face->charmap == NULL)
-        {
-            Log::Message(Log::LT_ERROR, "Font face (from %s) does not contain a Unicode or Apple Roman character map.", source.CString());
-            FT_Done_Face(face);
-            if (local_data)
-                delete[] data;
-
-            return NULL;
-        }
-    }
-
-    return face;
+	FT_Face face = NULL;
+	int error = FT_New_Memory_Face(ft_library, (const FT_Byte*) data, data_length, 0, &face);
+	if (error != 0)
+	{
+		Log::Message(Log::LT_ERROR, "FreeType error %d while loading face from %s.", error, source.CString());
+		if (local_data)
+			delete[] data;
+
+		return NULL;
+	}
+
+	// Initialise the character mapping on the face.
+	if (face->charmap == NULL)
+	{
+		FT_Select_Charmap(face, FT_ENCODING_APPLE_ROMAN);
+		if (face->charmap == NULL)
+		{
+			Log::Message(Log::LT_ERROR, "Font face (from %s) does not contain a Unicode or Apple Roman character map.", source.CString());
+			FT_Done_Face(face);
+			if (local_data)
+				delete[] data;
+
+			return NULL;
+		}
+	}
+
+	return face;
 }
 }
 
 
 }
 }