Browse Source

Started work on FreeType font importer

Marko Pintera 12 years ago
parent
commit
e8c8e713c9

+ 17 - 0
CamelotEngine.sln

@@ -21,6 +21,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CamelotClient", "CamelotCli
 		{1437BB4E-DDB3-4307-AA41-8C035DA3014B} = {1437BB4E-DDB3-4307-AA41-8C035DA3014B}
 		{F58FF869-2EA6-4FFF-AB84-328C531BA9D9} = {F58FF869-2EA6-4FFF-AB84-328C531BA9D9}
 		{08975177-4A13-4EE7-BB21-3BB92FB3F3CC} = {08975177-4A13-4EE7-BB21-3BB92FB3F3CC}
+		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73} = {AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}
 		{7F449698-73DF-4203-9F31-0877DBF01695} = {7F449698-73DF-4203-9F31-0877DBF01695}
 		{BFEBBAF8-8A84-4899-8899-D0D7196AF9A1} = {BFEBBAF8-8A84-4899-8899-D0D7196AF9A1}
 		{796B6DFF-BA04-42B7-A43A-2B14D707A33A} = {796B6DFF-BA04-42B7-A43A-2B14D707A33A}
@@ -78,6 +79,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CamelotEditor", "CamelotEdi
 		{CC7F9445-71C9-4559-9976-FF0A64DCB582} = {CC7F9445-71C9-4559-9976-FF0A64DCB582}
 	EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CamelotFontImporter", "CamelotFontImporter\CamelotTTFImporter.vcxproj", "{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}"
+EndProject
 Global
 	GlobalSection(SubversionScc) = preSolution
 		Svn-Managed = True
@@ -248,6 +251,20 @@ Global
 		{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|Win32.Build.0 = Release|Win32
 		{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.ActiveCfg = Release|x64
 		{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.Build.0 = Release|x64
+		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}.Debug|Any CPU.ActiveCfg = Debug|Win32
+		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}.Debug|Mixed Platforms.Build.0 = Debug|Win32
+		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}.Debug|Win32.ActiveCfg = Debug|Win32
+		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}.Debug|Win32.Build.0 = Debug|Win32
+		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}.Debug|x64.ActiveCfg = Debug|x64
+		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}.Debug|x64.Build.0 = Debug|x64
+		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}.Release|Any CPU.ActiveCfg = Release|Win32
+		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}.Release|Mixed Platforms.Build.0 = Release|Win32
+		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}.Release|Win32.ActiveCfg = Release|Win32
+		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}.Release|Win32.Build.0 = Release|Win32
+		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}.Release|x64.ActiveCfg = Release|x64
+		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}.Release|x64.Build.0 = Release|x64
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 160 - 0
CamelotFontImporter/CamelotTTFImporter.vcxproj

@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}</ProjectGuid>
+    <RootNamespace>CamelotTTFImporter</RootNamespace>
+    <ProjectName>CamelotFontImporter</ProjectName>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v110</PlatformToolset>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v110</PlatformToolset>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v110</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v110</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <OutDir>..\bin\$(Configuration)\</OutDir>
+    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\</IntDir>
+    <OutDir>..\bin\$(Configuration)\</OutDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <OutDir>..\bin\$(Configuration)\</OutDir>
+    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\</IntDir>
+    <OutDir>..\bin\$(Configuration)\</OutDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <AdditionalIncludeDirectories>../CamelotCore/Include;../CamelotUtility/Include;./Include;../Dependencies/Include;./Dependencies/Include</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>CM_FONT_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>../lib/$(Configuration);../Dependencies/lib/Debug;./Dependencies/lib/Debug</AdditionalLibraryDirectories>
+      <AdditionalDependencies>CamelotCore.lib;CamelotUtility.lib;freetypeD.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <ImportLibrary>..\lib\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <AdditionalIncludeDirectories>../CamelotCore/Include;../CamelotUtility/Include;./Include;../Dependencies/Include;./Dependencies/Include</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>CM_FONT_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/Debug;./Dependencies/lib/x64/Debug</AdditionalLibraryDirectories>
+      <AdditionalDependencies>CamelotCore.lib;CamelotUtility.lib;freetypeD.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <AdditionalIncludeDirectories>../CamelotCore/Include;../CamelotUtility/Include;./Include;../Dependencies/Include;./Dependencies/Include</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>CM_FONT_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalLibraryDirectories>../lib/$(Configuration);../Dependencies/lib/Release;./Dependencies/lib/Release</AdditionalLibraryDirectories>
+      <AdditionalDependencies>CamelotCore.lib;CamelotUtility.lib;freetype.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <ImportLibrary>..\lib\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <AdditionalIncludeDirectories>../CamelotCore/Include;../CamelotUtility/Include;./Include;../Dependencies/Include;./Dependencies/Include</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>CM_FONT_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/Release;./Dependencies/lib/x64/Release</AdditionalLibraryDirectories>
+      <AdditionalDependencies>CamelotCore.lib;CamelotUtility.lib;freetype.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClInclude Include="Include\CmFontImporter.h" />
+    <ClInclude Include="Include\CmFontPrerequisites.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="Source\CmFontImporter.cpp" />
+    <ClCompile Include="Source\CmFontPlugin.cpp" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>

