--- a/hedgewars/SDLh.pas Mon Oct 16 21:06:32 2006 +0000
+++ b/hedgewars/SDLh.pas Thu Oct 19 18:57:58 2006 +0000
@@ -110,7 +110,7 @@
r: Byte;
g: Byte;
b: Byte;
- a: Byte;
+ unused: Byte;
end;
PSDL_RWops = ^TSDL_RWops;
@@ -226,7 +226,9 @@
{$IFDEF UNIX}
SDL_TTFLibName = 'libSDL_ttf.so';
{$ENDIF}
-
+ TTF_STYLE_NORMAL = 0;
+ TTF_STYLE_BOLD = 1;
+ TTF_STYLE_ITALIC = 2;
type PTTF_Font = ^TTTF_font;
TTTF_Font = record
@@ -240,6 +242,7 @@
function TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
function TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
function TTF_OpenFont(const filename: PChar; size: integer): PTTF_Font; cdecl; external SDL_TTFLibName;
+procedure TTF_SetFontStyle(font: PTTF_Font; style: integer); cdecl; external SDL_TTFLibName;
(* SDL_mixer *)
--- a/hedgewars/uConsts.pas Mon Oct 16 21:06:32 2006 +0000
+++ b/hedgewars/uConsts.pas Thu Oct 19 18:57:58 2006 +0000
@@ -50,6 +50,7 @@
THHFont = record
Handle: PTTF_Font;
Height: integer;
+ style: integer;
Name: string[15];
end;
TAmmo = record
@@ -160,11 +161,15 @@
Fontz: array[THWFont] of THHFont = (
(Height: 12;
+ style: TTF_STYLE_NORMAL;
Name: 'DejaVuSans.ttf'),
(Height: 24;
+ style: TTF_STYLE_NORMAL;
Name: 'DejaVuSans.ttf')
);
+ FontBorder = 2;
+
PathPrefix: string = './';
Pathz: array[TPathType] of string = (
'', // ptNone
--- a/hedgewars/uStore.pas Mon Oct 16 21:06:32 2006 +0000
+++ b/hedgewars/uStore.pas Thu Oct 19 18:57:58 2006 +0000
@@ -102,23 +102,22 @@
TTF_SizeUTF8(Fontz[Font].Handle, PChar(s), w, h);
Result.x:= X;
Result.y:= Y;
-Result.w:= w + 6;
-Result.h:= h + 2;
+Result.w:= w + FontBorder * 2 + 4;
+Result.h:= h + FontBorder * 2;
DrawRoundRect(@Result, cWhiteColor, cColorNearBlack, Surface);
clr.r:= Color shr 16;
clr.g:= (Color shr 8) and $FF;
clr.b:= Color and $FF;
-clr.a:= $FF;
tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, PChar(s), clr);
-Result.x:= X + 3;
-Result.y:= Y + 1;
+Result.x:= X + FontBorder + 2;
+Result.y:= Y + FontBorder;
SDLTry(tmpsurf <> nil, true);
SDL_UpperBlit(tmpsurf, nil, Surface, @Result);
SDL_FreeSurface(tmpsurf);
Result.x:= X;
Result.y:= Y;
-Result.w:= w + 6;
-Result.h:= h + 2
+Result.w:= w + FontBorder * 2 + 4;
+Result.h:= h + FontBorder * 2
end;
procedure StoreLoad;
@@ -257,6 +256,7 @@
WriteToConsole(msgLoading + s + '... ');
Handle:= TTF_OpenFont(PChar(s), Height);
SDLTry(Handle <> nil, true);
+ TTF_SetFontStyle(Handle, style);
WriteLnToConsole(msgOK)
end;
AddProgress;
@@ -375,7 +375,6 @@
clr.r:= $FF;
clr.g:= $FF;
clr.b:= $FF;
-clr.a:= $FF;
tmpsurf:= TTF_RenderUTF8_Solid(Fontz[Font].Handle, PChar(s), clr);
SDLTry(tmpsurf <> nil, true);
SDL_UpperBlit(tmpsurf, nil, Surface, @r);
@@ -433,7 +432,8 @@
var w, h: integer;
begin
TTF_SizeUTF8(Fontz[font].Handle, PChar(s), w, h);
-Result:= SDL_CreateRGBSurface(SDL_HWSURFACE, w + 6, h + 2, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, PixelFormat.AMask);
+Result:= SDL_CreateRGBSurface(SDL_HWSURFACE, w + FontBorder * 2 + 4, h + FontBorder * 2,
+ cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, PixelFormat.AMask);
TryDo(Result <> nil, 'RenderString: fail to create surface', true);
WriteInRoundRect(Result, 0, 0, Color, font, s);
TryDo(SDL_SetColorKey(Result, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true)