diff --git a/README.txt b/README.txt index 0603924..d5e293d 100644 --- a/README.txt +++ b/README.txt @@ -54,7 +54,7 @@ Compiling on GNU/Linux: ----------------------- Install dependencies. Here's an example for Debian/Ubuntu: -$ apt-get install build-essential libirrlicht-dev cmake libbz2-dev libpng12-dev libjpeg8-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev +$ apt-get install build-essential libirrlicht-dev cmake libbz2-dev libpng12-dev libjpeg8-dev libfreetype6-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev Download source, extract (this is the URL to the latest of source repository, which might not work at all times): $ wget https://github.com/celeron55/minetest/tarball/master -O master.tar.gz @@ -90,6 +90,7 @@ Compiling on Windows: http://www.winimage.com/zLibDll/index.html * Zlib library (zlibwapi.lib and zlibwapi.dll from zlib125dll.zip): http://www.winimage.com/zLibDll/index.html + * Freetype library (TODO: test and explain this) * Optional: gettext bibrary and tools: http://gnuwin32.sourceforge.net/downlinks/gettext.php - This is used for other UI languages. Feel free to leave it out. @@ -276,3 +277,53 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +FreeType 2 +--------------- + +This program uses the FreeType library. + +Copyright (c) 2011 The FreeType Project (www.freetype.org). +FreeType is licensed under the GNU General Public License, version 2 or later. + +(Actually, FreeType is dual-licensed, the other license being the BSD-like +FreeType License with advertisement clause.) + + +ustring and CGUITTFont +------------------------------ + +This program uses the ustring and CGUITTFont classes. +http://irrlicht.sourceforge.net/forum/viewtopic.php?f=6&t=37296 + +Basic Unicode string class for Irrlicht. +Copyright (c) 2009-2011 John Norman + +CGUITTFont FreeType class for Irrlicht +Copyright (c) 2009-2010 John Norman + +License for ustring and CGUITTFont: + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you use + this software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source + distribution. + +The original version of this class can be located at: +http://irrlicht.suckerfreegames.com/ + +John Norman +john@suckerfreegames.com diff --git a/src/cguittfont/CGUITTFont.cpp b/src/cguittfont/CGUITTFont.cpp index c883d4d..3f494f9 100644 --- a/src/cguittfont/CGUITTFont.cpp +++ b/src/cguittfont/CGUITTFont.cpp @@ -28,9 +28,6 @@ john@suckerfreegames.com */ -#include -#include "irrUString.h" - #include #include "CGUITTFont.h" @@ -460,7 +457,7 @@ CGUITTGlyphPage* CGUITTFont::getLastGlyphPage() const CGUITTGlyphPage* CGUITTFont::createGlyphPage(const u8& pixel_mode) { CGUITTGlyphPage* page = 0; - + // Name of our page. io::path name("TTFontGlyphPage_"); name += tt_face->family_name; diff --git a/src/cguittfont/CMakeLists.txt b/src/cguittfont/CMakeLists.txt index 1c92231..94d0614 100644 --- a/src/cguittfont/CMakeLists.txt +++ b/src/cguittfont/CMakeLists.txt @@ -1,22 +1,17 @@ -# Alas, CGUITTFont.{cpp,h} don't include irrUString.h even though they use -# core::ustring. -# We don't want to (and shouldn't have to) modify our copies of -# CGUITTFont.{cpp,h} because that would complicate updating them later. - -#if(CMAKE_COMPILER_IS_GNUCXX) -# add_definitions(-include "${CMAKE_CURRENT_SOURCE_DIR}/irrUString.h") -# add_definitions(-include "stddef.h") -#endif(CMAKE_COMPILER_IS_GNUCXX) - include_directories( - ${IRRLICHT_INCLUDE_DIR} - ${FREETYPE_INCLUDE_DIRS} + ${IRRLICHT_INCLUDE_DIR} + ${FREETYPE_INCLUDE_DIRS} ) -add_library(cguittfont CGUITTFont.cpp) +# CGUITTFont authors, y u no include headers you use? +# Do not add CGUITTFont.cpp to the line below. +# xCGUITTFont.cpp is a wrapper file that includes +# additional required headers. +add_library(cguittfont xCGUITTFont.cpp) target_link_libraries( - cguittfont - ${IRRLICHT_LIBRARY} - ${FREETYPE_LIBRARIES} + cguittfont + ${IRRLICHT_LIBRARY} + ${FREETYPE_LIBRARY} + ${ZLIB_LIBRARIES} # needed by freetype, repeated here for safety ) diff --git a/src/cguittfont/irrUString.h b/src/cguittfont/irrUString.h index 518a8c5..6fffa16 100644 --- a/src/cguittfont/irrUString.h +++ b/src/cguittfont/irrUString.h @@ -38,8 +38,6 @@ # endif #endif - -#include #include #include #include @@ -259,7 +257,7 @@ public: _set(c); return *this; } - + //! Increments the value by 1. //! \return Myself. _ustring16_iterator_access& operator++() @@ -394,7 +392,7 @@ public: return unicode::toUTF32(a[pos], a[pos + 1]); } } - + //! Sets a uchar32_t at our current position. void _set(uchar32_t c) { @@ -739,7 +737,7 @@ public: typedef typename _Base::distance_type distance_type; typedef access pointer; typedef access reference; - + using _Base::pos; using _Base::ref; @@ -920,6 +918,20 @@ public: } + //! Constructor for copying a UTF-8 string from a single char. + ustring16(const char c) + : array(0), allocated(0), used(0) + { +#if __BIG_ENDIAN__ + encoding = unicode::EUTFE_UTF16_BE; +#else + encoding = unicode::EUTFE_UTF16_LE; +#endif + + append((uchar32_t)c); + } + + //! Constructor for copying a UTF-8 string from a pointer with a given length. ustring16(const uchar8_t* const c, u32 length) : array(0), allocated(0), used(0) @@ -2023,6 +2035,16 @@ public: } + //! Appends a character to this ustring16. + //! \param c Character to append. + //! \return A reference to our current string. + ustring16& operator += (char c) + { + append((uchar32_t)c); + return *this; + } + + //! Appends a character to this ustring16. //! \param c Character to append. //! \return A reference to our current string. @@ -2033,6 +2055,78 @@ public: } + //! Appends a number to this ustring16. + //! \param c Number to append. + //! \return A reference to our current string. + ustring16& operator += (short c) + { + append(core::stringc(c)); + return *this; + } + + + //! Appends a number to this ustring16. + //! \param c Number to append. + //! \return A reference to our current string. + ustring16& operator += (unsigned short c) + { + append(core::stringc(c)); + return *this; + } + + +#ifdef USTRING_CPP0X_NEWLITERALS + //! Appends a number to this ustring16. + //! \param c Number to append. + //! \return A reference to our current string. + ustring16& operator += (int c) + { + append(core::stringc(c)); + return *this; + } + + + //! Appends a number to this ustring16. + //! \param c Number to append. + //! \return A reference to our current string. + ustring16& operator += (unsigned int c) + { + append(core::stringc(c)); + return *this; + } +#endif + + + //! Appends a number to this ustring16. + //! \param c Number to append. + //! \return A reference to our current string. + ustring16& operator += (long c) + { + append(core::stringc(c)); + return *this; + } + + + //! Appends a number to this ustring16. + //! \param c Number to append. + //! \return A reference to our current string. + ustring16& operator += (unsigned long c) + { + append(core::stringc(c)); + return *this; + } + + + //! Appends a number to this ustring16. + //! \param c Number to append. + //! \return A reference to our current string. + ustring16& operator += (double c) + { + append(core::stringc(c)); + return *this; + } + + //! Appends a char ustring16 to this ustring16. //! \param c Char ustring16 to append. //! \return A reference to our current string. @@ -2062,7 +2156,7 @@ public: iterator i(*this, 0); while (!i.atEnd()) { - typename ustring16::iterator::access a = *i; + typename ustring16::access a = *i; if ((uchar32_t)a == toReplace) a = replaceWith; ++i; @@ -3241,6 +3335,208 @@ inline ustring16 operator+(const std::basic_string& left, } +//! Appends a ustring16 and a char. +template +inline ustring16 operator+(const ustring16& left, const char right) +{ + ustring16 ret(left); + ret += right; + return ret; +} + + +//! Appends a ustring16 and a char. +template +inline ustring16 operator+(const char left, const ustring16& right) +{ + ustring16 ret(left); + ret += right; + return ret; +} + + +#ifdef USTRING_CPP0X_NEWLITERALS +//! Appends a ustring16 and a uchar32_t. +template +inline ustring16 operator+(const ustring16& left, const uchar32_t right) +{ + ustring16 ret(left); + ret += right; + return ret; +} + + +//! Appends a ustring16 and a uchar32_t. +template +inline ustring16 operator+(const uchar32_t left, const ustring16& right) +{ + ustring16 ret(left); + ret += right; + return ret; +} +#endif + + +//! Appends a ustring16 and a short. +template +inline ustring16 operator+(const ustring16& left, const short right) +{ + ustring16 ret(left); + ret += core::stringc(right); + return ret; +} + + +//! Appends a ustring16 and a short. +template +inline ustring16 operator+(const short left, const ustring16& right) +{ + ustring16 ret(core::stringc(left)); + ret += right; + return ret; +} + + +//! Appends a ustring16 and an unsigned short. +template +inline ustring16 operator+(const ustring16& left, const unsigned short right) +{ + ustring16 ret(left); + ret += core::stringc(right); + return ret; +} + + +//! Appends a ustring16 and an unsigned short. +template +inline ustring16 operator+(const unsigned short left, const ustring16& right) +{ + ustring16 ret(core::stringc(left)); + ret += right; + return ret; +} + + +//! Appends a ustring16 and an int. +template +inline ustring16 operator+(const ustring16& left, const int right) +{ + ustring16 ret(left); + ret += core::stringc(right); + return ret; +} + + +//! Appends a ustring16 and an int. +template +inline ustring16 operator+(const int left, const ustring16& right) +{ + ustring16 ret(core::stringc(left)); + ret += right; + return ret; +} + + +//! Appends a ustring16 and an unsigned int. +template +inline ustring16 operator+(const ustring16& left, const unsigned int right) +{ + ustring16 ret(left); + ret += core::stringc(right); + return ret; +} + + +//! Appends a ustring16 and an unsigned int. +template +inline ustring16 operator+(const unsigned int left, const ustring16& right) +{ + ustring16 ret(core::stringc(left)); + ret += right; + return ret; +} + + +//! Appends a ustring16 and a long. +template +inline ustring16 operator+(const ustring16& left, const long right) +{ + ustring16 ret(left); + ret += core::stringc(right); + return ret; +} + + +//! Appends a ustring16 and a long. +template +inline ustring16 operator+(const long left, const ustring16& right) +{ + ustring16 ret(core::stringc(left)); + ret += right; + return ret; +} + + +//! Appends a ustring16 and an unsigned long. +template +inline ustring16 operator+(const ustring16& left, const unsigned long right) +{ + ustring16 ret(left); + ret += core::stringc(right); + return ret; +} + + +//! Appends a ustring16 and an unsigned long. +template +inline ustring16 operator+(const unsigned long left, const ustring16& right) +{ + ustring16 ret(core::stringc(left)); + ret += right; + return ret; +} + + +//! Appends a ustring16 and a float. +template +inline ustring16 operator+(const ustring16& left, const float right) +{ + ustring16 ret(left); + ret += core::stringc(right); + return ret; +} + + +//! Appends a ustring16 and a float. +template +inline ustring16 operator+(const float left, const ustring16& right) +{ + ustring16 ret(core::stringc(left)); + ret += right; + return ret; +} + + +//! Appends a ustring16 and a double. +template +inline ustring16 operator+(const ustring16& left, const double right) +{ + ustring16 ret(left); + ret += core::stringc(right); + return ret; +} + + +//! Appends a ustring16 and a double. +template +inline ustring16 operator+(const double left, const ustring16& right) +{ + ustring16 ret(core::stringc(left)); + ret += right; + return ret; +} + + #ifdef USTRING_CPP0X //! Appends two ustring16s. template @@ -3339,6 +3635,188 @@ inline ustring16&& operator+(ustring16&& left, const std::basic_ left.append(right); return std::move(left); } + + +//! Appends a ustring16 and a char. +template +inline ustring16 operator+(ustring16&& left, const char right) +{ + left.append((uchar32_t)right); + return std::move(left); +} + + +//! Appends a ustring16 and a char. +template +inline ustring16 operator+(const char left, ustring16&& right) +{ + right.insert((uchar32_t)left, 0); + return std::move(right); +} + + +#ifdef USTRING_CPP0X_NEWLITERALS +//! Appends a ustring16 and a uchar32_t. +template +inline ustring16 operator+(ustring16&& left, const uchar32_t right) +{ + left.append(right); + return std::move(left); +} + + +//! Appends a ustring16 and a uchar32_t. +template +inline ustring16 operator+(const uchar32_t left, ustring16&& right) +{ + right.insert(left, 0); + return std::move(right); +} +#endif + + +//! Appends a ustring16 and a short. +template +inline ustring16 operator+(ustring16&& left, const short right) +{ + left.append(core::stringc(right)); + return std::move(left); +} + + +//! Appends a ustring16 and a short. +template +inline ustring16 operator+(const short left, ustring16&& right) +{ + right.insert(core::stringc(left), 0); + return std::move(right); +} + + +//! Appends a ustring16 and an unsigned short. +template +inline ustring16 operator+(ustring16&& left, const unsigned short right) +{ + left.append(core::stringc(right)); + return std::move(left); +} + + +//! Appends a ustring16 and an unsigned short. +template +inline ustring16 operator+(const unsigned short left, ustring16&& right) +{ + right.insert(core::stringc(left), 0); + return std::move(right); +} + + +//! Appends a ustring16 and an int. +template +inline ustring16 operator+(ustring16&& left, const int right) +{ + left.append(core::stringc(right)); + return std::move(left); +} + + +//! Appends a ustring16 and an int. +template +inline ustring16 operator+(const int left, ustring16&& right) +{ + right.insert(core::stringc(left), 0); + return std::move(right); +} + + +//! Appends a ustring16 and an unsigned int. +template +inline ustring16 operator+(ustring16&& left, const unsigned int right) +{ + left.append(core::stringc(right)); + return std::move(left); +} + + +//! Appends a ustring16 and an unsigned int. +template +inline ustring16 operator+(const unsigned int left, ustring16&& right) +{ + right.insert(core::stringc(left), 0); + return std::move(right); +} + + +//! Appends a ustring16 and a long. +template +inline ustring16 operator+(ustring16&& left, const long right) +{ + left.append(core::stringc(right)); + return std::move(left); +} + + +//! Appends a ustring16 and a long. +template +inline ustring16 operator+(const long left, ustring16&& right) +{ + right.insert(core::stringc(left), 0); + return std::move(right); +} + + +//! Appends a ustring16 and an unsigned long. +template +inline ustring16 operator+(ustring16&& left, const unsigned long right) +{ + left.append(core::stringc(right)); + return std::move(left); +} + + +//! Appends a ustring16 and an unsigned long. +template +inline ustring16 operator+(const unsigned long left, ustring16&& right) +{ + right.insert(core::stringc(left), 0); + return std::move(right); +} + + +//! Appends a ustring16 and a float. +template +inline ustring16 operator+(ustring16&& left, const float right) +{ + left.append(core::stringc(right)); + return std::move(left); +} + + +//! Appends a ustring16 and a float. +template +inline ustring16 operator+(const float left, ustring16&& right) +{ + right.insert(core::stringc(left), 0); + return std::move(right); +} + + +//! Appends a ustring16 and a double. +template +inline ustring16 operator+(ustring16&& left, const double right) +{ + left.append(core::stringc(right)); + return std::move(left); +} + + +//! Appends a ustring16 and a double. +template +inline ustring16 operator+(const double left, ustring16&& right) +{ + right.insert(core::stringc(left), 0); + return std::move(right); +} #endif diff --git a/src/cguittfont/xCGUITTFont.cpp b/src/cguittfont/xCGUITTFont.cpp new file mode 100644 index 0000000..c51922e --- /dev/null +++ b/src/cguittfont/xCGUITTFont.cpp @@ -0,0 +1,5 @@ +// A wrapper source file to avoid hack with gcc and modifying +// the CGUITTFont files. + +#include "xCGUITTFont.h" +#include "CGUITTFont.cpp" diff --git a/src/cguittfont/xCGUITTFont.h b/src/cguittfont/xCGUITTFont.h index 9b7c953..c3efe7f 100644 --- a/src/cguittfont/xCGUITTFont.h +++ b/src/cguittfont/xCGUITTFont.h @@ -1,6 +1,7 @@ // A wrapper header to avoid hack with gcc and modifying // the CGUITTFont files. -#define USTRING_NO_STL -#include "irrUString.h" // must be included before CGUITTFont.h +#include +#include +#include "irrUString.h" #include "CGUITTFont.h"