hedgewars/uRenderUtils.pas
changeset 10104 cb0b750bd8a3
parent 10040 4ac87acbaed9
child 10105 8c5fa1d15bd5
--- a/hedgewars/uRenderUtils.pas	Tue Feb 04 14:04:24 2014 +0100
+++ b/hedgewars/uRenderUtils.pas	Tue Feb 04 15:23:37 2014 +0100
@@ -35,7 +35,8 @@
 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
 
 function  RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture;
-function  RenderStringTexLim(s: ansistring; Color: Longword; font: THWFont; maxLength: LongWord): PTexture;
+function  RenderStringTexPChar(s: PChar; Color: Longword; font: THWFont): PTexture;
+function  RenderStringTexLim(s: PChar; Color: Longword; font: THWFont; maxLength: LongWord): PTexture;
 function  RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture;
 
 implementation
@@ -270,17 +271,22 @@
 
 function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture;
 begin
-    RenderStringTex:= RenderStringTexLim(s, Color, font, 0);
+    RenderStringTex:= RenderStringTexLim(Str2PChar(s), Color, font, 0);
 end;
 
-function RenderStringTexLim(s: ansistring; Color: Longword; font: THWFont; maxLength: LongWord): PTexture;
+function RenderStringTexPChar(s: PChar; Color: Longword; font: THWFont): PTexture;
+begin
+    RenderStringTexPChar:= RenderStringTexLim(s, Color, font, 0);
+end;
+
+function RenderStringTexLim(s: PChar; Color: Longword; font: THWFont; maxLength: LongWord): PTexture;
 var w, h: LongInt;
     finalSurface: PSDL_Surface;
 begin
-    if length(s) = 0 then s:= _S' ';
+    if StrLength(s) = 0 then s:= Str2PChar(''); // conversion because pas2c ain't smart enough yet;
     font:= CheckCJKFont(s, font);
     w:= 0; h:= 0; // avoid compiler hints
-    TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), @w, @h);
+    TTF_SizeUTF8(Fontz[font].Handle, s, @w, @h);
     if (maxLength <> 0) and (w > maxLength) then w := maxLength;
 
     finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder * 2 + 4, h + cFontBorder * 2,
@@ -336,7 +342,7 @@
 
     if length(s) = 0 then
         s:= '...';
-    font:= CheckCJKFont(s, font);
+    font:= CheckCJKFont(Str2PChar(s), font);
     w:= 0; h:= 0; // avoid compiler hints
     TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), @w, @h);
     if w<8 then