Browse Source

Refactoring FontEngineDefault (part I). Isolate the interface with FreeType. All font engine default files moved to a separate folder.

Michael Ragazzon 6 years ago
parent
commit
cd670fc143
34 changed files with 520 additions and 820 deletions
  1. 18 23
      CMake/FileList.cmake
  2. 5 1
      Source/Core/Core.cpp
  3. 0 1
      Source/Core/Element.cpp
  4. 0 1
      Source/Core/ElementStyle.cpp
  5. 0 1
      Source/Core/ElementTextDefault.cpp
  6. 0 1
      Source/Core/ElementUtilities.cpp
  7. 10 30
      Source/Core/FontEngineDefault/FontDatabaseDefault.cpp
  8. 0 0
      Source/Core/FontEngineDefault/FontDatabaseDefault.h
  9. 0 0
      Source/Core/FontEngineDefault/FontEngineInterfaceDefault.cpp
  10. 1 1
      Source/Core/FontEngineDefault/FontEngineInterfaceDefault.h
  11. 35 24
      Source/Core/FontEngineDefault/FontFace.cpp
  12. 10 7
      Source/Core/FontEngineDefault/FontFace.h
  13. 30 14
      Source/Core/FontEngineDefault/FontFaceHandleDefault.cpp
  14. 15 26
      Source/Core/FontEngineDefault/FontFaceHandleDefault.h
  15. 0 1
      Source/Core/FontEngineDefault/FontFaceLayer.cpp
  16. 5 5
      Source/Core/FontEngineDefault/FontFaceLayer.h
  17. 12 0
      Source/Core/FontEngineDefault/FontFamily.cpp
  18. 10 9
      Source/Core/FontEngineDefault/FontFamily.h
  19. 196 0
      Source/Core/FontEngineDefault/FontProvider.cpp
  20. 25 5
      Source/Core/FontEngineDefault/FontProvider.h
  21. 16 25
      Source/Core/FontEngineDefault/FontTypes.h
  22. 111 45
      Source/Core/FontEngineDefault/FreeTypeInterface.cpp
  23. 18 21
      Source/Core/FontEngineDefault/FreeTypeInterface.h
  24. 2 2
      Source/Core/FontEngineDefault/precompiled.h
  25. 0 58
      Source/Core/FontProvider.cpp
  26. 0 71
      Source/Core/FreeType/FontFace.h
  27. 0 75
      Source/Core/FreeType/FontFaceHandle.h
  28. 0 63
      Source/Core/FreeType/FontFamily.cpp
  29. 0 228
      Source/Core/FreeType/FontProvider.cpp
  30. 0 78
      Source/Core/FreeType/FontProvider.h
  31. 0 1
      Source/Core/LayoutInlineBox.cpp
  32. 0 1
      Source/Core/LayoutInlineBoxText.cpp
  33. 0 1
      Source/Core/LayoutLineBox.cpp
  34. 1 1
      Source/Core/TextureResource.cpp

+ 18 - 23
CMake/FileList.cmake

