Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Screens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ int iResolution; // INI file
int iPlayIntro;
int iDisableMouseScrolling;
int iUseWinFonts;
float fTooltipScaleFactor;
/* WANNE, Sgt.Kolja
* INI file (Windowed or Fullscreen)
* REPLACE all defines WINDOWED_MODE with this variable
Expand Down
2 changes: 1 addition & 1 deletion Standard Gaming Platform/Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ UINT16 GetFontHeight(INT32 FontNum)
MapFont = WinFontMap[FontNum];
if (FontNum != -1)
{
return (GetWinFontHeight(L"A", MapFont));
return (GetWinFontHeight(MapFont));
}
}
return((UINT16)GetHeight(FontObjs[FontNum], 0));
Expand Down
109 changes: 50 additions & 59 deletions Standard Gaming Platform/WinFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
#include <vfs/Tools/vfs_property_container.h>

INT32 FindFreeWinFont( void );
BOOLEAN gfEnumSucceed = FALSE;

#ifdef CHINESE
#define DEC_INTERNAL_LEADING
#endif

// Private struct not to be exported
// to other modules
Expand All @@ -41,15 +36,14 @@ typedef struct
COLORVAL ForeColor;
COLORVAL BackColor;
UINT8 Height;
UINT8 Width[0x80];
#ifdef DEC_INTERNAL_LEADING
UINT8 InternalLeading;
#ifdef CHINESE
UINT8 Width[0x80];
#endif
} HWINFONT;

LOGFONT gLogFont;
LONG gWinFontAdjust;
HWINFONT WinFonts[WIN_LASTFONT];
HWINFONT WinFonts[WIN_LASTFONT + 2]; // extra space for the tooltip fonts

INT32 WinFontMap[MAX_WINFONTMAP];

Expand Down Expand Up @@ -80,6 +74,9 @@ struct {
{"HugeFont", {-19, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, "ja2font3"}, FROMRGB(0, 255, 0)}
};

INT32 TOOLTIP_IFONT = -1;
INT32 TOOLTIP_IFONT_BOLD = -1;

void Convert16BitStringTo8Bit( CHAR8 *dst, CHAR16 *src )
{
//hope 'dst' is big enough
Expand Down Expand Up @@ -288,6 +285,31 @@ void ShutdownWinFonts( )
{DeleteWinFont(i);}
}

void InitTooltipFonts()
{
LOGFONT logFont = { -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE,
"Arial"
};
logFont.lfHeight = logFont.lfHeight * fTooltipScaleFactor;

LOGFONT boldTooltipLogFont = logFont;
boldTooltipLogFont.lfWeight = FW_BOLD;

TOOLTIP_IFONT = CreateWinFont(logFont);
TOOLTIP_IFONT_BOLD = CreateWinFont(boldTooltipLogFont);

COLORVAL regularColor = FROMRGB(201, 197, 143);
COLORVAL boldColor = FROMRGB(223, 176, 1);
SetWinFontForeColor(TOOLTIP_IFONT, &regularColor);
SetWinFontForeColor(TOOLTIP_IFONT_BOLD, &boldColor);
}

void ShutdownTooltipFonts()
{
ShutdownWinFonts();
}

INT32 FindFreeWinFont( void )
{
INT32 iCount;
Expand All @@ -306,7 +328,7 @@ INT32 FindFreeWinFont( void )

HWINFONT *GetWinFont( INT32 iFont )
{
if ( iFont == -1 || iFont >=WIN_LASTFONT)
if (iFont == -1 || iFont >= sizeof(WinFonts) )
{
return( NULL );
}
Expand Down Expand Up @@ -347,8 +369,10 @@ INT32 CreateWinFont( LOGFONT &logfont )
WinFonts[ iFont ].hFont = hFont;

HDC hdc = GetDC(NULL);
SelectObject(hdc, hFont);

#ifdef CHINESE
SIZE RectSize;
SelectObject(hdc, hFont );
wchar_t str[2]=L"\1";
for (int i = 1; i<0x80; i++)
{
Expand All @@ -359,12 +383,12 @@ INT32 CreateWinFont( LOGFONT &logfont )
str[0] = L'啊';
GetTextExtentPoint32W( hdc, str, 1, &RectSize );
WinFonts[iFont].Width[0] = (UINT8)RectSize.cx;
#endif

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 );
Expand Down Expand Up @@ -444,12 +468,10 @@ void PrintWinFont( UINT32 uiDestBuf, INT32 iFont, INT32 x, INT32 y, STR16 pFontS
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 );

IDirectDrawSurface2_ReleaseDC( pDDSurface, hdc );
Expand All @@ -458,17 +480,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;
#endif
HWINFONT *pWinFont;
pWinFont = GetWinFont( iFont );

if ( pWinFont == NULL )
{
return( 0 );
}
if (pWinFont == NULL) return(0);

#ifdef CHINESE
wchar_t *p=string2;
Expand All @@ -486,7 +501,9 @@ INT16 WinFontStringPixLength( STR16 string2, INT32 iFont )
}
return size;
#else
hdc = GetDC(NULL);
SIZE RectSize;
HDC hdc = GetDC(NULL);

SelectObject(hdc, pWinFont->hFont );
GetTextExtentPoint32W( hdc, string2, lstrlenW(string2), &RectSize );
ReleaseDC(NULL, hdc);
Expand All @@ -496,44 +513,18 @@ INT16 WinFontStringPixLength( STR16 string2, INT32 iFont )
}


INT16 GetWinFontHeight( STR16 string2, INT32 iFont )
INT16 GetWinFontHeight(INT32 iFont)
{
HWINFONT *pWinFont;
// HDC hdc;
// SIZE RectSize;
HWINFONT* pWinFont;

pWinFont = GetWinFont( iFont );
pWinFont = GetWinFont(iFont);

if ( pWinFont == NULL )
if (pWinFont == NULL) return(0);
#ifdef CHINESE //zwwooooo: Correct tactical interface font height to fixed Chinese characters smearing bug
if (iFont == WinFontMap[TINYFONT1] || iFont == WinFontMap[SMALLFONT1] || iFont == WinFontMap[WIN_14POINTARIAL])
{
return( 0 );
return pWinFont->Height + 2;
}
else
{
#ifdef CHINESE //zwwooooo: Correct tactical interface font height to fixed Chinese characters smearing bug
if (iFont==WIN_TINYFONT1 || iFont==WIN_SMALLFONT1 || iFont==WIN_14POINTARIAL) return pWinFont->Height+2;
#endif
return pWinFont->Height;
}
/*
hdc = GetDC(NULL);
SelectObject(hdc, pWinFont->hFont );
GetTextExtentPoint32W( hdc, string2, lstrlenW(string2), &RectSize );
ReleaseDC(NULL, hdc);

return( (INT16)RectSize.cy );*/
}

