Files
source/sgp/WinFont.h
T
Marco Antonio J. Costaandmajcosta b147e47856 let the text drawing path take a string it will not write to
DrawTextToScreen takes STR16, a mutable wchar_t*, for a string it only
measures and prints. Quest Debug System.cpp picks its text with a conditional:

  DrawTextToScreen( gubFact[ usLoop1 ] ? L"True" : L"False", ... );

which has type const wchar_t*. clang-cl's MSVC compatibility lets a bare
string literal decay to wchar_t*, but not a const wchar_t* expression, so it
reports

  error: no matching function for call to 'DrawTextToScreen'
  note: candidate function not viable: 1st argument ('const wchar_t *')
  would lose const qualifier

The parameter is const-correct in every function DrawTextToScreen hands the
string on to, so the change follows the string down the call chain rather
than stopping at the top:

  DrawTextToScreen, ShadowText          Utils/WordWrap.h
  WFStringPixLength                     Utils/Font Control.h
  mprintf, StringPixLength,             sgp/Font.h
  VarFindFontCenterCoordinates,
  VarFindFontRightCoordinates
  WinFontStringPixLength                sgp/WinFont.h
  gprintfdirty                          TileEngine/Render Dirty.h

The varargs members of that list copy the format string into a local buffer
before doing anything with it, and the measuring ones walk it and return a
width; none of the nine assigns through the parameter. Where StringPixLength
casts the string to UINT16* to walk it, the cast and the local now carry the
const rather than dropping it.

Callers are unaffected: every one already passes something that converts to
const CHAR16*. Both configurations build with no new diagnostics, and the
parse sweep drops from 9 error sites in 7 files to 5 in 3.

To check the claim that nothing writes through these parameters, read the
nine bodies; each is short.
2026-07-23 19:29:55 -03:00

52 lines
1.2 KiB
C

#ifndef __WINFONT_
#define __WINFONT_
#include <windows.h>
void InitWinFonts( );
void ShutdownWinFonts( );
void InitTooltipFonts();
void ShutdownTooltipFonts();
INT32 CreateWinFont( LOGFONT &logfont );
void DeleteWinFont( INT32 iFont );
void SetWinFontBackColor( INT32 iFont, COLORVAL *pColor );
void SetWinFontForeColor( INT32 iFont, COLORVAL *pColor );
void PrintWinFont( UINT32 uiDestBuf, INT32 iFont, INT32 x, INT32 y, STR16 pFontString, ...);
INT16 WinFontStringPixLength( const CHAR16* string, INT32 iFont );
INT16 GetWinFontHeight( INT32 iFont );
//if you cahnge this enum, you must change FontInfo struct in WinFont.cpp too.
enum {
WIN_LARGEFONT1 = 0,
WIN_SMALLFONT1,
WIN_TINYFONT1,
WIN_12POINTFONT1,
WIN_COMPFONT,
WIN_SMALLCOMPFONT,
WIN_10POINTROMAN,
WIN_12POINTROMAN,
WIN_14POINTSANSSERIF,
WIN_10POINTARIAL,
WIN_14POINTARIAL,
WIN_12POINTARIAL,
WIN_BLOCKYFONT,
WIN_BLOCKYFONT2,
WIN_10POINTARIALBOLD,
WIN_12POINTARIALFIXEDFONT,
WIN_16POINTARIAL,
WIN_BLOCKFONTNARROW,
WIN_14POINTHUMANIST,
WIN_HUGEFONT,
WIN_LASTFONT
};
#define MAX_WINFONTMAP 25
extern INT32 WinFontMap[MAX_WINFONTMAP];
extern INT32 TOOLTIP_IFONT;
extern INT32 TOOLTIP_IFONT_BOLD;
#endif