@@ -893,10 +893,11 @@ static int l_DrawImage(lua_State* L)
893893 }
894894
895895 if (af & AF_XY ) {
896+ const float dpiScale = ui->renderer ->VirtualScreenScaleFactor ();
896897 for (int i = k; i < k + 4 ; i++) {
897898 ui->LAssert (L, lua_isnumber (L, i), " DrawImage() argument %d: expected number, got %s" , i, luaL_typename (L, i));
898899 const int idx = i - k;
899- xys[idx/2 ][idx%2 ] = (float )lua_tonumber (L, i);
900+ xys[idx/2 ][idx%2 ] = (float )lua_tonumber (L, i) * dpiScale ;
900901 }
901902 k += 4 ;
902903 }
@@ -1061,9 +1062,15 @@ static int l_DrawString(lua_State* L)
10611062 ui->LAssert (L, lua_isstring (L, 6 ), " DrawString() argument 6: expected string, got %s" , luaL_typename (L, 6 ));
10621063 static const char * alignMap[6 ] = { " LEFT" , " CENTER" , " RIGHT" , " CENTER_X" , " RIGHT_X" , NULL };
10631064 static const char * fontMap[4 ] = { " FIXED" , " VAR" , " VAR BOLD" , NULL };
1065+ const float dpiScale = ui->renderer ->VirtualScreenScaleFactor ();
10641066 ui->renderer ->DrawString (
1065- (float )lua_tonumber (L, 1 ), (float )lua_tonumber (L, 2 ), luaL_checkoption (L, 3 , " LEFT" , alignMap),
1066- (int )lua_tointeger (L, 4 ), NULL , luaL_checkoption (L, 5 , " FIXED" , fontMap), lua_tostring (L, 6 )
1067+ (float )lua_tonumber (L, 1 ) * dpiScale,
1068+ (float )lua_tonumber (L, 2 ) * dpiScale,
1069+ luaL_checkoption (L, 3 , " LEFT" , alignMap),
1070+ (int )lua_tointeger (L, 4 ) * dpiScale,
1071+ NULL ,
1072+ luaL_checkoption (L, 5 , " FIXED" , fontMap),
1073+ lua_tostring (L, 6 )
10671074 );
10681075 return 0 ;
10691076}
@@ -1078,7 +1085,10 @@ static int l_DrawStringWidth(lua_State* L)
10781085 ui->LAssert (L, lua_isstring (L, 2 ), " DrawStringWidth() argument 2: expected string, got %s" , luaL_typename (L, 2 ));
10791086 ui->LAssert (L, lua_isstring (L, 3 ), " DrawStringWidth() argument 3: expected string, got %s" , luaL_typename (L, 3 ));
10801087 static const char * fontMap[4 ] = { " FIXED" , " VAR" , " VAR BOLD" , NULL };
1081- lua_pushinteger (L, ui->renderer ->DrawStringWidth ((int )lua_tointeger (L, 1 ), luaL_checkoption (L, 2 , " FIXED" , fontMap), lua_tostring (L, 3 )));
1088+ const float dpiScale = ui->renderer ->VirtualScreenScaleFactor ();
1089+ lua_pushinteger (L, ui->renderer ->DrawStringWidth ((int )lua_tointeger (L, 1 ) * dpiScale,
1090+ luaL_checkoption (L, 2 , " FIXED" , fontMap),
1091+ lua_tostring (L, 3 )) / dpiScale);
10821092 return 1 ;
10831093}
10841094
0 commit comments