mirror of https://github.com/axmolengine/axmol.git
issue #1056: Modified the configuration of ios project.
This commit is contained in:
parent
321771a7ea
commit
02ae04c1d6
|
@ -1 +1 @@
|
|||
70c443ceaf43c95b4a380aa01b43a1875462d911
|
||||
1921c7a89735ac8fdac8731d985871be741b4996
|
|
@ -31,7 +31,7 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only)
|
|||
|
||||
****************************************************************************/
|
||||
#include "CCLabelBMFont.h"
|
||||
|
||||
#include "CCDirector.h"
|
||||
#include "platform/platform.h"
|
||||
#include "CCDictionary.h"
|
||||
#include "CCConfiguration.h"
|
||||
|
@ -445,180 +445,180 @@ int CCLabelBMFont::kerningAmountForFirst(unsigned short first, unsigned short se
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int cc_wcslen(const unsigned short* str)
|
||||
{
|
||||
int i=0;
|
||||
while(*str++) i++;
|
||||
return i;
|
||||
static int cc_wcslen(const unsigned short* str)
|
||||
{
|
||||
int i=0;
|
||||
while(*str++) i++;
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Code from GLIB gutf8.c starts here. */
|
||||
|
||||
#define UTF8_COMPUTE(Char, Mask, Len) \
|
||||
if (Char < 128) \
|
||||
{ \
|
||||
Len = 1; \
|
||||
Mask = 0x7f; \
|
||||
} \
|
||||
else if ((Char & 0xe0) == 0xc0) \
|
||||
{ \
|
||||
Len = 2; \
|
||||
Mask = 0x1f; \
|
||||
} \
|
||||
else if ((Char & 0xf0) == 0xe0) \
|
||||
{ \
|
||||
Len = 3; \
|
||||
Mask = 0x0f; \
|
||||
} \
|
||||
else if ((Char & 0xf8) == 0xf0) \
|
||||
{ \
|
||||
Len = 4; \
|
||||
Mask = 0x07; \
|
||||
} \
|
||||
else if ((Char & 0xfc) == 0xf8) \
|
||||
{ \
|
||||
Len = 5; \
|
||||
Mask = 0x03; \
|
||||
} \
|
||||
else if ((Char & 0xfe) == 0xfc) \
|
||||
{ \
|
||||
Len = 6; \
|
||||
Mask = 0x01; \
|
||||
} \
|
||||
else \
|
||||
Len = -1;
|
||||
|
||||
#define UTF8_LENGTH(Char) \
|
||||
((Char) < 0x80 ? 1 : \
|
||||
((Char) < 0x800 ? 2 : \
|
||||
((Char) < 0x10000 ? 3 : \
|
||||
((Char) < 0x200000 ? 4 : \
|
||||
((Char) < 0x4000000 ? 5 : 6)))))
|
||||
|
||||
|
||||
#define UTF8_GET(Result, Chars, Count, Mask, Len) \
|
||||
(Result) = (Chars)[0] & (Mask); \
|
||||
for ((Count) = 1; (Count) < (Len); ++(Count)) \
|
||||
{ \
|
||||
if (((Chars)[(Count)] & 0xc0) != 0x80) \
|
||||
{ \
|
||||
(Result) = -1; \
|
||||
break; \
|
||||
} \
|
||||
(Result) <<= 6; \
|
||||
(Result) |= ((Chars)[(Count)] & 0x3f); \
|
||||
}
|
||||
|
||||
#define UNICODE_VALID(Char) \
|
||||
((Char) < 0x110000 && \
|
||||
(((Char) & 0xFFFFF800) != 0xD800) && \
|
||||
((Char) < 0xFDD0 || (Char) > 0xFDEF) && \
|
||||
((Char) & 0xFFFE) != 0xFFFE)
|
||||
|
||||
|
||||
static const char utf8_skip_data[256] = {
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5,
|
||||
5, 5, 5, 6, 6, 1, 1
|
||||
};
|
||||
|
||||
static const char *const g_utf8_skip = utf8_skip_data;
|
||||
|
||||
#define cc_utf8_next_char(p) (char *)((p) + g_utf8_skip[*(unsigned char *)(p)])
|
||||
|
||||
/*
|
||||
* g_utf8_strlen:
|
||||
* @p: pointer to the start of a UTF-8 encoded string.
|
||||
* @max: the maximum number of bytes to examine. If @max
|
||||
* is less than 0, then the string is assumed to be
|
||||
* nul-terminated. If @max is 0, @p will not be examined and
|
||||
* may be %NULL.
|
||||
*
|
||||
* Returns the length of the string in characters.
|
||||
*
|
||||
* Return value: the length of the string in characters
|
||||
**/
|
||||
static long
|
||||
cc_utf8_strlen (const char * p, int max)
|
||||
{
|
||||
long len = 0;
|
||||
const char *start = p;
|
||||
|
||||
if (!(p != NULL || max == 0))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (max < 0)
|
||||
{
|
||||
while (*p)
|
||||
{
|
||||
p = cc_utf8_next_char (p);
|
||||
++len;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (max == 0 || !*p)
|
||||
return 0;
|
||||
|
||||
p = cc_utf8_next_char (p);
|
||||
|
||||
while (p - start < max && *p)
|
||||
{
|
||||
++len;
|
||||
p = cc_utf8_next_char (p);
|
||||
}
|
||||
|
||||
/* only do the last len increment if we got a complete
|
||||
* char (don't count partial chars)
|
||||
*/
|
||||
if (p - start == max)
|
||||
++len;
|
||||
}
|
||||
|
||||
return len;
|
||||
/* Code from GLIB gutf8.c starts here. */
|
||||
|
||||
#define UTF8_COMPUTE(Char, Mask, Len) \
|
||||
if (Char < 128) \
|
||||
{ \
|
||||
Len = 1; \
|
||||
Mask = 0x7f; \
|
||||
} \
|
||||
else if ((Char & 0xe0) == 0xc0) \
|
||||
{ \
|
||||
Len = 2; \
|
||||
Mask = 0x1f; \
|
||||
} \
|
||||
else if ((Char & 0xf0) == 0xe0) \
|
||||
{ \
|
||||
Len = 3; \
|
||||
Mask = 0x0f; \
|
||||
} \
|
||||
else if ((Char & 0xf8) == 0xf0) \
|
||||
{ \
|
||||
Len = 4; \
|
||||
Mask = 0x07; \
|
||||
} \
|
||||
else if ((Char & 0xfc) == 0xf8) \
|
||||
{ \
|
||||
Len = 5; \
|
||||
Mask = 0x03; \
|
||||
} \
|
||||
else if ((Char & 0xfe) == 0xfc) \
|
||||
{ \
|
||||
Len = 6; \
|
||||
Mask = 0x01; \
|
||||
} \
|
||||
else \
|
||||
Len = -1;
|
||||
|
||||
#define UTF8_LENGTH(Char) \
|
||||
((Char) < 0x80 ? 1 : \
|
||||
((Char) < 0x800 ? 2 : \
|
||||
((Char) < 0x10000 ? 3 : \
|
||||
((Char) < 0x200000 ? 4 : \
|
||||
((Char) < 0x4000000 ? 5 : 6)))))
|
||||
|
||||
|
||||
#define UTF8_GET(Result, Chars, Count, Mask, Len) \
|
||||
(Result) = (Chars)[0] & (Mask); \
|
||||
for ((Count) = 1; (Count) < (Len); ++(Count)) \
|
||||
{ \
|
||||
if (((Chars)[(Count)] & 0xc0) != 0x80) \
|
||||
{ \
|
||||
(Result) = -1; \
|
||||
break; \
|
||||
} \
|
||||
(Result) <<= 6; \
|
||||
(Result) |= ((Chars)[(Count)] & 0x3f); \
|
||||
}
|
||||
|
||||
#define UNICODE_VALID(Char) \
|
||||
((Char) < 0x110000 && \
|
||||
(((Char) & 0xFFFFF800) != 0xD800) && \
|
||||
((Char) < 0xFDD0 || (Char) > 0xFDEF) && \
|
||||
((Char) & 0xFFFE) != 0xFFFE)
|
||||
|
||||
|
||||
static const char utf8_skip_data[256] = {
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5,
|
||||
5, 5, 5, 6, 6, 1, 1
|
||||
};
|
||||
|
||||
static const char *const g_utf8_skip = utf8_skip_data;
|
||||
|
||||
#define cc_utf8_next_char(p) (char *)((p) + g_utf8_skip[*(unsigned char *)(p)])
|
||||
|
||||
/*
|
||||
* g_utf8_strlen:
|
||||
* @p: pointer to the start of a UTF-8 encoded string.
|
||||
* @max: the maximum number of bytes to examine. If @max
|
||||
* is less than 0, then the string is assumed to be
|
||||
* nul-terminated. If @max is 0, @p will not be examined and
|
||||
* may be %NULL.
|
||||
*
|
||||
* Returns the length of the string in characters.
|
||||
*
|
||||
* Return value: the length of the string in characters
|
||||
**/
|
||||
static long
|
||||
cc_utf8_strlen (const char * p, int max)
|
||||
{
|
||||
long len = 0;
|
||||
const char *start = p;
|
||||
|
||||
if (!(p != NULL || max == 0))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (max < 0)
|
||||
{
|
||||
while (*p)
|
||||
{
|
||||
p = cc_utf8_next_char (p);
|
||||
++len;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (max == 0 || !*p)
|
||||
return 0;
|
||||
|
||||
p = cc_utf8_next_char (p);
|
||||
|
||||
while (p - start < max && *p)
|
||||
{
|
||||
++len;
|
||||
p = cc_utf8_next_char (p);
|
||||
}
|
||||
|
||||
/* only do the last len increment if we got a complete
|
||||
* char (don't count partial chars)
|
||||
*/
|
||||
if (p - start == max)
|
||||
++len;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/*
|
||||
* g_utf8_get_char:
|
||||
* @p: a pointer to Unicode character encoded as UTF-8
|
||||
*
|
||||
* Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
|
||||
* If @p does not point to a valid UTF-8 encoded character, results are
|
||||
* undefined. If you are not sure that the bytes are complete
|
||||
* valid Unicode characters, you should use g_utf8_get_char_validated()
|
||||
* instead.
|
||||
*
|
||||
* Return value: the resulting character
|
||||
**/
|
||||
static unsigned int
|
||||
cc_utf8_get_char (const char * p)
|
||||
{
|
||||
int i, mask = 0, len;
|
||||
unsigned int result;
|
||||
unsigned char c = (unsigned char) *p;
|
||||
|
||||
UTF8_COMPUTE (c, mask, len);
|
||||
if (len == -1)
|
||||
return (unsigned int) - 1;
|
||||
UTF8_GET (result, p, i, mask, len);
|
||||
|
||||
return result;
|
||||
}
|
||||
/*
|
||||
* g_utf8_get_char:
|
||||
* @p: a pointer to Unicode character encoded as UTF-8
|
||||
*
|
||||
* Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
|
||||
* If @p does not point to a valid UTF-8 encoded character, results are
|
||||
* undefined. If you are not sure that the bytes are complete
|
||||
* valid Unicode characters, you should use g_utf8_get_char_validated()
|
||||
* instead.
|
||||
*
|
||||
* Return value: the resulting character
|
||||
**/
|
||||
static unsigned int
|
||||
cc_utf8_get_char (const char * p)
|
||||
{
|
||||
int i, mask = 0, len;
|
||||
unsigned int result;
|
||||
unsigned char c = (unsigned char) *p;
|
||||
|
||||
UTF8_COMPUTE (c, mask, len);
|
||||
if (len == -1)
|
||||
return (unsigned int) - 1;
|
||||
UTF8_GET (result, p, i, mask, len);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void CCLabelBMFont::createFontChars()
|
||||
|
@ -651,10 +651,10 @@ void CCLabelBMFont::createFontChars()
|
|||
|
||||
const char* p = m_sString.c_str();
|
||||
|
||||
for (int i = 0; i < utf8len; ++i)
|
||||
{
|
||||
pUniStr[i] = cc_utf8_get_char(p);
|
||||
p = cc_utf8_next_char (p);
|
||||
for (int i = 0; i < utf8len; ++i)
|
||||
{
|
||||
pUniStr[i] = cc_utf8_get_char(p);
|
||||
p = cc_utf8_next_char (p);
|
||||
}
|
||||
|
||||
unsigned int stringLen = cc_wcslen(pUniStr);
|
||||
|
@ -712,7 +712,7 @@ void CCLabelBMFont::createFontChars()
|
|||
}
|
||||
|
||||
float yOffset = (float)(m_pConfiguration->m_uCommonHeight) - fontDef.yOffset;
|
||||
CCPoint fontPos = ccp( (float)nextFontPositionX + fontDef.xOffset + fontDef.rect.size.width*0.5f + kerningAmount, (float)nextFontPositionY + yOffset - rect.size.height*0.5f );
|
||||
CCPoint fontPos = ccp( (float)nextFontPositionX + fontDef.xOffset + fontDef.rect.size.width*0.5f + kerningAmount, (float)nextFontPositionY + yOffset - rect.size.height*0.5f );
|
||||
fontChar->setPosition(CC_POINT_PIXELS_TO_POINTS(fontPos));
|
||||
|
||||
// NSLog(@"position.y: %f", fontChar.position.y);
|
||||
|
|
Loading…
Reference in New Issue