#pragma region CPL License /* Nuclex Engine Copyright (C) 2002-2008 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion #ifndef NUCLEX_PLUGINS_FREETYPE_FREETYPEPLUGIN_H #define NUCLEX_PLUGINS_FREETYPE_FREETYPEPLUGIN_H #include "Nuclex/Nuclex.h" #include "Nuclex/Support/Synchronization.h" #include "FT2Build.h" #include FT_FREETYPE_H // The following block will decide whether symbols are imported from a // dll (client app) or exported to a dll (nuclex library). // The FREETYPEPLUGIN_EXPORTS symbol should only be used for compiling // the Nuclex.Plugins.FreeType library and nowhere else. // #ifdef FREETYPEPLUGIN_EXPORTS #define FREETYPEPLUGIN_API __declspec(dllexport) #else #define FREETYPEPLUGIN_API __declspec(dllimport) #endif namespace Nuclex { namespace Text { // ------------------------------------------------------------------------------------------- // /// Get the FreeType library handle /// The FreeType library handle FREETYPEPLUGIN_API FT_Library getFreeTypeLibrary(); // ------------------------------------------------------------------------------------------- // /// Get the mutex used for all threaded operations on FreeType /// The mutex to use for all threaded operations on FreeType FREETYPEPLUGIN_API Mutex &getFreeTypeMutex(); // ------------------------------------------------------------------------------------------- // /// Obtain a textual description of a FreeType error code /// The error code whose textual description to look up /// Returns a human-readable description of an error given its error code FREETYPEPLUGIN_API inline string getFreeTypeErrorDescription(int nErrorCode) { // A little hack to enforce the header to be processed a second time #undef __FTERRORS_H__ // This is FreeType's way to help define our own structure for storing the // FreeType error codes #define FT_ERRORDEF(e, v, s) { e, s }, #define FT_ERROR_START_LIST { #define FT_ERROR_END_LIST { 0, 0 } }; // By including the header below, we actually provide this structure // definition with a list of all the error codes known to FreeType static const struct { int nErrorCode; const char *pszErrorMessage; } FreeTypeErrors[] = #include FT_ERRORS_H // We're done, undef the symbols to not pollute the global namespace #undef FT_ERRORDEF #undef FT_ERROR_START_LIST #undef FT_ERROR_END_LIST // This is the actual error lookup, performed as a simple incremental search ;) for( size_t ErrorIndex = 0; ErrorIndex < sizeof(FreeTypeErrors) / sizeof(*FreeTypeErrors); ++ErrorIndex ) { // If this is the error code we're looking for, return it! if(FreeTypeErrors[ErrorIndex].nErrorCode == nErrorCode) return FreeTypeErrors[ErrorIndex].pszErrorMessage; } // Error code not found, report it as being an unknown error return string("unknown error ") + lexical_cast(nErrorCode); } // ------------------------------------------------------------------------------------------- // }} // namespace Nuclex::Text #endif // NUCLEX_PLUGINS_FREETYPE_FREETYPEPLUGIN_H