Browse Source

Remove BitmapFont provider

Michael Ragazzon 6 years ago
parent
commit
064cbb1493

+ 0 - 14
CMake/FileList.cmake

@@ -1,13 +1,6 @@
 # This file was auto-generated with gen_filelists.sh
 # This file was auto-generated with gen_filelists.sh
 
 
 set(Core_HDR_FILES
 set(Core_HDR_FILES
-    ${PROJECT_SOURCE_DIR}/Source/Core/BitmapFont/BitmapFontDefinitions.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/BitmapFont/FontFace.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/BitmapFont/FontFaceHandle.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/BitmapFont/FontFaceLayer.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/BitmapFont/FontFamily.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/BitmapFont/FontParser.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/BitmapFont/precompiled.h
     ${PROJECT_SOURCE_DIR}/Source/Core/Clock.h
     ${PROJECT_SOURCE_DIR}/Source/Core/Clock.h
     ${PROJECT_SOURCE_DIR}/Source/Core/ComputeProperty.h
     ${PROJECT_SOURCE_DIR}/Source/Core/ComputeProperty.h
     ${PROJECT_SOURCE_DIR}/Source/Core/ContextInstancerDefault.h
     ${PROJECT_SOURCE_DIR}/Source/Core/ContextInstancerDefault.h
@@ -109,7 +102,6 @@ set(MASTER_Core_PUB_HDR_FILES
 set(Core_PUB_HDR_FILES
 set(Core_PUB_HDR_FILES
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Animation.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Animation.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/BaseXMLParser.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/BaseXMLParser.h
-    ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/BitmapFont/FontProvider.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Box.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Box.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Colour.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Colour.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Colour.inl
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Colour.inl
@@ -200,12 +192,6 @@ set(Core_PUB_HDR_FILES
 
 
 set(Core_SRC_FILES
 set(Core_SRC_FILES
     ${PROJECT_SOURCE_DIR}/Source/Core/BaseXMLParser.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/BaseXMLParser.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/BitmapFont/FontFace.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/BitmapFont/FontFaceHandle.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/BitmapFont/FontFaceLayer.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/BitmapFont/FontFamily.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/BitmapFont/FontParser.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/BitmapFont/FontProvider.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/Box.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/Box.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/Clock.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/Clock.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/ComputeProperty.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/ComputeProperty.cpp

+ 0 - 101
Include/RmlUi/Core/BitmapFont/FontProvider.h

@@ -1,101 +0,0 @@
-/*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#ifndef RMLUICOREBITMAPFONTFONTPROVIDER_H
-#define RMLUICOREBITMAPFONTFONTPROVIDER_H
-
-#include "../StringUtilities.h"
-#include "../FontProvider.h"
-
-namespace Rml {
-namespace Core {
-
-
-class FontEffect;
-class FontFaceHandle;
-class PropertyDictionary;
-
-namespace BitmapFont {
-
-class FontFamily;
-
-/**
-    The font database contains all font families currently in use by RmlUi.
-    @author Peter Curry
- */
-
-class RMLUICORE_API FontProvider : public Rml::Core::FontProvider
-{
-public:
-    static bool Initialise();
-    static void Shutdown();
-
-    /// Adds a new font face to the database. The face's family, style and weight will be determined from the face itself.
-    /// @param[in] file_name The file to load the face from.
-    /// @return True if the face was loaded successfully, false otherwise.
-    static bool LoadFontFace(const String& file_name);
-    /// Adds a new font face to the database, ignoring any family, style and weight information stored in the face itself.
-    /// @param[in] file_name The file to load the face from.
-    /// @param[in] family The family to add the face to.
-    /// @param[in] style The style of the face (normal or italic).
-    /// @param[in] weight The weight of the face (normal or bold).
-    /// @return True if the face was loaded successfully, false otherwise.
-    static bool LoadFontFace(const String& file_name, const String& family, Style::FontStyle style, Style::FontWeight weight);
-    /// Adds a new font face to the database, loading from memory. The face's family, style and weight will be determined from the face itself.
-    /// @param[in] data The font data.
-    /// @param[in] data_length Length of the data.
-    /// @return True if the face was loaded successfully, false otherwise.
-    static bool LoadFontFace(const byte* data, int data_length);
-    /// Adds a new font face to the database, loading from memory.
-    /// @param[in] data The font data.
-    /// @param[in] data_length Length of the data.
-    /// @param[in] family The family to add the face to.
-    /// @param[in] style The style of the face (normal or italic).
-    /// @param[in] weight The weight of the face (normal or bold).
-    /// @return True if the face was loaded successfully, false otherwise.
-    static bool LoadFontFace(const byte* data, int data_length, const String& family, Style::FontStyle style, Style::FontWeight weight);
-
-private:
-    FontProvider(void);
-    ~FontProvider(void);
-
-    // Adds a loaded face to the appropriate font family.
-    bool AddFace(void* face, const String& family, Style::FontStyle style, Style::FontWeight weight, bool release_stream);
-    // Loads a FreeType face.
-    void* LoadFace(const String& file_name);
-    // Loads a FreeType face from memory.
-    void* LoadFace(const byte* data, int data_length, const String& source, bool local_data);
-
-    static FontProvider* instance;
-};
-
-}
-}
-}
-
-#endif

+ 2 - 11
Include/RmlUi/Core/FontDatabase.h

@@ -50,13 +50,6 @@ class PropertyDictionary;
 class RMLUICORE_API FontDatabase
 class RMLUICORE_API FontDatabase
 {
 {
 public:
 public:
-
-    enum FontProviderType
-    {
-        FreeType = 0,
-        BitmapFont
-    };
-
 	static bool Initialise();
 	static bool Initialise();
 	static void Shutdown();
 	static void Shutdown();
 
 
@@ -75,7 +68,7 @@ public:
 	/// @param[in] data The font data.
 	/// @param[in] data The font data.
 	/// @param[in] data_length Length of the data.
 	/// @param[in] data_length Length of the data.
 	/// @return True if the face was loaded successfully, false otherwise.
 	/// @return True if the face was loaded successfully, false otherwise.
-    static bool LoadFontFace(FontProviderType font_provider_type, const byte* data, int data_length);
+    static bool LoadFontFace(const byte* data, int data_length);
 	/// Adds a new font face to the database, loading from memory.
 	/// Adds a new font face to the database, loading from memory.
 	/// @param[in] data The font data.
 	/// @param[in] data The font data.
 	/// @param[in] data_length Length of the data.
 	/// @param[in] data_length Length of the data.
@@ -83,7 +76,7 @@ public:
 	/// @param[in] style The style of the face (normal or italic).
 	/// @param[in] style The style of the face (normal or italic).
 	/// @param[in] weight The weight of the face (normal or bold).
 	/// @param[in] weight The weight of the face (normal or bold).
 	/// @return True if the face was loaded successfully, false otherwise.
 	/// @return True if the face was loaded successfully, false otherwise.
-    static bool LoadFontFace(FontProviderType font_provider_type, const byte* data, int data_length, const String& family, Style::FontStyle style, Style::FontWeight weight);
+    static bool LoadFontFace(const byte* data, int data_length, const String& family, Style::FontStyle style, Style::FontWeight weight);
 
 
 	/// Returns a handle to a font face that can be used to position and render text. This will return the closest match
 	/// Returns a handle to a font face that can be used to position and render text. This will return the closest match
 	/// it can find, but in the event a font family is requested that does not exist, nullptr will be returned instead of a
 	/// it can find, but in the event a font family is requested that does not exist, nullptr will be returned instead of a
@@ -104,8 +97,6 @@ private:
 	FontDatabase(void);
 	FontDatabase(void);
 	~FontDatabase(void);
 	~FontDatabase(void);
 
 
-    static FontProviderType GetFontProviderType(const String& file_name);
-
     typedef std::vector< FontProvider *> FontProviderTable;
     typedef std::vector< FontProvider *> FontProviderTable;
 
 
     static FontProviderTable font_provider_table;
     static FontProviderTable font_provider_table;

+ 0 - 148
Source/Core/BitmapFont/BitmapFontDefinitions.h

@@ -1,148 +0,0 @@
-/*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#ifndef BITMAPFONTDEFINITIONS_H
-#define BITMAPFONTDEFINITIONS_H
-
-#include <RmlUi/Core/Header.h>
-#include <RmlUi/Core/Types.h>
-#include <RmlUi/Core/Dictionary.h>
-#include <set>
-
-namespace Rml {
-namespace Core {
-namespace BitmapFont {
-
-	struct FontInfo
-	{
-		String FamilyName;
-		String Source;
-		String BitmapSource;
-		int Size;
-		Style::FontStyle Style;
-		Style::FontWeight Weight;
-	};
-
-	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 KerningInfo
-	{
-		int FirstCharacterId;
-		int SecondCharacterId;
-		int KerningAmount;
-	};
-
-	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_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;
-		}
-
-	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;
-
-				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 );
-				}
-			}
-		}
-	};
-
-}
-}
-}
-#endif

+ 0 - 124
Source/Core/BitmapFont/FontFace.cpp

@@ -1,124 +0,0 @@
-/*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#include "precompiled.h"
-#include "FontFace.h"
-#include "FontFaceHandle.h"
-#include <RmlUi/Core/Log.h>
-
-namespace Rml {
-namespace Core {
-
-BitmapFont::FontFace::FontFace(BitmapFontDefinitions *_face, Style::FontStyle _style, Style::FontWeight _weight, bool _release_stream) : Rml::Core::FontFace(_style, _weight, _release_stream)
-{
-	face = _face;
-}
-
-BitmapFont::FontFace::~FontFace()
-{
-	ReleaseFace();
-}
-
-// Returns a handle for positioning and rendering this face at the given size.
-SharedPtr<Rml::Core::FontFaceHandle> BitmapFont::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)
-			{
-				return 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.c_str());
-			return nullptr;
-		}
-
-		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)
-			{
-				return handles[i];
-			}
-		}
-	}
-
-	// See if this face has been released.
-	if (!face)
-	{
-		Log::Message(Log::LT_WARNING, "Font face has been released, unable to generate new handle.");
-		return nullptr;
-	}
-
-	// Construct and initialise the new handle.
-	auto handle = std::make_shared<BitmapFont::FontFaceHandle>();
-	if (!handle->Initialise(face, _raw_charset, size))
-	{
-		return nullptr;
-	}
-
-	// 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);
-
-	return handle;
-}
-
-// Releases the face's structure.
-void BitmapFont::FontFace::ReleaseFace()
-{
-	delete face;
-}
-
-}
-}

+ 0 - 69
Source/Core/BitmapFont/FontFace.h

@@ -1,69 +0,0 @@
-/*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#ifndef RMLUICOREBITMAPFONTFACE_H
-#define RMLUICOREBITMAPFONTFACE_H
-
-#include "../../../Include/RmlUi/Core/FontFace.h"
-#include "BitmapFontDefinitions.h"
-
-namespace Rml {
-namespace Core {
-namespace BitmapFont {
-
-class FontFaceHandle;
-
-/**
-	@author Peter Curry
- */
-
-class FontFace : public Rml::Core::FontFace
-{
-public:
-	FontFace(BitmapFontDefinitions *_face, Style::FontStyle style, Style::FontWeight 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.
-	SharedPtr<Rml::Core::FontFaceHandle> GetHandle(const String& charset, int size) override;
-
-	/// 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() override;
-
-private:
-	BitmapFontDefinitions *face;
-};
-
-}
-}
-}
-
-#endif

+ 0 - 179
Source/Core/BitmapFont/FontFaceHandle.cpp

@@ -1,179 +0,0 @@
-/*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#include "precompiled.h"
-#include "FontFaceHandle.h"
-#include "FontFaceLayer.h"
-#include <algorithm>
-#include "../TextureLayout.h"
-
-namespace Rml {
-namespace Core {
-
-BitmapFont::FontFaceHandle::FontFaceHandle()
-{
-	bm_face = nullptr;
-	texture_width = 0;
-	texture_height = 0;
-}
-
-BitmapFont::FontFaceHandle::~FontFaceHandle()
-{
-}
-
-// Initialises the handle so it is able to render text.
-bool BitmapFont::FontFaceHandle::Initialise(BitmapFontDefinitions *_bm_face, const String& _charset, int _size)
-{
-	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.c_str());
-		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(nullptr);
-	layer_configurations.push_back(LayerConfiguration());
-	layer_configurations.back().push_back(base_layer);
-
-	return true;
-}
-
-void BitmapFont::FontFaceHandle::GenerateMetrics(BitmapFontDefinitions *bm_face)
-{
-	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;
-
-	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));
-
-	// 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;
-}
-
-void BitmapFont::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;
-	}
-}
-
-void 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 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 bitmap position.
-	glyph.bitmap_dimensions.x = bm_glyph->X;
-	glyph.bitmap_dimensions.y = bm_glyph->Y;
-
-	glyph.bitmap_data = nullptr;
-}
-
-int BitmapFont::FontFaceHandle::GetKerning(word lhs, word rhs) const
-{
-	if( bm_face != nullptr)
-	{
-		return bm_face->BM_Helper_GetXKerning(lhs, rhs);
-	}
-
-	return 0;
-}
-
-Rml::Core::FontFaceLayer* BitmapFont::FontFaceHandle::CreateNewLayer()
-{
-	return new BitmapFont::FontFaceLayer();
-}
-
-
-}
-}

+ 0 - 94
Source/Core/BitmapFont/FontFaceHandle.h

@@ -1,94 +0,0 @@
-/*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#ifndef RMLUICOREBITMAPFONTFONTFACEHANDLE_H
-#define RMLUICOREBITMAPFONTFONTFACEHANDLE_H
-
-#include "../UnicodeRange.h"
-#include "../../../Include/RmlUi/Core/FontEffect.h"
-#include "../../../Include/RmlUi/Core/FontGlyph.h"
-#include "../../../Include/RmlUi/Core/Geometry.h"
-#include "../../../Include/RmlUi/Core/Texture.h"
-#include "../FontFaceHandle.h"
-#include "BitmapFontDefinitions.h"
-
-namespace Rml {
-namespace Core {
-namespace BitmapFont {
-
-/**
-	@author Peter Curry
- */
-
-class FontFaceHandle : public Rml::Core::FontFaceHandle
-{
-public:
-	FontFaceHandle();
-	virtual ~FontFaceHandle();
-
-	/// Initialises the handle so it is able to render text.
-	bool Initialise(BitmapFontDefinitions *bm_face, const String& charset, int size);
-
-	const String & GetTextureSource() const
-	{
-		return texture_source;
-	}
-
-	unsigned int GetTextureWidth() const
-	{
-		return texture_width;
-	}
-
-	unsigned int GetTextureHeight() const
-	{
-		return texture_height;
-	}
-
-protected:
-	Rml::Core::FontFaceLayer* CreateNewLayer() override;
-
-private:
-	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 override;
-
-	BitmapFontDefinitions * bm_face;
-	String texture_source;
-	String texture_directory;
-	unsigned int texture_width;
-	unsigned int texture_height;
-};
-
-}
-}
-}
-
-#endif

+ 0 - 126
Source/Core/BitmapFont/FontFaceLayer.cpp

@@ -1,126 +0,0 @@
-/*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#include "precompiled.h"
-#include "FontFaceLayer.h"
-#include "FontFaceHandle.h"
-
-namespace Rml {
-namespace Core {
-
-BitmapFont::FontFaceLayer::FontFaceLayer() : Rml::Core::FontFaceLayer()
-{
-	handle = nullptr;
-	effect = nullptr;
-}
-
-BitmapFont::FontFaceLayer::~FontFaceLayer()
-{
-}
-
-// Generates the character and texture data for the layer.
-bool BitmapFont::FontFaceLayer::Initialise(const Rml::Core::FontFaceHandle* _handle, SharedPtr<const FontEffect> _effect, const Rml::Core::FontFaceLayer* clone, bool deep_clone)
-{
-	(void)(_effect);
-
-	Rml::Core::BitmapFont::FontFaceHandle
-		* bm_font_face_handle;
-
-	handle = _handle;
-
-	bm_font_face_handle = ( Rml::Core::BitmapFont::FontFaceHandle * ) handle;
-
-	const FontGlyphList& glyphs = handle->GetGlyphs();
-
-	// Clone the geometry and textures from the clone layer.
-	if (clone != nullptr)
-	{
-		// 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;
-
-		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;
-
-			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
-
-			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;
-
-			// 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;
-
-			// 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;
-
-	}
-	return true;
-}
-
-// Generates the texture data for a layer (for the texture database).
-bool BitmapFont::FontFaceLayer::GenerateTexture(const byte*& texture_data, Vector2i& texture_dimensions, int texture_id)
-{
-	return true;
-}
-
-}
-}

+ 0 - 78
Source/Core/BitmapFont/FontFaceLayer.h

@@ -1,78 +0,0 @@
-/*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#ifndef RMLUICOREBITMAPFONTFACELAYER_H
-#define RMLUICOREBITMAPFONTFACELAYER_H
-
-#include <RmlUi/Core/Header.h>
-#include <RmlUi/Core/FontGlyph.h>
-#include <RmlUi/Core/Geometry.h>
-#include <RmlUi/Core/GeometryUtilities.h>
-#include "../FontFaceLayer.h"
-
-namespace Rml {
-namespace Core {
-
-	class TextureLayout;
-
-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
- */
-
-class FontFaceLayer : public Rml::Core::FontFaceLayer
-{
-public:
-	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.
-	bool Initialise(const Rml::Core::FontFaceHandle* handle, SharedPtr<const FontEffect> effect, const Rml::Core::FontFaceLayer* clone = nullptr, bool deep_clone = false) override;
-
-	/// 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.
-	bool GenerateTexture(const byte*& texture_data, Vector2i& texture_dimensions, int texture_id) override;
-
-};
-
-}
-}
-}
-
-#endif