UINT32 WinFont_mprintf( INT32 iFont, INT32 x, INT32 y, STR16 pFontString, ...)
{
va_list argptr;
CHAR16 string[512];

va_start(argptr, pFontString); // Set up variable argument pointer
vswprintf(string, pFontString, argptr); // process gprintf string (get output str)
va_end(argptr);

PrintWinFont( FontDestBuffer, iFont, x, y, string );

return( 1 );
return pWinFont->Height;
}
8 changes: 6 additions & 2 deletions Standard Gaming Platform/WinFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
void InitWinFonts( );
void ShutdownWinFonts( );

void InitTooltipFonts();
void ShutdownTooltipFonts();
Comment thread
majcosta marked this conversation as resolved.

INT32 CreateWinFont( LOGFONT &logfont );
void DeleteWinFont( INT32 iFont );

Expand All @@ -14,8 +17,7 @@ void SetWinFontForeColor( INT32 iFont, COLORVAL *pColor );
void PrintWinFont( UINT32 uiDestBuf, INT32 iFont, INT32 x, INT32 y, STR16 pFontString, ...);

INT16 WinFontStringPixLength( STR16 string, INT32 iFont );
INT16 GetWinFontHeight( STR16 string, INT32 iFont );
UINT32 WinFont_mprintf( INT32 iFont, INT32 x, INT32 y, STR16 pFontString, ...);
INT16 GetWinFontHeight( INT32 iFont );

//if you cahnge this enum, you must change FontInfo struct in WinFont.cpp too.
enum {
Expand Down Expand Up @@ -43,5 +45,7 @@ WIN_LASTFONT
};
#define MAX_WINFONTMAP 25
extern INT32 WinFontMap[MAX_WINFONTMAP];
extern INT32 TOOLTIP_IFONT;
extern INT32 TOOLTIP_IFONT_BOLD;

#endif
Loading