@@ -31,22 +31,20 @@ set(Core_HDR_FILES
     ${PROJECT_SOURCE_DIR}/Source/Core/EventIterators.h
     ${PROJECT_SOURCE_DIR}/Source/Core/EventSpecification.h
     ${PROJECT_SOURCE_DIR}/Source/Core/FileInterfaceDefault.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/FontDatabaseDefault.h
     ${PROJECT_SOURCE_DIR}/Source/Core/FontEffectOutline.h
     ${PROJECT_SOURCE_DIR}/Source/Core/FontEffectOutlineInstancer.h
     ${PROJECT_SOURCE_DIR}/Source/Core/FontEffectShadow.h
     ${PROJECT_SOURCE_DIR}/Source/Core/FontEffectShadowInstancer.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineInterfaceDefault.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/FontFace.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/FontFaceHandleDefault.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/FontFaceLayer.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/FontFamily.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/FontProvider.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/FreeType/FontFace.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/FreeType/FontFaceHandle.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/FreeType/FontFamily.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/FreeType/FontProvider.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/FreeType/precompiled.h
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/FontDatabaseDefault.h
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/FontEngineInterfaceDefault.h
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/FontFace.h
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/FontFaceHandleDefault.h
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/FontFaceLayer.h
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/FontFamily.h
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/FontProvider.h
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/FontTypes.h
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/FreeTypeInterface.h
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/precompiled.h
     ${PROJECT_SOURCE_DIR}/Source/Core/IdNameMap.h
     ${PROJECT_SOURCE_DIR}/Source/Core/LayoutBlockBox.h
     ${PROJECT_SOURCE_DIR}/Source/Core/LayoutBlockBoxSpace.h
@@ -239,24 +237,21 @@ set(Core_SRC_FILES
     ${PROJECT_SOURCE_DIR}/Source/Core/Factory.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/FileInterface.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/FileInterfaceDefault.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/FontDatabaseDefault.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/FontEffect.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/FontEffectInstancer.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/FontEffectOutline.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/FontEffectOutlineInstancer.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/FontEffectShadow.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/FontEffectShadowInstancer.cpp
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/FontDatabaseDefault.cpp
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/FontEngineInterfaceDefault.cpp
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/FontFace.cpp
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/FontFaceHandleDefault.cpp
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/FontFaceLayer.cpp
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/FontFamily.cpp
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/FontProvider.cpp
+    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineDefault/FreeTypeInterface.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineInterface.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/FontEngineInterfaceDefault.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/FontFace.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/FontFaceHandleDefault.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/FontFaceLayer.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/FontFamily.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/FontProvider.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/FreeType/FontFace.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/FreeType/FontFaceHandle.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/FreeType/FontFamily.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/FreeType/FontProvider.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/Geometry.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/GeometryUtilities.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/LayoutBlockBox.cpp

+ 5 - 1
Source/Core/Core.cpp

@@ -30,13 +30,17 @@
 #include "../../Include/RmlUi/Core.h"
 #include "EventSpecification.h"
 #include "FileInterfaceDefault.h"
-#include "FontEngineInterfaceDefault.h"
 #include "PluginRegistry.h"
 #include "StyleSheetFactory.h"
 #include "TemplateCache.h"
 #include "TextureDatabase.h"
 #include "EventSpecification.h"
 
+#ifndef RMLUI_NO_FONT_INTERFACE_DEFAULT
+#include "FontEngineDefault/FontEngineInterfaceDefault.h"
+#endif
+
+
 namespace Rml {
 namespace Core {
 

+ 0 - 1
Source/Core/Element.cpp

@@ -45,7 +45,6 @@
 #include "EventDispatcher.h"
 #include "EventSpecification.h"
 #include "ElementDecoration.h"
-#include "FontFaceHandleDefault.h"
 #include "LayoutEngine.h"
 #include "PluginRegistry.h"
 #include "PropertiesIterator.h"

+ 0 - 1
Source/Core/ElementStyle.cpp

@@ -43,7 +43,6 @@
 #include "ElementBorder.h"
 #include "ElementDecoration.h"
 #include "ElementDefinition.h"
-#include "FontFaceHandleDefault.h"
 #include "ComputeProperty.h"
 #include "PropertiesIterator.h"
 

+ 0 - 1
Source/Core/ElementTextDefault.cpp

@@ -30,7 +30,6 @@
 #include "ElementTextDefault.h"
 #include "ElementDefinition.h"
 #include "ElementStyle.h"
-#include "FontFaceHandleDefault.h"
 #include "../../Include/RmlUi/Core/ElementDocument.h"
 #include "../../Include/RmlUi/Core/ElementUtilities.h"
 #include "../../Include/RmlUi/Core/Event.h"

+ 0 - 1
Source/Core/ElementUtilities.cpp

@@ -32,7 +32,6 @@
 #include "../../Include/RmlUi/Core/ElementUtilities.h"
 #include <queue>
 #include <limits>
-#include "FontFaceHandleDefault.h"
 #include "LayoutEngine.h"
 #include "ElementStyle.h"
 

+ 10 - 30
Source/Core/FontDatabaseDefault.cpp → Source/Core/FontEngineDefault/FontDatabaseDefault.cpp

@@ -30,7 +30,6 @@
 #include <RmlUi/Core.h>
 #include "FontFamily.h"
 #include "FontFace.h"
-#include "FreeType/FontProvider.h"
 #include "FontDatabaseDefault.h"
 
 namespace Rml {
@@ -59,7 +58,7 @@ bool FontDatabaseDefault::Initialise()
 	{
 		new FontDatabaseDefault();
 
-        if(!FontProvider_FreeType::Initialise())
+        if(!FontProvider::Initialise())
             return false;
 	}
 
@@ -70,7 +69,7 @@ void FontDatabaseDefault::Shutdown()
 {
 	if (instance != nullptr)
 	{
-        FontProvider_FreeType::Shutdown();
+		FontProvider::Shutdown();
 
 		delete instance;
 	}
@@ -79,28 +78,18 @@ void FontDatabaseDefault::Shutdown()
 // Loads a new font face.
 bool FontDatabaseDefault::LoadFontFace(const String& file_name, bool fallback_face)
 {
-	return FontProvider_FreeType::LoadFontFace(file_name, fallback_face);
+	return FontProvider::Get().LoadFontFace(file_name, fallback_face);
 }
 
 bool FontDatabaseDefault::LoadFontFace(const byte* data, int data_size, const String& font_family, Style::FontStyle style, Style::FontWeight weight, bool fallback_face)
 {
-	return FontProvider_FreeType::LoadFontFace(data, data_size, font_family, style, weight, fallback_face);
+	return FontProvider::Get().LoadFontFace(data, data_size, font_family, style, weight, fallback_face);
 }
 
 // Returns a handle to a font face that can be used to position and render text.
 SharedPtr<FontFaceHandleDefault> FontDatabaseDefault::GetFontFaceHandle(const String& family, Style::FontStyle style, Style::FontWeight weight, int size)
 {
-    size_t provider_count = font_provider_table.size();
-
-    for(size_t provider_index = 0; provider_index < provider_count; ++provider_index)
-    {
-		SharedPtr<FontFaceHandleDefault> face_handle = font_provider_table[ provider_index ]->GetFontFaceHandle(family, style, weight, size);
-
-        if(face_handle)
-            return face_handle;
-    }
-
-    return nullptr;
+	return FontProvider::Get().GetFontFaceHandle(family, style, weight, size);
 }
 
 void FontDatabaseDefault::AddFontProvider(FontProvider * provider)
@@ -122,25 +111,16 @@ void FontDatabaseDefault::RemoveFontProvider(FontProvider * provider)
 
 int FontDatabaseDefault::CountFallbackFontFaces()
 {
-	int count = 0;
-	for (const FontProvider* provider : instance->font_provider_table)
-		count += (int)provider->GetFallbackFontFaces().size();
-
-	return count;
+	return (int)FontProvider::Get().GetFallbackFontFaces().size();
 }
 
 SharedPtr<FontFaceHandleDefault> FontDatabaseDefault::GetFallbackFontFace(int index, int font_size)
 {
-	int iterate_index = 0;
-	for (const FontProvider* provider : instance->font_provider_table)
-	{
-		const FontFaceList& faces = provider->GetFallbackFontFaces();
-		int faces_index = index - iterate_index;
-		int faces_count = (int)faces.size();
-		if (faces_index >= 0 && faces_index < faces_count)
-			return faces[faces_index]->GetHandle(font_size);
+	auto& faces = FontProvider::Get().GetFallbackFontFaces();
 
-		iterate_index += faces_count;
+	if (index >= 0 && index < (int)faces.size())
+	{
+		return faces[index]->GetHandle(font_size);
 	}
 
 	return nullptr;

+ 0 - 0
Source/Core/FontDatabaseDefault.h → Source/Core/FontEngineDefault/FontDatabaseDefault.h


+ 0 - 0
Source/Core/FontEngineInterfaceDefault.cpp → Source/Core/FontEngineDefault/FontEngineInterfaceDefault.cpp


+ 1 - 1
Source/Core/FontEngineInterfaceDefault.h → Source/Core/FontEngineDefault/FontEngineInterfaceDefault.h

@@ -28,7 +28,7 @@
 #ifndef RMLUICOREFONTENGINEINTERFACEDEFAULT_H
 #define RMLUICOREFONTENGINEINTERFACEDEFAULT_H
 
-#include "../../Include/RmlUi/Core/FontEngineInterface.h"
+#include "../../../Include/RmlUi/Core/FontEngineInterface.h"
 
 namespace Rml {
 namespace Core {

+ 35 - 24
Source/Core/FreeType/FontFace.cpp → Source/Core/FontEngineDefault/FontFace.cpp

@@ -27,29 +27,46 @@
  */
 
 #include "precompiled.h"
-
-#ifndef RMLUI_NO_FONT_INTERFACE_DEFAULT
-
-#include "FontFace.h"
-#include "FontFaceHandle.h"
 #include "../../../Include/RmlUi/Core/Log.h"
+#include "FontFace.h"
+#include "FontFaceHandleDefault.h"
+#include "FreeTypeInterface.h"
 
 namespace Rml {
 namespace Core {
 
-FontFace_FreeType::FontFace_FreeType(FT_Face _face, Style::FontStyle _style, Style::FontWeight _weight, bool _release_stream) : Rml::Core::FontFace(_style, _weight, _release_stream)
+FontFace::FontFace(FontFaceHandleFreetype _face, Style::FontStyle _style, Style::FontWeight _weight, bool _release_stream)
 {
+	style = _style;
+	weight = _weight;
 	face = _face;
+
+	release_stream = _release_stream;
 }
 
-FontFace_FreeType::~FontFace_FreeType()
+FontFace::~FontFace()
 {
 	ReleaseFace();
+	handles.clear();
+}
+
+// Returns the style of the font face.
+Style::FontStyle FontFace::GetStyle() const
+{
+	return style;
 }
 
-// Returns a handle for positioning and rendering this face at the given size.
-SharedPtr<Rml::Core::FontFaceHandleDefault> FontFace_FreeType::GetHandle(int size)
+// Returns the weight of the font face.
+Style::FontWeight FontFace::GetWeight() const
 {
+	return weight;
+}
+
+/// Returns a handle for positioning and rendering this face at the given size.
+/// @param[in] size The size of the desired handle, in points.
+/// @return The shared font handle.
+
+SharedPtr<FontFaceHandleDefault> FontFace::GetHandle(int size) {
 	auto it = handles.find(size);
 	if (it != handles.end())
 		return it->second;
@@ -62,8 +79,8 @@ SharedPtr<Rml::Core::FontFaceHandleDefault> FontFace_FreeType::GetHandle(int siz
 	}
 
 	// Construct and initialise the new handle.
-	auto handle = std::make_shared<FontFaceHandle_FreeType>();
-	if (!handle->Initialise(face, size))
+	auto handle = std::make_shared<FontFaceHandleDefault>();
+	if (!handle->Initialize(face, size))
 	{
 		handles[size] = nullptr;
 		return nullptr;
@@ -75,22 +92,16 @@ SharedPtr<Rml::Core::FontFaceHandleDefault> FontFace_FreeType::GetHandle(int siz
 	return handle;
 }
 
-// Releases the face's FreeType face structure.
-void FontFace_FreeType::ReleaseFace()
-{
-	if (face != nullptr)
-	{
-		FT_Byte* face_memory = face->stream->base;
-		FT_Done_Face(face);
-
-		if (release_stream)
-			delete[] face_memory;
+/// Releases the face's FreeType face structure. This will mean handles for new sizes cannot be constructed,
+/// but existing ones can still be fetched.
 
-		face = nullptr;
+void FontFace::ReleaseFace() {
+	if (face)
+	{
+		FreeType::ReleaseFace(face, release_stream);
+		face = 0;
 	}
 }
 
 }
 }
-
-#endif

+ 10 - 7
Source/Core/FontFace.h → Source/Core/FontEngineDefault/FontFace.h

@@ -29,7 +29,8 @@
 #ifndef RMLUICOREFONTFACE_H
 #define RMLUICOREFONTFACE_H
 
-#include <RmlUi/Core/ComputedValues.h>
+#include "../../../Include/RmlUi/Core/ComputedValues.h"
+#include "FontTypes.h"
 
 namespace Rml {
 namespace Core {
@@ -40,11 +41,11 @@ class FontFaceHandleDefault;
 	@author Peter Curry
  */
 
-class FontFace
+class FontFace final
 {
 public:
-	FontFace(Style::FontStyle style, Style::FontWeight weight, bool release_stream);
-	virtual ~FontFace();
+	FontFace(FontFaceHandleFreetype face, Style::FontStyle style, Style::FontWeight weight, bool release_stream);
+	~FontFace();
 
 	/// Returns the style of the font face.
 	/// @return The font face's style.
@@ -56,13 +57,13 @@ public:
 	/// Returns a handle for positioning and rendering this face at the given size.
 	/// @param[in] size The size of the desired handle, in points.
 	/// @return The shared font handle.
-	virtual SharedPtr<FontFaceHandleDefault> GetHandle(int size) = 0;
+	SharedPtr<FontFaceHandleDefault> GetHandle(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.
-	virtual void ReleaseFace() = 0;
+	void ReleaseFace();
 
-protected:
+private:
 	Style::FontStyle style;
 	Style::FontWeight weight;
 
@@ -71,6 +72,8 @@ protected:
 	// Key is font size
 	using HandleMap = UnorderedMap< int, SharedPtr<FontFaceHandleDefault> >;
 	HandleMap handles;
+
+	FontFaceHandleFreetype face;
 };
 
 }

+ 30 - 14
Source/Core/FontFaceHandleDefault.cpp → Source/Core/FontEngineDefault/FontFaceHandleDefault.cpp

@@ -27,12 +27,12 @@
  */
 
 #include "precompiled.h"
+#include "../TextureLayout.h"
 #include "FontFaceHandleDefault.h"
 #include "FontDatabaseDefault.h"
-#include <algorithm>
-#include "../../Include/RmlUi/Core.h"
 #include "FontFaceLayer.h"
-#include "TextureLayout.h"
+#include "FreeTypeInterface.h"
+#include <algorithm>
 
 namespace Rml {
 namespace Core {
@@ -41,8 +41,9 @@ namespace Core {
 	
 FontFaceHandleDefault::FontFaceHandleDefault()
 {
-	metrics = {};
 	base_layer = nullptr;
+	metrics = {};
+	ft_face = 0;
 }
 
 FontFaceHandleDefault::~FontFaceHandleDefault()
@@ -51,6 +52,24 @@ FontFaceHandleDefault::~FontFaceHandleDefault()
 	layers.clear();
 }
 
+bool FontFaceHandleDefault::Initialize(FontFaceHandleFreetype face, int font_size)
+{
+	ft_face = face;
+
+	RMLUI_ASSERTMSG(layer_configurations.empty(), "Initialize must only be called once.");
+
+	if (!FreeType::InitialiseFaceHandle(ft_face, glyphs, metrics, font_size))
+	{
+		return false;
+	}
+
+	// Generate the default layer and layer configuration.
+	base_layer = GetOrCreateLayer(nullptr);
+	layer_configurations.push_back(LayerConfiguration{ base_layer });
+
+	return true;
+}
+
 // Returns the point size of this font face.
 int FontFaceHandleDefault::GetSize() const
 {
@@ -282,19 +301,16 @@ int FontFaceHandleDefault::GetVersion() const
 	return version;
 }
 
-FontGlyphMap& FontFaceHandleDefault::GetGlyphs() {
-	return glyphs;
-}
-
-FontMetrics& FontFaceHandleDefault::GetMetrics() {
-	return metrics;
+bool FontFaceHandleDefault::AppendGlyph(CodePoint code_point) 
+{
+	bool result = FreeType::AppendGlyph(ft_face, code_point, metrics.size, glyphs);
+	return result;
 }
 
-void FontFaceHandleDefault::GenerateBaseLayer()
+int FontFaceHandleDefault::GetKerning(CodePoint lhs, CodePoint rhs) const
 {
-	RMLUI_ASSERTMSG(layer_configurations.empty(), "GenerateBaseLayer should only be called before any layers are generated.");
-	base_layer = GetOrCreateLayer(nullptr);
-	layer_configurations.push_back(LayerConfiguration{ base_layer });
+	int result = FreeType::GetKerning(ft_face, lhs, rhs);
+	return result;
 }
 
 const FontGlyph* FontFaceHandleDefault::GetOrAppendGlyph(CodePoint& code_point, bool look_in_fallback_fonts)

+ 15 - 26
Source/Core/FontFaceHandleDefault.h → Source/Core/FontEngineDefault/FontFaceHandleDefault.h

@@ -29,11 +29,12 @@
 #ifndef RMLUICOREFONTFACEHANDLE_H
 #define RMLUICOREFONTFACEHANDLE_H
 
-#include "../../Include/RmlUi/Core/Traits.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 "../../../Include/RmlUi/Core/Traits.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 "FontTypes.h"
 
 namespace Rml {
 namespace Core {
@@ -42,25 +43,18 @@ namespace Core {
 
 class FontFaceLayer;
 
-struct FontMetrics {
-	int size;
-	int x_height;
-	int line_height;
-	int baseline;
-
-	float underline_position;
-	float underline_thickness;
-};
 
 /**
 	@author Peter Curry
  */
 
-class FontFaceHandleDefault : public NonCopyMoveable
+class FontFaceHandleDefault final : public NonCopyMoveable
 {
 public:
 	FontFaceHandleDefault();
-	virtual ~FontFaceHandleDefault();
+	~FontFaceHandleDefault();
+
+	bool Initialize(FontFaceHandleFreetype face, int font_size);
 
 	/// Returns the point size of this font face.
 	int GetSize() const;
@@ -107,19 +101,12 @@ public:
 	/// Version is changed whenever the layers are dirtied, requiring regeneration of string geometry.
 	int GetVersion() const;
 
-protected:
-
-	FontGlyphMap& GetGlyphs();
-	FontMetrics& GetMetrics();
-
-	void GenerateBaseLayer();
 
+private:
 	// Build and append glyph to 'glyphs'
-	virtual bool AppendGlyph(CodePoint code_point) = 0;
-
-	virtual int GetKerning(CodePoint lhs, CodePoint rhs) const = 0;
+	bool AppendGlyph(CodePoint code_point);
 
-private:
+	int GetKerning(CodePoint lhs, CodePoint rhs) const;
 
 	/// Retrieve a glyph from the given code point, building and appending a new glyph if not already built.
 	/// @param[in-out] code_point  The code point, can be changed e.g. to the replacement character if no glyph is found.
@@ -156,6 +143,8 @@ private:
 	LayerConfigurationList layer_configurations;
 
 	FontMetrics metrics;
+
+	FontFaceHandleFreetype ft_face;
 };
 
 #endif

+ 0 - 1
Source/Core/FontFaceLayer.cpp → Source/Core/FontEngineDefault/FontFaceLayer.cpp

@@ -28,7 +28,6 @@
 
 #include "precompiled.h"
 #include "FontFaceLayer.h"
-#include "../../Include/RmlUi/Core/Core.h"
 #include "FontFaceHandleDefault.h"
 #include "FontDatabaseDefault.h"
 

+ 5 - 5
Source/Core/FontFaceLayer.h → Source/Core/FontEngineDefault/FontFaceLayer.h

@@ -29,11 +29,11 @@
 #ifndef RMLUICOREFONTFACELAYER_H
 #define RMLUICOREFONTFACELAYER_H
 
-#include "../../Include/RmlUi/Core/FontGlyph.h"
-#include "../../Include/RmlUi/Core/Geometry.h"
-#include "../../Include/RmlUi/Core/GeometryUtilities.h"
-#include "../../Include/RmlUi/Core/Texture.h"
-#include "TextureLayout.h"
+#include "../../../Include/RmlUi/Core/FontGlyph.h"
+#include "../../../Include/RmlUi/Core/Geometry.h"
+#include "../../../Include/RmlUi/Core/GeometryUtilities.h"
+#include "../../../Include/RmlUi/Core/Texture.h"
+#include "../TextureLayout.h"
 
 namespace Rml {
 namespace Core {

+ 12 - 0
Source/Core/FontFamily.cpp → Source/Core/FontEngineDefault/FontFamily.cpp

@@ -65,5 +65,17 @@ SharedPtr<FontFaceHandleDefault> FontFamily::GetFaceHandle(Style::FontStyle styl
 	return matching_face->GetHandle(size);
 }
 
+
+// Adds a new face to the family.
+FontFace* FontFamily::AddFace(FontFaceHandleFreetype ft_face, Style::FontStyle style, Style::FontWeight weight, bool release_stream)
+{
+	auto face = std::make_unique<FontFace>(ft_face, style, weight, release_stream);
+	FontFace* result = face.get();
+
+	font_faces.push_back(std::move(face));
+
+	return result;
+}
+
 }
 }

+ 10 - 9
Source/Core/FontFamily.h → Source/Core/FontEngineDefault/FontFamily.h

@@ -29,7 +29,7 @@
 #ifndef RMLUICOREFONTFAMILY_H
 #define RMLUICOREFONTFAMILY_H
 
-#include <RmlUi/Core/StringUtilities.h>
+#include "FontTypes.h"
 
 namespace Rml {
 namespace Core {
@@ -47,14 +47,6 @@ public:
 	FontFamily(const String& name);
 	virtual ~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.
-	virtual FontFace* AddFace(void* ft_face, Style::FontStyle style, Style::FontWeight weight, bool release_stream) = 0;
-
 	/// Returns a handle to the most appropriate font in the family, at the correct size.
 	/// @param[in] style The style of the desired handle.
 	/// @param[in] weight The weight of the desired handle.
@@ -62,6 +54,15 @@ public:
 	/// @return A valid handle if a matching (or closely matching) font face was found, nullptr otherwise.
 	SharedPtr<FontFaceHandleDefault> GetFaceHandle(Style::FontStyle style, Style::FontWeight weight, int size);
 
+
+	/// 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.
+	FontFace* AddFace(FontFaceHandleFreetype ft_face, Style::FontStyle style, Style::FontWeight weight, bool release_stream);
+
 protected:
 	String name;
 

+ 196 - 0
Source/Core/FontEngineDefault/FontProvider.cpp

@@ -0,0 +1,196 @@
+/*
+ * 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 "FontProvider.h"
+#include "FontFamily.h"
+#include "FreeTypeInterface.h"
+
+namespace Rml {
+namespace Core {
+
+#ifndef RMLUI_NO_FONT_INTERFACE_DEFAULT
+
+static FontProvider* g_font_provider = nullptr;
+
+FontProvider::FontProvider()
+{
+	RMLUI_ASSERT(!g_font_provider);
+}
+
+FontProvider::~FontProvider()
+{
+	RMLUI_ASSERT(g_font_provider == this);
+}
+
+bool FontProvider::Initialise()
+{
+	RMLUI_ASSERT(!g_font_provider);
+	if (!FreeType::Initialise())
+		return false;
+	g_font_provider = new FontProvider;
+	return true;
+}
+
+void FontProvider::Shutdown()
+{
+	RMLUI_ASSERT(g_font_provider);
+	delete g_font_provider;
+	g_font_provider = nullptr;
+	FreeType::Shutdown();
+}
+
+FontProvider& FontProvider::Get()
+{
+	RMLUI_ASSERT(g_font_provider);
+	return *g_font_provider;
+}
+
+// Returns a handle to a font face that can be used to position and render text.
+SharedPtr<FontFaceHandleDefault> FontProvider::GetFontFaceHandle(const String& family, Style::FontStyle style, Style::FontWeight weight, int size)
+{
+	RMLUI_ASSERTMSG(family == StringUtilities::ToLower(family), "Font family name must be converted to lowercase before entering here.");
+
+	auto it = font_families.find(family);
+	if (it == font_families.end())
+		return nullptr;
+
+	return it->second->GetFaceHandle(style, weight, size);
+}
+
+const FontFaceList& FontProvider::GetFallbackFontFaces() const
+{
+	return fallback_font_faces;
+}
+
+
+
+
+// Loads a new font face.
+bool FontProvider::LoadFontFace(const String& file_name, bool fallback_face)
+{
+	FileInterface* file_interface = GetFileInterface();
+	FileHandle handle = file_interface->Open(file_name);
+
+	if (!handle)
+	{
+		Log::Message(Log::LT_ERROR, "Failed to load font face from %s, could not open file.", file_name.c_str());
+		return nullptr;
+	}
+
+	size_t length = file_interface->Length(handle);
+
+	byte* buffer = new byte[length];
+	file_interface->Read(buffer, length, handle);
+	file_interface->Close(handle);
+
+	bool result = LoadFontFace(buffer, (int)length, fallback_face, true, file_name);
+
+	return result;
+}
+
+
+bool FontProvider::LoadFontFace(const byte* data, int data_size, const String& font_family, Style::FontStyle style, Style::FontWeight weight, bool fallback_face)
+{
+	const String source = "memory";
+	
+	bool result = LoadFontFace(data, data_size, fallback_face, false, source, font_family, style, weight);
+	
+	return result;
+}
+
+bool FontProvider::LoadFontFace(const byte* data, int data_size, bool fallback_face, bool local_data, const String& source,
+	String font_family, Style::FontStyle style, Style::FontWeight weight)
+{
+	FontFaceHandleFreetype ft_face = FreeType::LoadFace(data, data_size, source);
+	
+	if (!ft_face)
+	{
+		if (local_data)
+			delete[] data;
+
+		Log::Message(Log::LT_ERROR, "Failed to load font face %s (from %s).", font_family.c_str(), source.c_str());
+		return false;
+	}
+
+	if (font_family.empty())
+	{
+		FreeType::GetFontFaceStyle(ft_face, font_family, style, weight);
+	}
+
+	if (!AddFace(ft_face, font_family, style, weight, fallback_face, local_data))
+	{
+		Log::Message(Log::LT_ERROR, "Failed to load font face %s (from %s).", font_family.c_str(), source.c_str());
+		return false;
+	}
+
+	Log::Message(Log::LT_INFO, "Loaded font face %s (from %s).", font_family.c_str(), source.c_str());
+	return true;
+}
+
+
+
+
+// Adds a loaded face to the appropriate font family.
+bool FontProvider::AddFace(FontFaceHandleFreetype face, const String& family, Style::FontStyle style, Style::FontWeight weight, bool fallback_face, bool release_stream)
+{
+	String family_lower = StringUtilities::ToLower(family);
+	FontFamily* font_family = nullptr;
+	auto it = font_families.find(family_lower);
+	if (it != font_families.end())
+	{
+		font_family = (FontFamily*)it->second.get();
+	}
+	else
+	{
+		auto font_family_ptr = std::make_unique<FontFamily>(family_lower);
+		font_family = font_family_ptr.get();
+		font_families[family_lower] = std::move(font_family_ptr);
+	}
+
+	FontFace* font_face_result = font_family->AddFace(face, style, weight, release_stream);
+
+	if (font_face_result && fallback_face)
+	{
+		auto it_fallback_face = std::find(fallback_font_faces.begin(), fallback_font_faces.end(), font_face_result);
+		if (it_fallback_face == fallback_font_faces.end())
+		{
+			fallback_font_faces.push_back(font_face_result);
+		}
+	}
+
+	return static_cast<bool>(font_face_result);
+}
+
+
+
+
+#endif
+
+}
+}

+ 25 - 5
Source/Core/FontProvider.h → Source/Core/FontEngineDefault/FontProvider.h

@@ -29,9 +29,9 @@
 #ifndef RMLUICOREFONTPROVIDER_H
 #define RMLUICOREFONTPROVIDER_H
 
-#include <RmlUi/Core/Header.h>
-#include <RmlUi/Core/StringUtilities.h>
-#include <RmlUi/Core/ComputedValues.h>
+#include "../../../Include/RmlUi/Core/Types.h"
+#include "../../../Include/RmlUi/Core/ComputedValues.h"
+#include "FontTypes.h"
 
 namespace Rml {
 namespace Core {
@@ -47,9 +47,14 @@ using FontFaceList = std::vector<FontFace*>;
 	@author Peter Curry
  */
 
-class RMLUICORE_API FontProvider
+class FontProvider
 {
 public:
+	static bool Initialise();
+	static void Shutdown();
+
+	static FontProvider& Get();
+
 	/// 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
 	/// valid handle.
@@ -62,13 +67,28 @@ public:
 
 	const FontFaceList& GetFallbackFontFaces() const;
 
-protected:
+	/// Adds a new font face to the database. The face's family, style and weight will be determined from the face itself.
+	bool LoadFontFace(const String& file_name, bool fallback_face);
+
+	/// Adds a new font face from memory.
+	bool LoadFontFace(const byte* data, int data_size, const String& font_family, Style::FontStyle style, Style::FontWeight weight, bool fallback_face);
+
+
+private:
+	FontProvider();
+	~FontProvider();
+
+	bool LoadFontFace(const byte* data, int data_size, bool fallback_face, bool local_data, const String& source,
+		String font_family = {}, Style::FontStyle style = Style::FontStyle::Normal, Style::FontWeight weight = Style::FontWeight::Normal);
+
+	bool AddFace(FontFaceHandleFreetype face, const String& family, Style::FontStyle style, Style::FontWeight weight, bool fallback_face, bool release_stream);
 
 	using FontFamilyMap = UnorderedMap< String, UniquePtr<FontFamily>>;
 	FontFamilyMap font_families;
 	FontFaceList fallback_font_faces;
 
 	static const String debugger_font_family_name;
+	
 };
 
 }

+ 16 - 25
Source/Core/FontFace.cpp → Source/Core/FontEngineDefault/FontTypes.h

@@ -15,7 +15,7 @@
  *
  * 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
@@ -26,38 +26,29 @@
  *
  */
 
-#include "precompiled.h"
-#include "FontFace.h"
-#include "FontFaceHandleDefault.h"
-#include "../../Include/RmlUi/Core/Log.h"
+#ifndef RMLUICOREFONTTYPES_H
+#define RMLUICOREFONTTYPES_H
+
+#include "../../../Include/RmlUi/Core/Types.h"
 
 namespace Rml {
 namespace Core {
 
-FontFace::FontFace(Style::FontStyle _style, Style::FontWeight _weight, bool _release_stream)
-{
-	style = _style;
-	weight = _weight;
 
-	release_stream = _release_stream;
-}
+using FontFaceHandleFreetype = uintptr_t;
 
-FontFace::~FontFace()
+struct FontMetrics 
 {
-	handles.clear();
-}
+	int size;
+	int x_height;
+	int line_height;
+	int baseline;
 
-// Returns the style of the font face.
-Style::FontStyle FontFace::GetStyle() const
-{
-	return style;
-}
-
-// Returns the weight of the font face.
-Style::FontWeight FontFace::GetWeight() const
-{
-	return weight;
-}
+	float underline_position;
+	float underline_thickness;
+};
 
 }
 }
+
+#endif

+ 111 - 45
Source/Core/FreeType/FontFaceHandle.cpp → Source/Core/FontEngineDefault/FreeTypeInterface.cpp

@@ -30,67 +30,130 @@
 
 #ifndef RMLUI_NO_FONT_INTERFACE_DEFAULT
 
-#include "FontFaceHandle.h"
-#include <algorithm>
-#include "../../../Include/RmlUi/Core.h"
-#include "../FontFaceLayer.h"
-#include "../TextureLayout.h"
+#include "FreeTypeInterface.h"
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
 
 namespace Rml {
 namespace Core {
 
+static FT_Library ft_library = nullptr;
+
+
 static bool BuildGlyph(FT_Face ft_face, CodePoint code_point, FontGlyphMap& glyphs);
 static void BuildGlyphMap(FT_Face ft_face, FontGlyphMap& glyphs, int size);
 static void GenerateMetrics(FT_Face ft_face, const FontGlyphMap& glyphs, FontMetrics& metrics);
 
 
-FontFaceHandle_FreeType::FontFaceHandle_FreeType()
+bool FreeType::Initialise()
+{
+	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 FreeType::Shutdown()
+{
+	if (ft_library != nullptr)
+	{
+		FT_Done_FreeType(ft_library);
+		ft_library = nullptr;
+	}
+}
+
+// Loads a FreeType face from memory.
+FontFaceHandleFreetype FreeType::LoadFace(const byte* data, int data_length, const String& source)
+{
+	FT_Face face = nullptr;
+	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.c_str());
+		return 0;
+	}
+
+	// Initialise the character mapping on the face.
+	if (face->charmap == nullptr)
+	{
+		FT_Select_Charmap(face, FT_ENCODING_APPLE_ROMAN);
+		if (face->charmap == nullptr)
+		{
+			Log::Message(Log::LT_ERROR, "Font face (from %s) does not contain a Unicode or Apple Roman character map.", source.c_str());
+			FT_Done_Face(face);
+			return 0;
+		}
+	}
+
+	return (FontFaceHandleFreetype)face;
+}
+
+bool FreeType::ReleaseFace(FontFaceHandleFreetype in_face, bool release_stream)
 {
-	ft_face = nullptr;
+	FT_Face face = (FT_Face)in_face;
+
+	FT_Byte* face_memory = face->stream->base;
+	FT_Error error = FT_Done_Face(face);
+
+	if (release_stream)
+		delete[] face_memory;
+
+	return (error == 0);
 }
 
-FontFaceHandle_FreeType::~FontFaceHandle_FreeType()
+void FreeType::GetFontFaceStyle(FontFaceHandleFreetype in_face, String& font_family, Style::FontStyle& style, Style::FontWeight& weight)
 {
+	FT_Face face = (FT_Face)in_face;
+
+	font_family = face->family_name;
+	style = face->style_flags & FT_STYLE_FLAG_ITALIC ? Style::FontStyle::Italic : Style::FontStyle::Normal;
+	weight = face->style_flags & FT_STYLE_FLAG_BOLD ? Style::FontWeight::Bold : Style::FontWeight::Normal;
 }
 
 
+
 // Initialises the handle so it is able to render text.
-bool FontFaceHandle_FreeType::Initialise(FT_Face ft_face, int size)
+bool FreeType::InitialiseFaceHandle(FontFaceHandleFreetype face, FontGlyphMap& glyphs, FontMetrics& metrics, int font_size)
 {
-	this->ft_face = ft_face;
-	GetMetrics().size = size;
+	FT_Face ft_face = (FT_Face)face;
+
+	metrics.size = font_size;
 
 	// Set the character size on the font face.
-	FT_Error error = FT_Set_Char_Size(ft_face, 0, size << 6, 0, 0);
+	FT_Error error = FT_Set_Char_Size(ft_face, 0, font_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);
+		Log::Message(Log::LT_ERROR, "Unable to set the character size '%d' on the font face '%s %s'.", font_size, ft_face->family_name, ft_face->style_name);
 		return false;
 	}
 
 	// Construct the initial list of glyphs.
-	BuildGlyphMap(ft_face, GetGlyphs(), size);
+	BuildGlyphMap(ft_face, glyphs, font_size);
 
 	// Generate the metrics for the handle.
-	GenerateMetrics(ft_face, GetGlyphs(), GetMetrics());
-
-	// Generate the default layer and layer configuration.
-	GenerateBaseLayer();
+	GenerateMetrics(ft_face, glyphs, metrics);
 
 	return true;
 }
 
-bool FontFaceHandle_FreeType::AppendGlyph(CodePoint code_point)
+bool FreeType::AppendGlyph(FontFaceHandleFreetype face, CodePoint code_point, int font_size, FontGlyphMap& glyphs)
 {
-	FontGlyphMap& glyphs = GetGlyphs();
+	FT_Face ft_face = (FT_Face)face;
+
 	RMLUI_ASSERT(glyphs.find(code_point) == glyphs.end());
 	RMLUI_ASSERT(ft_face);
 
 	// Set face size again in case it was used at another size in another font face handle.
-	FT_Error error = FT_Set_Char_Size(ft_face, 0, GetMetrics().size << 6, 0, 0);
+	FT_Error error = FT_Set_Char_Size(ft_face, 0, font_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'.", GetMetrics().size, ft_face->family_name, ft_face->style_name);
+		Log::Message(Log::LT_ERROR, "Unable to set the character size '%d' on the font face '%s %s'.", font_size, ft_face->family_name, ft_face->style_name);
 		return false;
 	}
 
@@ -101,6 +164,32 @@ bool FontFaceHandle_FreeType::AppendGlyph(CodePoint code_point)
 }
 
 
+int FreeType::GetKerning(FontFaceHandleFreetype face, CodePoint lhs, CodePoint rhs)
+{
+	FT_Face ft_face = (FT_Face)face;
+
+	if (!FT_HAS_KERNING(ft_face))
+		return 0;
+
+	FT_Vector ft_kerning;
+
+	FT_Error ft_error = FT_Get_Kerning(
+		ft_face,
+		FT_Get_Char_Index(ft_face, (FT_ULong)lhs),
+		FT_Get_Char_Index(ft_face, (FT_ULong)rhs),
+		FT_KERNING_DEFAULT,
+		&ft_kerning
+	);
+
+	if (ft_error != 0)
+		return 0;
+
+	int kerning = ft_kerning.x >> 6;
+	return kerning;
+}
+
+
+
 static void BuildGlyphMap(FT_Face ft_face, FontGlyphMap& glyphs, int size)
 {
 	glyphs.reserve(128);
@@ -279,29 +368,6 @@ static void GenerateMetrics(FT_Face ft_face, const FontGlyphMap& glyphs, FontMet
 }
 
 
-int FontFaceHandle_FreeType::GetKerning(CodePoint lhs, CodePoint rhs) const
-{
-	if (!FT_HAS_KERNING(ft_face))
-		return 0;
-
-	FT_Vector ft_kerning;
-
-	FT_Error ft_error = FT_Get_Kerning(
-		ft_face,
-		FT_Get_Char_Index(ft_face, (FT_ULong)lhs),
-		FT_Get_Char_Index(ft_face, (FT_ULong)rhs),
-		FT_KERNING_DEFAULT,
-		&ft_kerning
-	);
-
-	if (ft_error != 0)
-		return 0;
-
-	int kerning = ft_kerning.x >> 6;
-	return kerning;
-}
-
-
 }
 }
 

+ 18 - 21
Source/Core/FreeType/FontFamily.h → Source/Core/FontEngineDefault/FreeTypeInterface.h

@@ -26,37 +26,34 @@
  *
  */
 
-#ifndef RMLUICOREFREETYPEFONTFAMILY_H
-#define RMLUICOREFREETYPEFONTFAMILY_H
+#ifndef RMLUICOREFREETYPEINTERFACE_H
+#define RMLUICOREFREETYPEINTERFACE_H
 
 #ifndef RMLUI_NO_FONT_INTERFACE_DEFAULT
 
-#include "../FontFamily.h"
-#include <ft2build.h>
-#include FT_FREETYPE_H
+#include "FontTypes.h"
 
 namespace Rml {
 namespace Core {
+namespace FreeType {
 
-/**
-	@author Peter Curry
- */
+bool Initialise();
+void Shutdown();
+
+// Loads a FreeType face from memory.
+FontFaceHandleFreetype LoadFace(const byte* data, int data_length, const String& source);
+bool ReleaseFace(FontFaceHandleFreetype face, bool release_stream);
+
+// Retrieves the font family, style and weight of the given font face.
+void GetFontFaceStyle(FontFaceHandleFreetype face, String& font_family, Style::FontStyle& style, Style::FontWeight& weight);
 
-class FontFamily_FreeType : public Rml::Core::FontFamily
-{
-public:
-	FontFamily_FreeType(const String& name);
-	~FontFamily_FreeType();
+bool InitialiseFaceHandle(FontFaceHandleFreetype face, FontGlyphMap& glyphs, FontMetrics& metrics, int font_size);
 
-	/// 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.
-	FontFace* AddFace(void* ft_face, Style::FontStyle style, Style::FontWeight weight, bool release_stream) override;
-};
+bool AppendGlyph(FontFaceHandleFreetype face, CodePoint code_point, int font_size, FontGlyphMap& glyphs);
 
+int GetKerning(FontFaceHandleFreetype face, CodePoint lhs, CodePoint rhs);
+
+}
 }
 }
 

+ 2 - 2
Source/Core/FreeType/precompiled.h → Source/Core/FontEngineDefault/precompiled.h

@@ -26,8 +26,8 @@
  *
  */
 
-#ifndef RMLUICOREFREETYPEFONTPRECOMPILED_H
-#define RMLUICOREFREETYPEFONTPRECOMPILED_H
+#ifndef RMLUICOREFONTENGINEDEFAULTPRECOMPILED_H
+#define RMLUICOREFONTENGINEDEFAULTPRECOMPILED_H
 
 #ifndef RMLUI_NO_FONT_INTERFACE_DEFAULT
 

+ 0 - 58
Source/Core/FontProvider.cpp

@@ -1,58 +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 "FontProvider.h"
-#include "FontFamily.h"
-
-namespace Rml {
-namespace Core {
-
-#ifndef RMLUI_NO_FONT_INTERFACE_DEFAULT
-
-// Returns a handle to a font face that can be used to position and render text.
-SharedPtr<FontFaceHandleDefault> FontProvider::GetFontFaceHandle(const String& family, Style::FontStyle style, Style::FontWeight weight, int size)
-{
-	RMLUI_ASSERTMSG(family == StringUtilities::ToLower(family), "Font family name must be converted to lowercase before entering here.");
-
-	auto it = font_families.find(family);
-	if (it == font_families.end())
-		return nullptr;
-
-	return it->second->GetFaceHandle(style, weight, size);
-}
-
-const FontFaceList& FontProvider::GetFallbackFontFaces() const
-{
-	return fallback_font_faces;
-}
-
-#endif
-
-}
-}

+ 0 - 71
Source/Core/FreeType/FontFace.h

@@ -1,71 +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 RMLUICOREFREETYPEFONTFACE_H
-#define RMLUICOREFREETYPEFONTFACE_H
-
-#ifndef RMLUI_NO_FONT_INTERFACE_DEFAULT
-
-#include "../FontFace.h"
-#include <ft2build.h>
-#include FT_FREETYPE_H
-
-namespace Rml {
-namespace Core {
-
-/**
-	@author Peter Curry
- */
-
-class FontFaceHandleDefault;
-
-class FontFace_FreeType : public Rml::Core::FontFace
-{
-public:
-	FontFace_FreeType(FT_Face face, Style::FontStyle style, Style::FontWeight weight, bool release_stream);
-	~FontFace_FreeType();
-
-	/// Returns a handle for positioning and rendering this face at the given size.
-	/// @param[in] size The size of the desired handle, in points.
-	/// @return The shared font handle.
-	SharedPtr<Rml::Core::FontFaceHandleDefault> GetHandle(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:
-	FT_Face face;
-};
-
-}
-}
-
-#endif
-
-#endif

+ 0 - 75
Source/Core/FreeType/FontFaceHandle.h

@@ -1,75 +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 RMLUICOREFREETYPEFONTFACEHANDLE_H
-#define RMLUICOREFREETYPEFONTFACEHANDLE_H
-
-#ifndef RMLUI_NO_FONT_INTERFACE_DEFAULT
-
-#include "../FontFaceHandleDefault.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 <ft2build.h>
-#include FT_FREETYPE_H
-
-namespace Rml {
-namespace Core {
-
-/**
-	@author Peter Curry
- */
-
-class FontFaceHandle_FreeType : public Rml::Core::FontFaceHandleDefault
-{
-public:
-	FontFaceHandle_FreeType();
-	virtual ~FontFaceHandle_FreeType();
-
-	/// Initialises the handle so it is able to render text.
-	/// @param[in] ft_face The FreeType face that this handle is rendering.
-	/// @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, int size);
-
-private:
-	bool AppendGlyph(CodePoint code_point) override;
-
-
-	int GetKerning(CodePoint lhs, CodePoint rhs) const override;
-
-	FT_Face ft_face;
-};
-
-}
-}
-
-#endif
-
-#endif

+ 0 - 63
Source/Core/FreeType/FontFamily.cpp

@@ -1,63 +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"
-
-#ifndef RMLUI_NO_FONT_INTERFACE_DEFAULT
-
-#include "FontFamily.h"
-#include "FontFace.h"
-
-namespace Rml {
-namespace Core {
-
-FontFamily_FreeType::FontFamily_FreeType(const String& name) : Rml::Core::FontFamily(name)
-{
-
-}
-
-FontFamily_FreeType::~FontFamily_FreeType()
-{
-
-}
-
-// Adds a new face to the family.
-FontFace* FontFamily_FreeType::AddFace(void* ft_face, Style::FontStyle style, Style::FontWeight weight, bool release_stream)
-{
-	auto face = std::make_unique<FontFace_FreeType>((FT_Face)ft_face, style, weight, release_stream);
-	FontFace* result = face.get();
-
-	font_faces.push_back(std::move(face));
-
-	return result;
-}
-
-}
-}
-
-#endif

+ 0 - 228
Source/Core/FreeType/FontProvider.cpp

@@ -1,228 +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"
-
-#ifndef RMLUI_NO_FONT_INTERFACE_DEFAULT
-
-#include "FontProvider.h"
-#include "FontFaceHandle.h"
-#include "../FontDatabaseDefault.h"
-#include "FontFamily.h"
-#include <RmlUi/Core.h>
-#include <ft2build.h>
-#include FT_FREETYPE_H
-
-namespace Rml {
-namespace Core {
-
-FontProvider_FreeType* FontProvider_FreeType::instance = nullptr;
-
-static FT_Library ft_library = nullptr;
-
-FontProvider_FreeType::FontProvider_FreeType()
-{
-	RMLUI_ASSERT(instance == nullptr);
-	instance = this;
-}
-
-FontProvider_FreeType::~FontProvider_FreeType()
-{
-	RMLUI_ASSERT(instance == this);
-	instance = nullptr;
-}
-
-bool FontProvider_FreeType::Initialise()
-{
-	if (instance == nullptr)
-	{
-		new FontProvider_FreeType();
-
-		FontDatabaseDefault::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_FreeType::Shutdown()
-{
-	if (instance != nullptr)
-	{
-		instance->font_families.clear();
-
-		if (ft_library != nullptr)
-		{
-			FT_Done_FreeType(ft_library);
-			ft_library = nullptr;
-		}
-
-		FontDatabaseDefault::RemoveFontProvider(instance);
-		delete instance;
-		instance = nullptr;
-	}
-}
-
-// Loads a new font face.
-bool FontProvider_FreeType::LoadFontFace(const String& file_name, bool fallback_face)
-{
-	FT_Face ft_face = (FT_Face) instance->LoadFace(file_name);
-	if (ft_face == nullptr)
-	{
-		Log::Message(Log::LT_ERROR, "Failed to load font face from %s.", file_name.c_str());
-		return false;
-	}
-
-	Style::FontStyle style = ft_face->style_flags & FT_STYLE_FLAG_ITALIC ? Style::FontStyle::Italic : Style::FontStyle::Normal;
-	Style::FontWeight weight = ft_face->style_flags & FT_STYLE_FLAG_BOLD ? Style::FontWeight::Bold : Style::FontWeight::Normal;
-
-	if (!instance->AddFace(ft_face, ft_face->family_name, style, weight, fallback_face, true))
-	{
-		Log::Message(Log::LT_ERROR, "Failed to load font face %s %s (from %s).", ft_face->family_name, ft_face->style_name, file_name.c_str());
-		return false;
-	}
-
-	Log::Message(Log::LT_INFO, "Loaded font face %s %s (from %s).", ft_face->family_name, ft_face->style_name, file_name.c_str());
-	return true;
-}
-
-bool FontProvider_FreeType::LoadFontFace(const byte* data, int data_size, const String& font_family, Style::FontStyle style, Style::FontWeight weight, bool fallback_face)
-{
-	const String source = "memory";
-
-	FT_Face ft_face = (FT_Face)instance->LoadFace(data, data_size, source, false);
-	if (ft_face == nullptr)
-	{
-		Log::Message(Log::LT_ERROR, "Failed to load font face %s from memory.", font_family.c_str());
-		return false;
-	}
-
-	if (!instance->AddFace(ft_face, font_family, style, weight, fallback_face, false))
-	{
-		Log::Message(Log::LT_ERROR, "Failed to load font face %s %s (from memory).", ft_face->family_name, ft_face->style_name);
-		return false;
-	}
-
-	Log::Message(Log::LT_INFO, "Loaded font face %s %s (from memory).", ft_face->family_name, ft_face->style_name);
-	return true;
-}
-
-// Adds a loaded face to the appropriate font family.
-bool FontProvider_FreeType::AddFace(void* face, const String& family, Style::FontStyle style, Style::FontWeight weight, bool fallback_face, bool release_stream)
-{
-	String family_lower = StringUtilities::ToLower(family);
-	FontFamily_FreeType* font_family = nullptr;
-	auto it = font_families.find(family_lower);
-	if (it != font_families.end())
-	{
-		font_family = (FontFamily_FreeType*)it->second.get();
-	}
-	else
-	{
-		auto font_family_ptr = std::make_unique< FontFamily_FreeType>(family_lower);
-		font_family = font_family_ptr.get();
-		font_families[family_lower] = std::move(font_family_ptr);
-	}
-
-	FontFace* font_face_result = font_family->AddFace((FT_Face)face, style, weight, release_stream);
-
-	if (font_face_result && fallback_face)
-	{
-		auto it_fallback_face = std::find(fallback_font_faces.begin(), fallback_font_faces.end(), font_face_result);
-		if (it_fallback_face == fallback_font_faces.end())
-		{
-			fallback_font_faces.push_back(font_face_result);
-		}
-	}
-
-	return static_cast<bool>(font_face_result);
-}
-
-// Loads a FreeType face.
-void* FontProvider_FreeType::LoadFace(const String& file_name)
-{
-	FileInterface* file_interface = GetFileInterface();
-	FileHandle handle = file_interface->Open(file_name);
-
-	if (!handle)
-	{
-		return nullptr;
-	}
-
-	size_t length = file_interface->Length(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);
-}
-
-// Loads a FreeType face from memory.
-void* FontProvider_FreeType::LoadFace(const byte* data, int data_length, const String& source, bool local_data)
-{
-	FT_Face face = nullptr;
-	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.c_str());
-		if (local_data)
-			delete[] data;
-
-		return nullptr;
-	}
-
-	// Initialise the character mapping on the face.
-	if (face->charmap == nullptr)
-	{
-		FT_Select_Charmap(face, FT_ENCODING_APPLE_ROMAN);
-		if (face->charmap == nullptr)
-		{
-			Log::Message(Log::LT_ERROR, "Font face (from %s) does not contain a Unicode or Apple Roman character map.", source.c_str());
-			FT_Done_Face(face);
-			if (local_data)
-				delete[] data;
-
-			return nullptr;
-		}
-	}
-
-	return face;
-}
-
-}
-}
-
-#endif

+ 0 - 78
Source/Core/FreeType/FontProvider.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 RMLUICOREFREETYPEFONTPROVIDER_H
-#define RMLUICOREFREETYPEFONTPROVIDER_H
-
-#ifndef RMLUI_NO_FONT_INTERFACE_DEFAULT
-
-#include <RmlUi/Core/StringUtilities.h>
-#include "../FontProvider.h"
-
-namespace Rml {
-namespace Core {
-
-/**
-    The font database contains all font families currently in use by RmlUi.
-    @author Peter Curry
- */
-
-class RMLUICORE_API FontProvider_FreeType : 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, bool fallback_face);
-
-	/// Adds a new font face from memory.
-	static bool LoadFontFace(const byte* data, int data_size, const String& font_family, Style::FontStyle style, Style::FontWeight weight, bool fallback_face);
-
-private:
-	FontProvider_FreeType(void);
-	~FontProvider_FreeType(void);
-
-	// Adds a loaded face to the appropriate font family.
-	bool AddFace(void* face, const String& family, Style::FontStyle style, Style::FontWeight weight, bool fallback_face, 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_FreeType* instance;
-};
-
-}
-}
-
-#endif
-
-#endif

+ 0 - 1
Source/Core/LayoutInlineBox.cpp

@@ -28,7 +28,6 @@
 
 #include "precompiled.h"
 #include "LayoutInlineBox.h"
-#include "FontFaceHandleDefault.h"
 #include "LayoutBlockBox.h"
 #include "LayoutEngine.h"
 #include "../../Include/RmlUi/Core/ElementText.h"

+ 0 - 1
Source/Core/LayoutInlineBoxText.cpp

@@ -28,7 +28,6 @@
 
 #include "precompiled.h"
 #include "LayoutInlineBoxText.h"
-#include "FontFaceHandleDefault.h"
 #include "LayoutEngine.h"
 #include "LayoutLineBox.h"
 #include "../../Include/RmlUi/Core/ElementText.h"

+ 0 - 1
Source/Core/LayoutLineBox.cpp

@@ -31,7 +31,6 @@
 #include "LayoutBlockBox.h"
 #include "LayoutEngine.h"
 #include "LayoutInlineBoxText.h"
-#include "FontFaceHandleDefault.h"
 #include "../../Include/RmlUi/Core/Property.h"
 #include "../../Include/RmlUi/Core/ElementUtilities.h"
 #include "../../Include/RmlUi/Core/ElementText.h"

+ 1 - 1
Source/Core/TextureResource.cpp

@@ -28,8 +28,8 @@
 
 #include "precompiled.h"
 #include "TextureResource.h"
-#include "FontFaceHandleDefault.h"
 #include "TextureDatabase.h"
+#include "FontEngineDefault/FontFaceHandleDefault.h"
 #include "../../Include/RmlUi/Core.h"
 
 namespace Rml {