+ 0 - 54
Source/Core/BitmapFont/FontFamily.cpp

@@ -1,54 +0,0 @@
-/*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#include "precompiled.h"
-#include "FontFamily.h"
-#include "FontFace.h"
-
-namespace Rml {
-namespace Core {
-
-BitmapFont::FontFamily::FontFamily(const String& name) : Rml::Core::FontFamily(name)
-{
-}
-
-BitmapFont::FontFamily::~FontFamily()
-{
-}
-
-// Adds a new face to the family.
-bool BitmapFont::FontFamily::AddFace( void *bm_face, Style::FontStyle style, Style::FontWeight weight, bool release_stream)
-{
-	Rml::Core::FontFace* face = new BitmapFont::FontFace((BitmapFontDefinitions*)bm_face, style, weight, release_stream);
-	font_faces.push_back(face);
-
-	return true;
-}
-
-}
-}

+ 0 - 66
Source/Core/BitmapFont/FontFamily.h

@@ -1,66 +0,0 @@
-/*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#ifndef RMLUICOREBITMAPFONTFAMILY_H
-#define RMLUICOREBITMAPFONTFAMILY_H
-
-#include "../../../Include/RmlUi/Core/FontFamily.h"
-#include "BitmapFontDefinitions.h"
-
-namespace Rml {
-namespace Core {
-
-class FontFace;
-class FontFaceHandle;
-
-namespace BitmapFont {
-
-/**
-	@author Peter Curry
- */
-
-class FontFamily : public Rml::Core::FontFamily
-{
-public:
-	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, Style::FontStyle style, Style::FontWeight weight, bool release_stream) override;
-};
-
-}
-}
-}
-
-#endif

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