+ 33 - 0
CamelotFontImporter/CamelotTTFImporter.vcxproj.filters

@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="Resource Files">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="Include\CmFontImporter.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmFontPrerequisites.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="Source\CmFontImporter.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmFontPlugin.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
+</Project>

+ 39 - 0
CamelotFontImporter/Include/CmFontImporter.h

@@ -0,0 +1,39 @@
+#pragma once
+
+#include "CmFontPrerequisites.h"
+#include "CmSpecificImporter.h"
+#include "CmImporter.h"
+
+namespace CamelotEngine
+{
+	class CM_FONT_EXPORT FontImporter : public SpecificImporter
+	{
+	public:
+		FontImporter();
+		virtual ~FontImporter();
+
+		/**
+		 * @brief	Should only be called by the plugin when its being loaded.
+		 */
+		static void startUp()
+		{
+			static FontImporter* importer = nullptr;
+			if(importer == nullptr)
+			{
+				importer = new FontImporter();
+				Importer::instance().registerAssetImporter(importer);
+			}
+		}
+
+		/** Inherited from SpecificImporter */
+		virtual bool isExtensionSupported(const String& ext) const;
+
+		/** Inherited from SpecificImporter */
+		virtual bool isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const; 
+
+		/** Inherited from SpecificImporter */
+		virtual BaseResourceHandle import(const String& filePath, ConstImportOptionsPtr importOptions);
+	private:
+		vector<String>::type mExtensions;
+	};
+}

+ 19 - 0
CamelotFontImporter/Include/CmFontPrerequisites.h

@@ -0,0 +1,19 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+
+#if (CM_PLATFORM == CM_PLATFORM_WIN32) && !defined(__MINGW32__)
+#	ifdef CM_FONT_EXPORTS
+#		define CM_FONT_EXPORT __declspec(dllexport)
+#	else
+#       if defined( __MINGW32__ )
+#           define CM_FONT_EXPORT
+#       else
+#    		define CM_FONT_EXPORT __declspec(dllimport)
+#       endif
+#	endif
+#elif defined ( CM_GCC_VISIBILITY )
+#    define CM_FONT_EXPORT  __attribute__ ((visibility("default")))
+#else
+#    define CM_FONT_EXPORT
+#endif

+ 36 - 0
CamelotFontImporter/Source/CmFontImporter.cpp

@@ -0,0 +1,36 @@
+#include "CmFontImporter.h"
+
+namespace CamelotEngine
+{
+	FontImporter::FontImporter()
+		:SpecificImporter() 
+	{
+		mExtensions.push_back("ttf");
+		mExtensions.push_back("otf");
+	}
+
+	FontImporter::~FontImporter() 
+	{
+
+	}
+
+	bool FontImporter::isExtensionSupported(const String& ext) const
+	{
+		String lowerCaseExt = ext;
+		StringUtil::toLowerCase(lowerCaseExt);
+
+		return find(mExtensions.begin(), mExtensions.end(), lowerCaseExt) != mExtensions.end();
+	}
+
+	bool FontImporter::isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const
+	{
+		// TODO
+		return false;
+	}
+
+	BaseResourceHandle FontImporter::import(const String& filePath, ConstImportOptionsPtr importOptions)
+	{
+		// TODO
+		return BaseResourceHandle();
+	}
+}

+ 16 - 0
CamelotFontImporter/Source/CmFontPlugin.cpp

@@ -0,0 +1,16 @@
+#include "CmFontPrerequisites.h"
+#include "CmFontImporter.h"
+
+namespace CamelotEngine
+{
+	extern "C" CM_FONT_EXPORT const String& getPluginName()
+	{
+		static String pluginName = "FontImporter";
+		return pluginName;
+	}
+
+	extern "C" CM_FONT_EXPORT void loadPlugin()
+	{
+		FontImporter::startUp();
+	}
+}