Erwan
- minor font fixes by linshier
This commit is contained in:
@@ -55,12 +55,6 @@ private:
|
|||||||
JLBFont * it;
|
JLBFont * it;
|
||||||
};
|
};
|
||||||
|
|
||||||
//Why do we need this ? could it move somewhere else ?
|
|
||||||
#if !defined (WIN32)
|
|
||||||
#define BYTE u8
|
|
||||||
#define DWORD u32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class WFBFont : public WFont
|
class WFBFont : public WFont
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -81,8 +75,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
static JRenderer * mRenderer;
|
static JRenderer * mRenderer;
|
||||||
|
|
||||||
BYTE* mEngFont;
|
u8 * mEngFont;
|
||||||
BYTE* mChnFont;
|
u8 * mChnFont;
|
||||||
|
|
||||||
PIXEL_TYPE mColor0;
|
PIXEL_TYPE mColor0;
|
||||||
PIXEL_TYPE mColor;
|
PIXEL_TYPE mColor;
|
||||||
@@ -101,9 +95,9 @@ private:
|
|||||||
int *mGBCode;
|
int *mGBCode;
|
||||||
int mCurr;
|
int mCurr;
|
||||||
|
|
||||||
DWORD* mCharBuffer;
|
u32 * mCharBuffer;
|
||||||
|
|
||||||
int PreCacheChar(const BYTE *ch);
|
int PreCacheChar(const u8 *ch);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -78,14 +78,14 @@ WFBFont::WFBFont(const char *fontname, int lineheight, bool useVideoRAM)
|
|||||||
if (!fileSys->OpenFile(chnFileName))
|
if (!fileSys->OpenFile(chnFileName))
|
||||||
return;
|
return;
|
||||||
size = fileSys->GetFileSize();
|
size = fileSys->GetFileSize();
|
||||||
mChnFont = NEW BYTE[size];
|
mChnFont = NEW u8[size];
|
||||||
fileSys->ReadFile(mChnFont, size);
|
fileSys->ReadFile(mChnFont, size);
|
||||||
fileSys->CloseFile();
|
fileSys->CloseFile();
|
||||||
|
|
||||||
if (!fileSys->OpenFile(engFileName))
|
if (!fileSys->OpenFile(engFileName))
|
||||||
return;
|
return;
|
||||||
size = fileSys->GetFileSize();
|
size = fileSys->GetFileSize();
|
||||||
mEngFont = NEW BYTE[size];
|
mEngFont = NEW u8[size];
|
||||||
fileSys->ReadFile(mEngFont, size);
|
fileSys->ReadFile(mEngFont, size);
|
||||||
fileSys->CloseFile();
|
fileSys->CloseFile();
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ WFBFont::WFBFont(const char *fontname, int lineheight, bool useVideoRAM)
|
|||||||
mGBCode = NEW int[mCacheSize];
|
mGBCode = NEW int[mCacheSize];
|
||||||
|
|
||||||
#if defined (WIN32) || defined (LINUX)
|
#if defined (WIN32) || defined (LINUX)
|
||||||
mCharBuffer = NEW DWORD[mFontSize*mFontSize];
|
mCharBuffer = NEW u32[mFontSize*mFontSize];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mTexture = mRenderer->CreateTexture(mCacheImageWidth, mCacheImageHeight, true);
|
mTexture = mRenderer->CreateTexture(mCacheImageWidth, mCacheImageHeight, true);
|
||||||
@@ -165,23 +165,23 @@ static void SwizzlePlot(u8* out, PIXEL_TYPE color, int i, int j, unsigned int wi
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int WFBFont::PreCacheChar(const BYTE *ch)
|
int WFBFont::PreCacheChar(const u8 *ch)
|
||||||
{
|
{
|
||||||
int code;
|
int code;
|
||||||
bool isChinese = true;
|
bool isChinese = true;
|
||||||
BYTE* src;
|
u8 * src;
|
||||||
int size, offset;
|
int size, offset;
|
||||||
u8 gray;
|
u8 gray;
|
||||||
|
|
||||||
if (*ch > 0xA0 && *(ch + 1) > 0xA0)
|
if (*ch > 0xA0 && *(ch + 1) > 0xA0)
|
||||||
// get offset to the proper character bits (GB2312 encoding)
|
// get offset to the proper character bits (GB2312 encoding)
|
||||||
code = (((DWORD)(*ch - 0xA1)) * 0x5E + ((DWORD)(*(ch + 1) - 0xA1)));
|
code = (((u32)(*ch - 0xA1)) * 0x5E + ((u32)(*(ch + 1) - 0xA1)));
|
||||||
else if (*ch > 0x80) {
|
else if (*ch > 0x80) {
|
||||||
// get offset to the character space's bits (GBK encoding)
|
// get offset to the character space's bits (GBK encoding)
|
||||||
code = 0;
|
code = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
code = ((DWORD)*ch)|0x10000;
|
code = ((u32)*ch)|0x10000;
|
||||||
isChinese = false;
|
isChinese = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ int WFBFont::PreCacheChar(const BYTE *ch)
|
|||||||
#if defined (WIN32) || defined (LINUX)
|
#if defined (WIN32) || defined (LINUX)
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
memset(mCharBuffer, 0, sizeof(DWORD) * mFontSize * mFontSize);
|
memset(mCharBuffer, 0, sizeof(u32) * mFontSize * mFontSize);
|
||||||
#else
|
#else
|
||||||
u8* pTexture = (u8*) mTexture->mBits;
|
u8* pTexture = (u8*) mTexture->mBits;
|
||||||
int x;
|
int x;
|
||||||
@@ -281,7 +281,7 @@ void WFBFont::DrawString(const char *s, float x, float y, int align, float leftO
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BYTE* str = (BYTE*)s;
|
u8 * str = (u8 *)s;
|
||||||
|
|
||||||
// (0, 0) refers to the center of the word, so fix it to the upper-left corner
|
// (0, 0) refers to the center of the word, so fix it to the upper-left corner
|
||||||
x += (mFontSize * mScale) / 2;
|
x += (mFontSize * mScale) / 2;
|
||||||
@@ -300,7 +300,7 @@ void WFBFont::DrawString(const char *s, float x, float y, int align, float leftO
|
|||||||
|
|
||||||
mRenderer->BindTexture(mTexture);
|
mRenderer->BindTexture(mTexture);
|
||||||
|
|
||||||
BYTE* src = str;
|
u8 * src = str;
|
||||||
float xx = x;
|
float xx = x;
|
||||||
float yy = y;
|
float yy = y;
|
||||||
int index;
|
int index;
|
||||||
@@ -413,7 +413,7 @@ float WFBFont::GetStringWidth(const char *s) const
|
|||||||
unsigned char c = *(unsigned short *)s & 0xFF;
|
unsigned char c = *(unsigned short *)s & 0xFF;
|
||||||
|
|
||||||
if (ISGBK(c)) {
|
if (ISGBK(c)) {
|
||||||
BYTE* src = (BYTE*)s;
|
u8 * src = (u8 *)s;
|
||||||
float xx = 0;
|
float xx = 0;
|
||||||
bool isChinese=true;
|
bool isChinese=true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user