Merge remote-tracking branch 'kahrl/cguittfont'

Conflicts:
	src/CMakeLists.txt
	src/cguittfont/CGUITTFont.cpp
	src/cguittfont/CMakeLists.txt
	src/cguittfont/irrUString.h
	src/cguittfont/xCGUITTFont.h
master
ValkaTR 2011-11-13 02:05:52 +02:00
commit 05ca57a277
6 changed files with 556 additions and 29 deletions

View File

@ -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

View File

@ -28,9 +28,6 @@
john@suckerfreegames.com
*/
#include <stddef.h>
#include "irrUString.h"
#include <irrlicht.h>
#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;

View File

@ -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
)

View File

@ -38,8 +38,6 @@
# endif
#endif
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -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<TAlloc>& 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<TAlloc>& 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<TAlloc>& 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<TAlloc>& 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<TAlloc>& 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<TAlloc>& 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<TAlloc>& 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<TAlloc>& 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<TAlloc>::iterator::access a = *i;
typename ustring16<TAlloc>::access a = *i;
if ((uchar32_t)a == toReplace)
a = replaceWith;
++i;
@ -3241,6 +3335,208 @@ inline ustring16<TAlloc> operator+(const std::basic_string<B, A, BAlloc>& left,
}
//! Appends a ustring16 and a char.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const char right)
{
ustring16<TAlloc> ret(left);
ret += right;
return ret;
}
//! Appends a ustring16 and a char.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const char left, const ustring16<TAlloc>& right)
{
ustring16<TAlloc> ret(left);
ret += right;
return ret;
}
#ifdef USTRING_CPP0X_NEWLITERALS
//! Appends a ustring16 and a uchar32_t.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const uchar32_t right)
{
ustring16<TAlloc> ret(left);
ret += right;
return ret;
}
//! Appends a ustring16 and a uchar32_t.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const uchar32_t left, const ustring16<TAlloc>& right)
{
ustring16<TAlloc> ret(left);
ret += right;
return ret;
}
#endif
//! Appends a ustring16 and a short.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const short right)
{
ustring16<TAlloc> ret(left);
ret += core::stringc(right);
return ret;
}
//! Appends a ustring16 and a short.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const short left, const ustring16<TAlloc>& right)
{
ustring16<TAlloc> ret(core::stringc(left));
ret += right;
return ret;
}
//! Appends a ustring16 and an unsigned short.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const unsigned short right)
{
ustring16<TAlloc> ret(left);
ret += core::stringc(right);
return ret;
}
//! Appends a ustring16 and an unsigned short.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const unsigned short left, const ustring16<TAlloc>& right)
{
ustring16<TAlloc> ret(core::stringc(left));
ret += right;
return ret;
}
//! Appends a ustring16 and an int.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const int right)
{
ustring16<TAlloc> ret(left);
ret += core::stringc(right);
return ret;
}
//! Appends a ustring16 and an int.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const int left, const ustring16<TAlloc>& right)
{
ustring16<TAlloc> ret(core::stringc(left));
ret += right;
return ret;
}
//! Appends a ustring16 and an unsigned int.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const unsigned int right)
{
ustring16<TAlloc> ret(left);
ret += core::stringc(right);
return ret;
}
//! Appends a ustring16 and an unsigned int.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const unsigned int left, const ustring16<TAlloc>& right)
{
ustring16<TAlloc> ret(core::stringc(left));
ret += right;
return ret;
}
//! Appends a ustring16 and a long.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const long right)
{
ustring16<TAlloc> ret(left);
ret += core::stringc(right);
return ret;
}
//! Appends a ustring16 and a long.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const long left, const ustring16<TAlloc>& right)
{
ustring16<TAlloc> ret(core::stringc(left));
ret += right;
return ret;
}
//! Appends a ustring16 and an unsigned long.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const unsigned long right)
{
ustring16<TAlloc> ret(left);
ret += core::stringc(right);
return ret;
}
//! Appends a ustring16 and an unsigned long.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const unsigned long left, const ustring16<TAlloc>& right)
{
ustring16<TAlloc> ret(core::stringc(left));
ret += right;
return ret;
}
//! Appends a ustring16 and a float.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const float right)
{
ustring16<TAlloc> ret(left);
ret += core::stringc(right);
return ret;
}
//! Appends a ustring16 and a float.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const float left, const ustring16<TAlloc>& right)
{
ustring16<TAlloc> ret(core::stringc(left));
ret += right;
return ret;
}
//! Appends a ustring16 and a double.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const double right)
{
ustring16<TAlloc> ret(left);
ret += core::stringc(right);
return ret;
}
//! Appends a ustring16 and a double.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const double left, const ustring16<TAlloc>& right)
{
ustring16<TAlloc> ret(core::stringc(left));
ret += right;
return ret;
}
#ifdef USTRING_CPP0X
//! Appends two ustring16s.
template <typename TAlloc>
@ -3339,6 +3635,188 @@ inline ustring16<TAlloc>&& operator+(ustring16<TAlloc>&& left, const std::basic_
left.append(right);
return std::move(left);
}
//! Appends a ustring16 and a char.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(ustring16<TAlloc>&& left, const char right)
{
left.append((uchar32_t)right);
return std::move(left);
}
//! Appends a ustring16 and a char.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const char left, ustring16<TAlloc>&& right)
{
right.insert((uchar32_t)left, 0);
return std::move(right);
}
#ifdef USTRING_CPP0X_NEWLITERALS
//! Appends a ustring16 and a uchar32_t.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(ustring16<TAlloc>&& left, const uchar32_t right)
{
left.append(right);
return std::move(left);
}
//! Appends a ustring16 and a uchar32_t.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const uchar32_t left, ustring16<TAlloc>&& right)
{
right.insert(left, 0);
return std::move(right);
}
#endif
//! Appends a ustring16 and a short.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(ustring16<TAlloc>&& left, const short right)
{
left.append(core::stringc(right));
return std::move(left);
}
//! Appends a ustring16 and a short.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const short left, ustring16<TAlloc>&& right)
{
right.insert(core::stringc(left), 0);
return std::move(right);
}
//! Appends a ustring16 and an unsigned short.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(ustring16<TAlloc>&& left, const unsigned short right)
{
left.append(core::stringc(right));
return std::move(left);
}
//! Appends a ustring16 and an unsigned short.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const unsigned short left, ustring16<TAlloc>&& right)
{
right.insert(core::stringc(left), 0);
return std::move(right);
}
//! Appends a ustring16 and an int.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(ustring16<TAlloc>&& left, const int right)
{
left.append(core::stringc(right));
return std::move(left);
}
//! Appends a ustring16 and an int.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const int left, ustring16<TAlloc>&& right)
{
right.insert(core::stringc(left), 0);
return std::move(right);
}
//! Appends a ustring16 and an unsigned int.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(ustring16<TAlloc>&& left, const unsigned int right)
{
left.append(core::stringc(right));
return std::move(left);
}
//! Appends a ustring16 and an unsigned int.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const unsigned int left, ustring16<TAlloc>&& right)
{
right.insert(core::stringc(left), 0);
return std::move(right);
}
//! Appends a ustring16 and a long.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(ustring16<TAlloc>&& left, const long right)
{
left.append(core::stringc(right));
return std::move(left);
}
//! Appends a ustring16 and a long.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const long left, ustring16<TAlloc>&& right)
{
right.insert(core::stringc(left), 0);
return std::move(right);
}
//! Appends a ustring16 and an unsigned long.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(ustring16<TAlloc>&& left, const unsigned long right)
{
left.append(core::stringc(right));
return std::move(left);
}
//! Appends a ustring16 and an unsigned long.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const unsigned long left, ustring16<TAlloc>&& right)
{
right.insert(core::stringc(left), 0);
return std::move(right);
}
//! Appends a ustring16 and a float.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(ustring16<TAlloc>&& left, const float right)
{
left.append(core::stringc(right));
return std::move(left);
}
//! Appends a ustring16 and a float.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const float left, ustring16<TAlloc>&& right)
{
right.insert(core::stringc(left), 0);
return std::move(right);
}
//! Appends a ustring16 and a double.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(ustring16<TAlloc>&& left, const double right)
{
left.append(core::stringc(right));
return std::move(left);
}
//! Appends a ustring16 and a double.
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const double left, ustring16<TAlloc>&& right)
{
right.insert(core::stringc(left), 0);
return std::move(right);
}
#endif

View File

@ -0,0 +1,5 @@
// A wrapper source file to avoid hack with gcc and modifying
// the CGUITTFont files.
#include "xCGUITTFont.h"
#include "CGUITTFont.cpp"

View File

@ -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 <algorithm>
#include <stddef.h>
#include "irrUString.h"
#include "CGUITTFont.h"