mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +02:00
- Added Chinese language support (thx to Noword from TBS)
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2424 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -20,66 +20,259 @@
|
||||
#include <ddraw.h>
|
||||
#include "winfont.h"
|
||||
#include "font.h"
|
||||
|
||||
#include "Font Control.h"
|
||||
|
||||
INT32 FindFreeWinFont( void );
|
||||
BOOLEAN gfEnumSucceed = FALSE;
|
||||
|
||||
|
||||
|
||||
#define MAX_WIN_FONTS 10
|
||||
#ifdef CHINESE
|
||||
#define DEC_INTERNAL_LEADING
|
||||
#endif
|
||||
|
||||
// Private struct not to be exported
|
||||
// to other modules
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HFONT hFont;
|
||||
COLORVAL ForeColor;
|
||||
COLORVAL BackColor;
|
||||
|
||||
UINT8 Height;
|
||||
UINT8 Width[0x80];
|
||||
#ifdef DEC_INTERNAL_LEADING
|
||||
UINT8 InternalLeading;
|
||||
#endif
|
||||
} HWINFONT;
|
||||
|
||||
LOGFONT gLogFont;
|
||||
LONG gWinFontAdjust;
|
||||
HWINFONT WinFonts[WIN_LASTFONT];
|
||||
|
||||
HWINFONT WinFonts[ MAX_WIN_FONTS ];
|
||||
INT32 WinFontMap[MAX_WINFONTMAP];
|
||||
|
||||
struct {
|
||||
char FontName[32]; //the key name
|
||||
LOGFONT LogFont; //read it from ja2.ini
|
||||
COLORVAL Color;
|
||||
} FontInfo[] = {
|
||||
{"LargeFont1", {-12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, FROMRGB(98, 98, 98)},
|
||||
{"SmallFont1", {-12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, FROMRGB(98, 98, 98)},
|
||||
{"TinyFont1", {-12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, FROMRGB(98, 98, 98)},
|
||||
{"12PointFont1", {-14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, 0},
|
||||
{"CompFont", {-12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, FROMRGB(0, 255, 0)},
|
||||
{"SmallCompFont", {-12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, FROMRGB(98, 98, 98)},
|
||||
{"10PointRoman", {-12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, FROMRGB(0, 255 , 0)},
|
||||
{"12PointRoman", {-14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, FROMRGB(0, 255 , 0)},
|
||||
{"14PointSansSerif", {-16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, FROMRGB(0, 255 , 0)},
|
||||
{"10PointArial", {-12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, 0},
|
||||
{"14PointArial", {-16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, FROMRGB(0, 255 , 0)},
|
||||
{"12PointArial", {-14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, FROMRGB(222, 222, 222)},
|
||||
{"BlockyFont", {-12, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, FROMRGB(217, 217, 217)},
|
||||
{"BlockyFont2", {-12, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, FROMRGB(217, 217, 217)},
|
||||
{"10PointArialBold", {-12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, 0},
|
||||
{"12PointArialFixedFont", {-14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, 0},
|
||||
{"16PointArial", {-18, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, FROMRGB(222, 222, 222)},
|
||||
{"BlockFontNarrow", {-12, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, FROMRGB(128, 0 , 0)},
|
||||
{"14PointHumanist", {-16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, FROMRGB(255, 0, 0)},
|
||||
{"HugeFont", {-20, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "Tahoma"}, FROMRGB(0, 255, 0)}
|
||||
};
|
||||
|
||||
void Convert16BitStringTo8BitChineseBig5String( CHAR8 *dst, CHAR16 *src )
|
||||
void Convert16BitStringTo8Bit( CHAR8 *dst, CHAR16 *src )
|
||||
{
|
||||
INT32 i, j;
|
||||
STR8 ptr;
|
||||
//hope 'dst' is big enough
|
||||
WideCharToMultiByte(CP_ACP, 0, src, -1, dst, 512 ,NULL,NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
i = j = 0;
|
||||
ptr = (STR8 )src;
|
||||
while( ptr[j] || ptr[j + 1] )
|
||||
void GetWinFontInfo()
|
||||
{
|
||||
/*
|
||||
;default settings, can be changed in ja2.ini
|
||||
|
||||
[LargeFont1]
|
||||
Name=Tahoma
|
||||
Height=-12
|
||||
Weight=400
|
||||
|
||||
[SmallFont1]
|
||||
Name=Tahoma
|
||||
Height=-12
|
||||
Weight=400
|
||||
|
||||
[TinyFont1]
|
||||
Name=Tahoma
|
||||
Height=-12
|
||||
Weight=400
|
||||
|
||||
[12PointFont1]
|
||||
Name=Tahoma
|
||||
Height=-14
|
||||
Weight=400
|
||||
|
||||
[CompFont]
|
||||
Name=Tahoma
|
||||
Height=-12
|
||||
Weight=400
|
||||
|
||||
[SmallCompFont]
|
||||
Name=Tahoma
|
||||
Height=-12
|
||||
Weight=400
|
||||
|
||||
[10PointRoman]
|
||||
Name=Tahoma
|
||||
Height=-12
|
||||
Weight=400
|
||||
|
||||
[12PointRoman]
|
||||
Name=Tahoma
|
||||
Height=-14
|
||||
Weight=400
|
||||
|
||||
[14PointSansSerif]
|
||||
Name=Tahoma
|
||||
Height=-16
|
||||
Weight=400
|
||||
|
||||
[10PointArial]
|
||||
Name=Tahoma
|
||||
Height=-12
|
||||
Weight=400
|
||||
|
||||
[14PointArial]
|
||||
Name=Tahoma
|
||||
Height=-16
|
||||
Weight=700
|
||||
|
||||
[12PointArial]
|
||||
Name=Tahoma
|
||||
Height=-14
|
||||
Weight=400
|
||||
|
||||
[BlockyFont]
|
||||
Name=Tahoma
|
||||
Height=-12
|
||||
Weight=700
|
||||
|
||||
[BlockyFont2]
|
||||
Name=Tahoma
|
||||
Height=-12
|
||||
Weight=700
|
||||
|
||||
[10PointArialBold]
|
||||
Name=Tahoma
|
||||
Height=-12
|
||||
Weight=400
|
||||
|
||||
[12PointArialFixedFont]
|
||||
Name=Tahoma
|
||||
Height=-14
|
||||
Weight=400
|
||||
|
||||
[16PointArial]
|
||||
Name=Tahoma
|
||||
Height=-18
|
||||
Weight=400
|
||||
|
||||
[BlockFontNarrow]
|
||||
Name=Tahoma
|
||||
Height=-12
|
||||
Weight=700
|
||||
|
||||
[14PointHumanist]
|
||||
Name=Tahoma
|
||||
Height=-16
|
||||
Weight=400
|
||||
|
||||
[HugeFont]
|
||||
Name=Tahoma
|
||||
Height=-20
|
||||
Weight=400
|
||||
*/
|
||||
char INIFile[MAX_PATH];
|
||||
GetExecutableDirectory( INIFile );
|
||||
strcat(INIFile, "\\Ja2.ini");
|
||||
|
||||
gWinFontAdjust = GetPrivateProfileInt("Ja2 Settings", "WIN_FONT_ADJUST", 0, INIFile);
|
||||
for (UINT16 i=0; i<WIN_LASTFONT; i++)
|
||||
{
|
||||
if( ptr[j] )
|
||||
{
|
||||
dst[i] = ptr[j];
|
||||
dst[ i + 1 ] = '\0';
|
||||
i++;
|
||||
}
|
||||
j++;
|
||||
GetPrivateProfileString(FontInfo[i].FontName, "Name", FontInfo[i].LogFont.lfFaceName, FontInfo[i].LogFont.lfFaceName, LF_FACESIZE, INIFile);
|
||||
FontInfo[i].LogFont.lfHeight = gWinFontAdjust + GetPrivateProfileInt(FontInfo[i].FontName, "Height", FontInfo[i].LogFont.lfHeight, INIFile);
|
||||
FontInfo[i].LogFont.lfWeight = GetPrivateProfileInt(FontInfo[i].FontName, "Weight", FontInfo[i].LogFont.lfWeight, INIFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void InitWinFonts( )
|
||||
{
|
||||
INT32 FontSlot[WIN_LASTFONT];
|
||||
memset( WinFonts, 0, sizeof( WinFonts ) );
|
||||
|
||||
GetWinFontInfo();
|
||||
|
||||
for (int i = 0; i<WIN_LASTFONT; i++)
|
||||
{
|
||||
FontSlot[i] = CreateWinFont(FontInfo[i].LogFont);
|
||||
SetWinFontForeColor(FontSlot[i], &FontInfo[i].Color);
|
||||
}
|
||||
|
||||
//can't use switch here, because FONT12ARIAL, LARGEFONT1... are variables
|
||||
for (int i=0; i<MAX_WINFONTMAP; i++)
|
||||
{
|
||||
if (i == FONT12ARIAL)
|
||||
{WinFontMap[i] = FontSlot[WIN_12POINTARIAL];}
|
||||
else if (i == LARGEFONT1)
|
||||
{WinFontMap[i] = FontSlot[WIN_LARGEFONT1];}
|
||||
else if (i == SMALLFONT1)
|
||||
{WinFontMap[i] = FontSlot[WIN_SMALLFONT1];}
|
||||
else if (i == TINYFONT1)
|
||||
{WinFontMap[i] = FontSlot[WIN_TINYFONT1];}
|
||||
else if (i == FONT12POINT1)
|
||||
{WinFontMap[i] = FontSlot[WIN_12POINTFONT1];}
|
||||
else if (i == COMPFONT)
|
||||
{WinFontMap[i] = FontSlot[WIN_COMPFONT];}
|
||||
else if (i == SMALLCOMPFONT)
|
||||
{WinFontMap[i] = FontSlot[WIN_SMALLCOMPFONT];}
|
||||
else if (i == FONT10ROMAN)
|
||||
{WinFontMap[i] = FontSlot[WIN_10POINTROMAN];}
|
||||
else if (i == FONT12ROMAN)
|
||||
{WinFontMap[i] = FontSlot[WIN_12POINTROMAN];}
|
||||
else if (i == FONT14SANSERIF)
|
||||
{WinFontMap[i] = FontSlot[WIN_14POINTSANSSERIF];}
|
||||
else if (i == MILITARYFONT1)
|
||||
{WinFontMap[i] = FontSlot[WIN_BLOCKYFONT];}
|
||||
else if (i == FONT10ARIAL)
|
||||
{WinFontMap[i] = FontSlot[WIN_10POINTARIAL];}
|
||||
else if (i == FONT14ARIAL)
|
||||
{WinFontMap[i] = FontSlot[WIN_14POINTARIAL];}
|
||||
else if (i == FONT10ARIALBOLD)
|
||||
{WinFontMap[i] = FontSlot[WIN_10POINTARIALBOLD];}
|
||||
else if (i == BLOCKFONT)
|
||||
{WinFontMap[i] = FontSlot[WIN_BLOCKYFONT];}
|
||||
else if (i == BLOCKFONT2)
|
||||
{WinFontMap[i] = FontSlot[WIN_BLOCKYFONT2];}
|
||||
else if (i == FONT12ARIALFIXEDWIDTH)
|
||||
{WinFontMap[i] = FontSlot[WIN_12POINTARIALFIXEDFONT];}
|
||||
else if (i == FONT16ARIAL)
|
||||
{WinFontMap[i] = FontSlot[WIN_16POINTARIAL];}
|
||||
else if (i == BLOCKFONTNARROW)
|
||||
{WinFontMap[i] = FontSlot[WIN_BLOCKFONTNARROW];}
|
||||
else if (i == FONT14HUMANIST)
|
||||
{WinFontMap[i] = FontSlot[WIN_14POINTHUMANIST];}
|
||||
else {WinFontMap[i] = -1;}
|
||||
}
|
||||
}
|
||||
|
||||
void ShutdownWinFonts( )
|
||||
{
|
||||
|
||||
for (int i=0; i<MAX_WINFONTMAP; i++)
|
||||
{DeleteWinFont(i);}
|
||||
}
|
||||
|
||||
INT32 FindFreeWinFont( void )
|
||||
{
|
||||
INT32 iCount;
|
||||
|
||||
for( iCount = 0; iCount < MAX_WIN_FONTS; iCount++ )
|
||||
for( iCount = 0; iCount < MAX_WINFONTMAP; iCount++ )
|
||||
{
|
||||
if( WinFonts[ iCount ].hFont == NULL )
|
||||
{
|
||||
@@ -93,7 +286,7 @@ INT32 FindFreeWinFont( void )
|
||||
|
||||
HWINFONT *GetWinFont( INT32 iFont )
|
||||
{
|
||||
if ( iFont == -1 )
|
||||
if ( iFont == -1 || iFont >=WIN_LASTFONT)
|
||||
{
|
||||
return( NULL );
|
||||
}
|
||||
@@ -108,14 +301,11 @@ HWINFONT *GetWinFont( INT32 iFont )
|
||||
}
|
||||
}
|
||||
|
||||
CHAR16 gzFontName[32];
|
||||
|
||||
INT32 CreateWinFont( INT32 iHeight, INT32 iWidth, INT32 iEscapement,
|
||||
INT32 iWeight, BOOLEAN fItalic, BOOLEAN fUnderline, BOOLEAN fStrikeOut, STR16 szFontName, INT32 iCharSet )
|
||||
INT32 CreateWinFont( LOGFONT &logfont )
|
||||
{
|
||||
INT32 iFont;
|
||||
HFONT hFont;
|
||||
CHAR8 szCharFontName[32]; //32 characters including null terminator (matches max font name length)
|
||||
// Find free slot
|
||||
iFont = FindFreeWinFont( );
|
||||
|
||||
@@ -124,35 +314,43 @@ INT32 CreateWinFont( INT32 iHeight, INT32 iWidth, INT32 iEscapement,
|
||||
return( iFont );
|
||||
}
|
||||
|
||||
//SET UP FONT WE WANT TO LOAD HERE
|
||||
wcscpy( gzFontName, szFontName );
|
||||
|
||||
//ATTEMPT TO LOAD THE FONT NOW
|
||||
sprintf( szCharFontName, "%S", szFontName );
|
||||
if( DoesWinFontExistOnSystem( szFontName, iCharSet ) )
|
||||
hFont = CreateFontIndirect( &logfont );
|
||||
if (hFont == NULL)
|
||||
{
|
||||
gLogFont.lfHeight = iHeight;
|
||||
gLogFont.lfWidth = 0;
|
||||
hFont = CreateFontIndirect( &gLogFont );
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalError( "Cannot load subtitle Windows Font: %S.", szFontName );
|
||||
FatalError( "Cannot load subtitle Windows Font: %S.", logfont.lfFaceName);
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
if ( hFont == NULL )
|
||||
{
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
// Set font....
|
||||
WinFonts[ iFont ].hFont = hFont;
|
||||
|
||||
HDC hdc = GetDC(NULL);
|
||||
SIZE RectSize;
|
||||
SelectObject(hdc, hFont );
|
||||
wchar_t str[2]=L"\1";
|
||||
for (int i = 1; i<0x80; i++)
|
||||
{
|
||||
GetTextExtentPoint32W( hdc, str, 1, &RectSize );
|
||||
WinFonts[iFont].Width[i]=(UINT8)RectSize.cx;
|
||||
str[0]++;
|
||||
}
|
||||
str[0] = L'°¡';
|
||||
GetTextExtentPoint32W( hdc, str, 1, &RectSize );
|
||||
WinFonts[iFont].Width[0] = (UINT8)RectSize.cx;
|
||||
TEXTMETRIC tm;
|
||||
GetTextMetrics(hdc, &tm);
|
||||
WinFonts[ iFont ].Height = (UINT8)tm.tmAscent;
|
||||
#ifdef DEC_INTERNAL_LEADING
|
||||
WinFonts[ iFont ].InternalLeading = (UINT8)tm.tmInternalLeading;
|
||||
#endif
|
||||
ReleaseDC(NULL, hdc);
|
||||
|
||||
return( iFont );
|
||||
}
|
||||
|
||||
void DeleteWinFont( INT32 iFont )
|
||||
void DeleteWinFont( INT32 iFont )
|
||||
{
|
||||
HWINFONT *pWinFont;
|
||||
|
||||
@@ -160,7 +358,8 @@ void DeleteWinFont( INT32 iFont )
|
||||
|
||||
if ( pWinFont != NULL )
|
||||
{
|
||||
DeleteObject( pWinFont->hFont );
|
||||
DeleteObject( pWinFont->hFont );
|
||||
pWinFont->hFont = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,15 +393,12 @@ void SetWinFontBackColor( INT32 iFont, COLORVAL *pColor )
|
||||
void PrintWinFont( UINT32 uiDestBuf, INT32 iFont, INT32 x, INT32 y, STR16 pFontString, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
CHAR16 string2[512];
|
||||
CHAR8 string[512];
|
||||
CHAR16 string[512];
|
||||
HVSURFACE hVSurface;
|
||||
LPDIRECTDRAWSURFACE2 pDDSurface;
|
||||
HDC hdc;
|
||||
RECT rc;
|
||||
HWINFONT *pWinFont;
|
||||
int len;
|
||||
SIZE RectSize;
|
||||
|
||||
pWinFont = GetWinFont( iFont );
|
||||
|
||||
@@ -212,15 +408,9 @@ void PrintWinFont( UINT32 uiDestBuf, INT32 iFont, INT32 x, INT32 y, STR16 pFontS
|
||||
}
|
||||
|
||||
va_start(argptr, pFontString); // Set up variable argument pointer
|
||||
len = vswprintf(string2, pFontString, argptr); // process gprintf string (get output str)
|
||||
len = vswprintf(string, pFontString, argptr); // process gprintf string (get output str)
|
||||
va_end(argptr);
|
||||
|
||||
#ifdef TAIWANESE
|
||||
Convert16BitStringTo8BitChineseBig5String( string, string2 );
|
||||
#else
|
||||
sprintf( string, "%S", string2 );
|
||||
#endif
|
||||
|
||||
// Get surface...
|
||||
GetVideoSurface( &hVSurface, uiDestBuf );
|
||||
|
||||
@@ -232,10 +422,16 @@ void PrintWinFont( UINT32 uiDestBuf, INT32 iFont, INT32 x, INT32 y, STR16 pFontS
|
||||
SetTextColor( hdc, pWinFont->ForeColor );
|
||||
SetBkColor(hdc, pWinFont->BackColor );
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
SetTextAlign(hdc, TA_TOP|TA_LEFT);
|
||||
|
||||
#ifdef DEC_INTERNAL_LEADING
|
||||
if (y - pWinFont->InternalLeading >=0)
|
||||
{
|
||||
y -= pWinFont->InternalLeading;
|
||||
}
|
||||
#endif
|
||||
TextOutW( hdc, x, y, string, len );
|
||||
|
||||
GetTextExtentPoint32( hdc, string, len, &RectSize );
|
||||
SetRect(&rc, x, y, x + RectSize.cx, y + RectSize.cy );
|
||||
ExtTextOut( hdc, x, y, ETO_OPAQUE, &rc, string, len, NULL );
|
||||
IDirectDrawSurface2_ReleaseDC( pDDSurface, hdc );
|
||||
|
||||
}
|
||||
@@ -243,10 +439,10 @@ void PrintWinFont( UINT32 uiDestBuf, INT32 iFont, INT32 x, INT32 y, STR16 pFontS
|
||||
INT16 WinFontStringPixLength( STR16 string2, INT32 iFont )
|
||||
{
|
||||
HWINFONT *pWinFont;
|
||||
#ifndef CHINESE
|
||||
HDC hdc;
|
||||
SIZE RectSize;
|
||||
CHAR8 string[512];
|
||||
|
||||
#endif
|
||||
pWinFont = GetWinFont( iFont );
|
||||
|
||||
if ( pWinFont == NULL )
|
||||
@@ -254,27 +450,37 @@ INT16 WinFontStringPixLength( STR16 string2, INT32 iFont )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
#ifdef TAIWANESE
|
||||
Convert16BitStringTo8BitChineseBig5String( string, string2 );
|
||||
#ifdef CHINESE
|
||||
wchar_t *p=string2;
|
||||
UINT32 size = 0;
|
||||
while (*p!=0)
|
||||
{
|
||||
if (*p != L'|')
|
||||
{
|
||||
if (*p>0x80)
|
||||
{size+=pWinFont->Width[0];}
|
||||
else
|
||||
{size+=pWinFont->Width[*p];}
|
||||
}
|
||||
p++;
|
||||
}
|
||||
return size;
|
||||
#else
|
||||
sprintf( string, "%S", string2 );
|
||||
#endif
|
||||
|
||||
hdc = GetDC(NULL);
|
||||
SelectObject(hdc, pWinFont->hFont );
|
||||
GetTextExtentPoint32( hdc, string, strlen(string), &RectSize );
|
||||
GetTextExtentPoint32W( hdc, string2, lstrlenW(string2), &RectSize );
|
||||
ReleaseDC(NULL, hdc);
|
||||
|
||||
return( (INT16)RectSize.cx );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
INT16 GetWinFontHeight( STR16 string2, INT32 iFont )
|
||||
{
|
||||
HWINFONT *pWinFont;
|
||||
HDC hdc;
|
||||
SIZE RectSize;
|
||||
CHAR8 string[512];
|
||||
// HDC hdc;
|
||||
// SIZE RectSize;
|
||||
|
||||
pWinFont = GetWinFont( iFont );
|
||||
|
||||
@@ -282,19 +488,17 @@ INT16 GetWinFontHeight( STR16 string2, INT32 iFont )
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
#ifdef TAIWANESE
|
||||
Convert16BitStringTo8BitChineseBig5String( string, string2 );
|
||||
#else
|
||||
sprintf( string, "%S", string2 );
|
||||
#endif
|
||||
|
||||
else
|
||||
{
|
||||
return pWinFont->Height;
|
||||
}
|
||||
/*
|
||||
hdc = GetDC(NULL);
|
||||
SelectObject(hdc, pWinFont->hFont );
|
||||
GetTextExtentPoint32( hdc, string, strlen(string), &RectSize );
|
||||
GetTextExtentPoint32W( hdc, string2, lstrlenW(string2), &RectSize );
|
||||
ReleaseDC(NULL, hdc);
|
||||
|
||||
return( (INT16)RectSize.cy );
|
||||
return( (INT16)RectSize.cy );*/
|
||||
}
|
||||
|
||||
UINT32 WinFont_mprintf( INT32 iFont, INT32 x, INT32 y, STR16 pFontString, ...)
|
||||
@@ -310,49 +514,3 @@ UINT32 WinFont_mprintf( INT32 iFont, INT32 x, INT32 y, STR16 pFontString, ...)
|
||||
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
int CALLBACK EnumFontFamProc( CONST LOGFONT *lplf, CONST TEXTMETRIC *lptm, DWORD dwType, LPARAM lpData )
|
||||
{
|
||||
|
||||
gfEnumSucceed = TRUE;
|
||||
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
|
||||
int CALLBACK EnumFontFamExProc( ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme, int FontType, LPARAM lParam )
|
||||
{
|
||||
CHAR8 szFontName[32];
|
||||
|
||||
sprintf( szFontName, "%S", gzFontName );
|
||||
if( !strcmp( szFontName, (STR8) lpelfe->elfFullName ) )
|
||||
{
|
||||
gfEnumSucceed = TRUE;
|
||||
memcpy( &gLogFont, &(lpelfe->elfLogFont), sizeof( LOGFONT ) );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN DoesWinFontExistOnSystem( STR16 pTypeFaceName, INT32 iCharSet )
|
||||
{
|
||||
HDC hdc;
|
||||
char string[512];
|
||||
LOGFONT LogFont;
|
||||
hdc = GetDC(NULL);
|
||||
|
||||
gfEnumSucceed = FALSE;
|
||||
// Copy into 8-bit!
|
||||
sprintf( string, "%S", pTypeFaceName );
|
||||
|
||||
memset( &LogFont, 0, sizeof( LOGFONT ) );
|
||||
LogFont.lfCharSet = iCharSet;
|
||||
lstrcpy( (LPSTR)&LogFont.lfFaceName, string );
|
||||
|
||||
EnumFontFamiliesEx( hdc, &LogFont, (FONTENUMPROCA) EnumFontFamExProc, 0, 0 );
|
||||
|
||||
ReleaseDC(NULL, hdc);
|
||||
|
||||
return( gfEnumSucceed );
|
||||
}
|
||||
Reference in New Issue
Block a user