@@ -1,115 +0,0 @@
-/*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#include "precompiled.h"
-#include "FontParser.h"
-
-namespace Rml {
-namespace Core {
-
-BitmapFont::FontParser::FontParser( BitmapFontDefinitions *face )
-	: BaseXMLParser()
-{
-	bm_face = face;
-	char_id = 0;
-	kern_id = 0;
-}
-
-BitmapFont::FontParser::~FontParser()
-{
-}
-
-// Called when the parser finds the beginning of an element tag.
-void BitmapFont::FontParser::HandleElementStart(const String& name, const XMLAttributes& attributes)
-{
-	if ( name == "info" )
-	{
-		bm_face->Face.FamilyName = Get(attributes, "face", String());
-		bm_face->Face.Size = Get(attributes, "size", 0);
-		bm_face->Face.Weight = Get(attributes, "bold", false ) ? Style::FontWeight::Bold : Style::FontWeight::Normal;
-		bm_face->Face.Style = Get(attributes, "italic", false ) ? Style::FontStyle::Italic : Style::FontStyle::Normal;
-		bm_face->Face.BitmapSource = Get(attributes, "src", String());
-	}
-	else if ( name == "common" )
-	{
-		bm_face->CommonCharactersInfo.LineHeight = Get(attributes, "lineHeight", 0);
-		bm_face->CommonCharactersInfo.BaseLine = Get(attributes, "base", 0) * -1;
-		bm_face->CommonCharactersInfo.ScaleWidth = Get(attributes, "scaleW", 0);
-		bm_face->CommonCharactersInfo.ScaleHeight = Get(attributes, "scaleH", 0);
-		bm_face->CommonCharactersInfo.CharacterCount = 0;
-		bm_face->CommonCharactersInfo.KerningCount = 0;
-	}
-	else if ( name == "chars" )
-	{
-		bm_face->CommonCharactersInfo.CharacterCount = Get(attributes, "count", 0);
-		// Memory @leak ?
-		bm_face->CharactersInfo = new BitmapFont::CharacterInfo[ Get(attributes, "count", 0) ];
-	}
-	else if ( name == "char" )
-	{
-		bm_face->CharactersInfo[ char_id ].Id = Get(attributes, "id", 0);
-		bm_face->CharactersInfo[ char_id ].X = Get(attributes, "x", 0); //The left position of the character image in the texture.
-		bm_face->CharactersInfo[ char_id ].Y = Get(attributes, "y", 0); //The top position of the character image in the texture.
-		bm_face->CharactersInfo[ char_id ].Width = Get(attributes, "width", 0); //The width of the character image in the texture.
-		bm_face->CharactersInfo[ char_id ].Height = Get(attributes, "height", 0); //The height of the character image in the texture.
-		bm_face->CharactersInfo[ char_id ].XOffset = Get(attributes, "xoffset", 0);
-		bm_face->CharactersInfo[ char_id ].YOffset = Get(attributes, "yoffset", 0);
-		bm_face->CharactersInfo[ char_id ].Advance = Get(attributes, "xadvance", 0);
-
-		char_id++;
-	}
-	else if ( name == "kernings" )
-	{
-		bm_face->CommonCharactersInfo.KerningCount = Get(attributes, "count", 0);
-		// Memory @leak ?
-		bm_face->KerningsInfo = new BitmapFont::KerningInfo[ Get(attributes, "count", 0) ];
-	}
-	else if ( name == "kerning" )
-	{
-		bm_face->KerningsInfo[ kern_id ].FirstCharacterId = Get(attributes, "first", 0);
-		bm_face->KerningsInfo[ kern_id ].SecondCharacterId = Get(attributes, "second", 0);
-		bm_face->KerningsInfo[ kern_id ].KerningAmount = Get(attributes, "amount", 0);
-
-		kern_id++;
-	}
-}
-
-// Called when the parser finds the end of an element tag.
-void BitmapFont::FontParser::HandleElementEnd(const String& RMLUI_UNUSED_PARAMETER(name))
-{
-	RMLUI_UNUSED(name);
-}
-
-// Called when the parser encounters data.
-void BitmapFont::FontParser::HandleData(const String& RMLUI_UNUSED_PARAMETER(data))
-{
-	RMLUI_UNUSED(data);
-}
-
-}
-}

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

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

+ 0 - 206
Source/Core/BitmapFont/FontProvider.cpp

@@ -1,206 +0,0 @@
-/*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#include "precompiled.h"
-#include <RmlUi/Core/BitmapFont/FontProvider.h>
-#include "../FontFaceHandle.h"
-#include <RmlUi/Core/FontDatabase.h>
-#include <RmlUi/Core/StreamMemory.h>
-#include "FontFamily.h"
-#include <RmlUi/Core.h>
-#include "BitmapFontDefinitions.h"
-#include "FontParser.h"
-
-namespace Rml {
-namespace Core {
-
-BitmapFont::FontProvider* BitmapFont::FontProvider::instance = nullptr;
-
-BitmapFont::FontProvider::FontProvider()
-{
-	RMLUI_ASSERT(instance == nullptr);
-	instance = this;
-}
-
-BitmapFont::FontProvider::~FontProvider()
-{
-	RMLUI_ASSERT(instance == this);
-	instance = nullptr;
-}
-
-bool BitmapFont::FontProvider::Initialise()
-{
-	if (instance == nullptr)
-	{
-		new FontProvider();
-
-		FontDatabase::AddFontProvider(instance);
-	}
-
-	return true;
-}
-
-void BitmapFont::FontProvider::Shutdown()
-{
-	if (instance != nullptr)
-	{
-		FontDatabase::RemoveFontProvider(instance);
-		delete instance;
-		instance = nullptr;
-	}
-}
-
-// Adds a new font face to the database, ignoring any family, style and weight information stored in the face itself.
-bool BitmapFont::FontProvider::LoadFontFace(const String& file_name)
-{
-	BitmapFont::BitmapFontDefinitions *bm_font = (BitmapFont::BitmapFontDefinitions*) instance->LoadFace(file_name);
-
-	if (bm_font == nullptr)
-	{
-		Log::Message(Log::LT_ERROR, "Failed to load font face from %s.", file_name.c_str());
-		return false;
-	}
-
-	Style::FontStyle style = bm_font->Face.Style;
-	Style::FontWeight 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.c_str(), file_name.c_str());
-		return true;
-	}
-	else
-	{
-		Log::Message(Log::LT_ERROR, "Failed to load font face %s (from %s).", bm_font->Face.FamilyName.c_str(), file_name.c_str());
-		return false;
-	}
-
-	return true;
-}
-
-// Loads a new font face.
-bool BitmapFont::FontProvider::LoadFontFace(const String& file_name, const String& family, Style::FontStyle style, Style::FontWeight weight)
-{
-	BitmapFont::BitmapFontDefinitions *bm_font = (BitmapFont::BitmapFontDefinitions*) instance->LoadFace(file_name);
-	if (bm_font == nullptr)
-	{
-		Log::Message(Log::LT_ERROR, "Failed to load font face from %s.", file_name.c_str());
-		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.c_str(), file_name.c_str());
-		return true;
-	}
-	else
-	{
-		Log::Message(Log::LT_ERROR, "Failed to load font face %s (from %s).", bm_font->Face.FamilyName.c_str(), file_name.c_str());
-		return false;
-	}
-
-	return true;
-}
-
-bool BitmapFont::FontProvider::LoadFontFace(const byte* data, int data_length)
-{
-	// TODO: Loading from memory
-	return false;
-}
-
-// Adds a new font face to the database, loading from memory.
-bool BitmapFont::FontProvider::LoadFontFace(const byte* data, int data_length, const String& family, Style::FontStyle style, Style::FontWeight weight)
-{
-	// TODO Loading from memory
-	return false;
-}
-
-// Adds a loaded face to the appropriate font family.
-bool BitmapFont::FontProvider::AddFace(void* face, const String& family, Style::FontStyle style, Style::FontWeight weight, bool release_stream)
-{
-	String family_lower = StringUtilities::ToLower(family);
-	Rml::Core::FontFamily* font_family = nullptr;
-	FontFamilyMap::iterator iterator = instance->font_families.find(family_lower);
-	if (iterator != instance->font_families.end())
-		font_family = (*iterator).second;
-	else
-	{
-		font_family = new FontFamily(family_lower);
-		instance->font_families[family_lower] = font_family;
-	}
-
-	return font_family->AddFace((BitmapFontDefinitions *) face, style, weight, release_stream);
-}
-
-// Loads a FreeType face.
-void* BitmapFont::FontProvider::LoadFace(const String& file_name)
-{
-	BitmapFont::BitmapFontDefinitions *bm_face = new BitmapFont::BitmapFontDefinitions();
-	BitmapFont::FontParser parser( bm_face );
-
-	FileInterface* file_interface = GetFileInterface();
-	FileHandle handle = file_interface->Open(file_name);
-
-	if (!handle)
-	{
-		return nullptr;
-	}
-
-	size_t length = file_interface->Length(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 );
-
-	parser.Parse( stream );
-
-	bm_face->Face.Source = file_name;
-	return bm_face;
-}
-
-// Loads a FreeType face from memory.
-void* BitmapFont::FontProvider::LoadFace(const byte* data, int data_length, const String& source, bool local_data)
-{
-	URL file_url = source + ".fnt";
-
-	BitmapFont::BitmapFontDefinitions *bm_face = new BitmapFont::BitmapFontDefinitions();
-	BitmapFont::FontParser parser( bm_face );
-	StreamMemory* stream = new StreamMemory( data, data_length );
-	stream->SetSourceURL( file_url );
-
-	parser.Parse( stream );
-
-	bm_face->Face.Source = file_url.GetPathedFileName();
-	return bm_face;
-}
-
-}
-}

+ 0 - 34
Source/Core/BitmapFont/precompiled.h

@@ -1,34 +0,0 @@
-/*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#ifndef RMLUICOREBITMAPFONTPRECOMPILED_H
-#define RMLUICOREBITMAPFONTPRECOMPILED_H
-
-#include "../precompiled.h"
-
-#endif

+ 6 - 67
Source/Core/FontDatabase.cpp

@@ -31,7 +31,6 @@
 #include <RmlUi/Core/FontFamily.h>
 #include <RmlUi/Core/FontFamily.h>
 #include <RmlUi/Core.h>
 #include <RmlUi/Core.h>
 #include <RmlUi/Core/FreeType/FontProvider.h>
 #include <RmlUi/Core/FreeType/FontProvider.h>
-#include <RmlUi/Core/BitmapFont/FontProvider.h>
 
 
 namespace Rml {
 namespace Rml {
 namespace Core {
 namespace Core {
@@ -59,9 +58,6 @@ bool FontDatabase::Initialise()
 
 
         if(!FreeType::FontProvider::Initialise())
         if(!FreeType::FontProvider::Initialise())
             return false;
             return false;
-
-        if(!BitmapFont::FontProvider::Initialise())
-            return false;
 	}
 	}
 
 
 	return true;
 	return true;
@@ -72,7 +68,6 @@ void FontDatabase::Shutdown()
 	if (instance != nullptr)
 	if (instance != nullptr)
 	{
 	{
         FreeType::FontProvider::Shutdown();
         FreeType::FontProvider::Shutdown();
-        BitmapFont::FontProvider::Shutdown();
 
 
 		delete instance;
 		delete instance;
 	}
 	}
@@ -81,81 +76,25 @@ void FontDatabase::Shutdown()
 // Loads a new font face.
 // Loads a new font face.
 bool FontDatabase::LoadFontFace(const String& file_name)
 bool FontDatabase::LoadFontFace(const String& file_name)
 {
 {
-    FontProviderType font_provider_type = GetFontProviderType(file_name);
-
-    switch(font_provider_type)
-    {
-        case FreeType:
-            return FreeType::FontProvider::LoadFontFace(file_name);
-
-        case BitmapFont:
-            return BitmapFont::FontProvider::LoadFontFace(file_name);
-
-        default:
-            return false;
-    }
+	return FreeType::FontProvider::LoadFontFace(file_name);
 }
 }
 
 
 // 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 FontDatabase::LoadFontFace(const String& file_name, const String& family, Style::FontStyle style, Style::FontWeight weight)
 bool FontDatabase::LoadFontFace(const String& file_name, const String& family, Style::FontStyle style, Style::FontWeight weight)
 {
 {
-    FontProviderType font_provider_type = GetFontProviderType(file_name);
-
-    switch(font_provider_type)
-    {
-        case FreeType:
-            return FreeType::FontProvider::LoadFontFace(file_name, family, style, weight);
-
-        case BitmapFont:
-            return BitmapFont::FontProvider::LoadFontFace(file_name, family, style, weight);
-
-        default:
-            return false;
-    }
+	return FreeType::FontProvider::LoadFontFace(file_name, family, style, weight);
 }
 }
 
 
 // Adds a new font face to the database, loading from memory.
 // Adds a new font face to the database, loading from memory.
-bool FontDatabase::LoadFontFace(FontProviderType font_provider_type, const byte* data, int data_length)
+bool FontDatabase::LoadFontFace(const byte* data, int data_length)
 {
 {
-    switch(font_provider_type)
-    {
-        case FreeType:
-            return FreeType::FontProvider::LoadFontFace(data, data_length);
-
-        case BitmapFont:
-            return BitmapFont::FontProvider::LoadFontFace(data, data_length);
-
-        default:
-            return false;
-    }
+	return FreeType::FontProvider::LoadFontFace(data, data_length);
 }
 }
 
 
 // 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 FontDatabase::LoadFontFace(FontProviderType font_provider_type, const byte* data, int data_length, const String& family, Style::FontStyle style, Style::FontWeight weight)
+bool FontDatabase::LoadFontFace(const byte* data, int data_length, const String& family, Style::FontStyle style, Style::FontWeight weight)
 {
 {
-    switch(font_provider_type)
-    {
-        case FreeType:
-            return FreeType::FontProvider::LoadFontFace(data, data_length, family, style, weight);
-
-        case BitmapFont:
-            return BitmapFont::FontProvider::LoadFontFace(data, data_length, family, style, weight);
-
-        default:
-            return false;
-    }
-}
-
-FontDatabase::FontProviderType FontDatabase::GetFontProviderType(const String& file_name)
-{
-    if(file_name.find(".fnt") != String::npos)
-    {
-        return BitmapFont;
-    }
-    else
-    {
-        return FreeType;
-    }
+	return FreeType::FontProvider::LoadFontFace(data, data_length, family, style, weight);
 }
 }
 
 
 // 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.

+ 2 - 2
Source/Debugger/Plugin.cpp

@@ -277,8 +277,8 @@ Plugin* Plugin::GetInstance()
 
 
 bool Plugin::LoadFont()
 bool Plugin::LoadFont()
 {
 {
-	return (Core::FontDatabase::LoadFontFace(Core::FontDatabase::FreeType, lacuna_regular, sizeof(lacuna_regular) / sizeof(unsigned char), "Lacuna", Core::Style::FontStyle::Normal, Core::Style::FontWeight::Normal) &&
-			Core::FontDatabase::LoadFontFace(Core::FontDatabase::FreeType, lacuna_italic, sizeof(lacuna_italic) / sizeof(unsigned char), "Lacuna", Core::Style::FontStyle::Italic, Core::Style::FontWeight::Normal));
+	return (Core::FontDatabase::LoadFontFace(lacuna_regular, sizeof(lacuna_regular) / sizeof(unsigned char), "Lacuna", Core::Style::FontStyle::Normal, Core::Style::FontWeight::Normal) &&
+			Core::FontDatabase::LoadFontFace(lacuna_italic, sizeof(lacuna_italic) / sizeof(unsigned char), "Lacuna", Core::Style::FontStyle::Italic, Core::Style::FontWeight::Normal));
 }
 }
 
 
 bool Plugin::LoadMenuElement()
 bool Plugin::LoadMenuElement()