hedgewars/uRenderUtils.pas
changeset 15974 8bb07b0f50ca
parent 15971 cee831693af1
child 15975 2146cb7be36f
equal deleted inserted replaced
15973:2d9d07ccb8ef 15974:8bb07b0f50ca
   113     tmpsurf: PSDL_Surface;
   113     tmpsurf: PSDL_Surface;
   114     finalRect, textRect: TSDL_Rect;
   114     finalRect, textRect: TSDL_Rect;
   115     clr: TSDL_Color;
   115     clr: TSDL_Color;
   116 begin
   116 begin
   117     TTF_SizeUTF8(Fontz[Font].Handle, PChar(s), @w, @h);
   117     TTF_SizeUTF8(Fontz[Font].Handle, PChar(s), @w, @h);
   118     if (maxLength > 0) and (w > maxLength * HDPIScaleFactor) then w := maxLength * HDPIScaleFactor;
   118     if (maxLength > 0) and (w > round(maxLength * HDPIScaleFactor)) then w := round(maxLength * HDPIScaleFactor);
   119     finalRect.x:= X;
   119     finalRect.x:= X;
   120     finalRect.y:= Y;
   120     finalRect.y:= Y;
   121     finalRect.w:= w + cFontBorder * 2 + cFontPadding * 2;
   121     finalRect.w:= w + cFontBorder * 2 + cFontPadding * 2;
   122     finalRect.h:= h + cFontBorder * 2;
   122     finalRect.h:= h + cFontBorder * 2;
   123     textRect.x:= X;
   123     textRect.x:= X;
   383         begin
   383         begin
   384         if length(s) = 0 then s:= _S' ';
   384         if length(s) = 0 then s:= _S' ';
   385         font:= CheckCJKFont(s, font);
   385         font:= CheckCJKFont(s, font);
   386         w:= 0; h:= 0; // avoid compiler hints
   386         w:= 0; h:= 0; // avoid compiler hints
   387         TTF_SizeUTF8(Fontz[font].Handle, PChar(s), @w, @h);
   387         TTF_SizeUTF8(Fontz[font].Handle, PChar(s), @w, @h);
   388         if (maxLength > 0) and (w > maxLength * HDPIScaleFactor) then w := maxLength * HDPIScaleFactor;
   388         if (maxLength > 0) and (w > round(maxLength * HDPIScaleFactor)) then w := round(maxLength * HDPIScaleFactor);
   389 
   389 
   390         finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder*2 + cFontPadding*2, h + cFontBorder * 2,
   390         finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder*2 + cFontPadding*2, h + cFontBorder * 2,
   391                 32, RMask, GMask, BMask, AMask);
   391                 32, RMask, GMask, BMask, AMask);
   392 
   392 
   393         if checkFails(finalSurface <> nil, 'RenderString: fail to create surface', true) then
   393         if checkFails(finalSurface <> nil, 'RenderString: fail to create surface', true) then