6 Commits

Author SHA1 Message Date
Ray
a946097de4 Remove trailing spaces 2026-08-26 19:47:40 +02:00
Ray
ba0ac542c5 Update rtext.c 2026-08-26 19:46:45 +02:00
173b854168 Fix memory leak in rtext LoadFontFromImage method (#6100)
Fix for
[rtext] Memory leak at LoadFontFromImage when failing to compute spacing's
2026-08-26 19:43:03 +02:00
4c1dc51a6f Fix unused variable warnings (SDL) (#6096) 2026-08-26 18:39:42 +02:00
b7d7e70ac5 Fix Font name conflict (#6094) 2026-08-26 18:38:45 +02:00
d9bf63bdf4 Updated BINDINGS.md for raylib-py 6.0 (#6095)
Co-authored-by: Jorge A. Gomes <jorgegomes83@gmail.com>
2026-08-26 18:37:52 +02:00
7 changed files with 35 additions and 56 deletions

View File

@ -78,7 +78,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers
| [pyraylib](https://github.com/Ho011/pyraylib) | 3.7 | [Python](https://www.python.org) | Zlib |
| [raylib-python-cffi](https://github.com/electronstudio/raylib-python-cffi) | **5.5** | [Python](https://www.python.org) | EPL-2.0 |
| [raylibpyctbg](https://github.com/overdev/raylibpyctbg) | 5.5 | [Python](https://www.python.org) | MIT |
| [raylib-py](https://github.com/overdev/raylib-py) | 5.5 | [Python](https://www.python.org) | MIT |
| [raylib-py](https://github.com/overdev/raylib-py) | **6.0** | [Python](https://www.python.org) | MIT |
| [raylib-python-ctypes](https://github.com/sDos280/raylib-python-ctypes) | 4.6-dev | [Python](https://www.python.org) | MIT |
| [raylib-pkpy-bindings](https://github.com/blueloveTH/pkpy-bindings) | 5.1-dev | [pocketpy](https://pocketpy.dev) | MIT |
| [raylib-php](https://github.com/joseph-montanez/raylib-php) | 4.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | Zlib |

View File

@ -56,12 +56,13 @@
#include "SDL3/SDL.h"
#elif defined(USING_SDL2_PROJECT)
#include "SDL2/SDL.h"
#if !defined(__linux__)
// WARNING: On Linux this header includes Xlib.h that defines Font and
// conflicts with raylib Font, as it is only used on GetWindowHandle() and
// most users do not need that function, just commenting for that case
// WARNING: On Linux, this header includes Xlib.h, which defines Font
// To prevent a conflict with raylib's own Font type, we temporarily
// rename it to FontX11
#define Font FontX11
#include "SDL2/SDL_syswm.h" // Required to get window handlers
#endif
#undef Font
#else
#include "SDL.h"
#endif
@ -469,12 +470,11 @@ bool WindowShouldClose(void)
void ToggleFullscreen(void)
{
const int monitor = SDL_GetWindowDisplayIndex(platform.window);
const int monitorCount = SDL_GetNumVideoDisplays();
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
#else
if ((monitor >= 0) && (monitor < monitorCount))
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
#endif
{
if (FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE))
@ -495,12 +495,11 @@ void ToggleFullscreen(void)
void ToggleBorderlessWindowed(void)
{
const int monitor = SDL_GetWindowDisplayIndex(platform.window);
const int monitorCount = SDL_GetNumVideoDisplays();
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
#else
if ((monitor >= 0) && (monitor < monitorCount))
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
#endif
{
if (FLAG_IS_SET(CORE.Window.flags, FLAG_BORDERLESS_WINDOWED_MODE))
@ -552,12 +551,11 @@ void SetWindowState(unsigned int flags)
if (FLAG_IS_SET(flags, FLAG_FULLSCREEN_MODE))
{
const int monitor = SDL_GetWindowDisplayIndex(platform.window);
const int monitorCount = SDL_GetNumVideoDisplays();
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
#else
if ((monitor >= 0) && (monitor < monitorCount))
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
#endif
{
SDL_SetWindowFullscreen(platform.window, SDL_WINDOW_FULLSCREEN);
@ -614,12 +612,11 @@ void SetWindowState(unsigned int flags)
if (FLAG_IS_SET(flags, FLAG_BORDERLESS_WINDOWED_MODE))
{
const int monitor = SDL_GetWindowDisplayIndex(platform.window);
const int monitorCount = SDL_GetNumVideoDisplays();
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
#else
if ((monitor >= 0) && (monitor < monitorCount))
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
#endif
{
SDL_SetWindowFullscreen(platform.window, SDL_WINDOW_FULLSCREEN_DESKTOP);
@ -836,11 +833,10 @@ void SetWindowPosition(int x, int y)
// Set monitor for the current window
void SetWindowMonitor(int monitor)
{
const int monitorCount = SDL_GetNumVideoDisplays();
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
#else
if ((monitor >= 0) && (monitor < monitorCount))
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
#endif
{
// NOTE 1: SDL started supporting moving exclusive fullscreen windows between displays on SDL3,
@ -960,17 +956,13 @@ void *GetWindowHandle(void)
#elif defined(__APPLE__)
handle = (void *)SDL_GetPointerProperty(props, SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, NULL); // Type: NSWindow*
#endif
#elif defined(USING_SDL2_PROJECT) && !defined(__linux__)
// WARNING: On linux the inclusion of SDL_syswm.h also includes Xlib.h and
// generates a symbol conflict with raylib due to Font, as this function is not
// required by most users, just avoiding that use case
#elif defined(USING_SDL2_PROJECT)
SDL_SysWMinfo wmInfo = { 0 };
SDL_VERSION(&wmInfo.version);
if (SDL_GetWindowWMInfo(platform.window, &wmInfo))
{
#if defined(_WIN32)
handle = (void *)wmInfo.info.win.window; // Type: HWND
/*
#elif defined(__linux__)
if (wmInfo.subsystem == SDL_SYSWM_X11)
{
@ -984,7 +976,6 @@ void *GetWindowHandle(void)
// NOTE: Alternative: wmInfo.info.wl.display
handle = (void *)wmInfo.info.wl.surface; // Type: struct wl_surface*
}
*/
#elif defined(__APPLE__)
handle = (void *)wmInfo.info.cocoa.window; // Type: NSWindow*
#endif
@ -997,32 +988,23 @@ void *GetWindowHandle(void)
// Get number of monitors
int GetMonitorCount(void)
{
int monitorCount = 0;
monitorCount = SDL_GetNumVideoDisplays();
return monitorCount;
return SDL_GetNumVideoDisplays();
}
// Get current monitor where window is placed
int GetCurrentMonitor(void)
{
int currentMonitor = 0;
// Be aware that this returns an ID in SDL3 and a Index in SDL2
currentMonitor = SDL_GetWindowDisplayIndex(platform.window);
return currentMonitor;
return SDL_GetWindowDisplayIndex(platform.window);
}
// Get selected monitor position
Vector2 GetMonitorPosition(int monitor)
{
const int monitorCount = SDL_GetNumVideoDisplays();
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
#else
if ((monitor >= 0) && (monitor < monitorCount))
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
#endif
{
SDL_Rect displayBounds;
@ -1046,11 +1028,10 @@ int GetMonitorWidth(int monitor)
{
int width = 0;
const int monitorCount = SDL_GetNumVideoDisplays();
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
#else
if ((monitor >= 0) && (monitor < monitorCount))
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
#endif
{
SDL_DisplayMode mode;
@ -1067,11 +1048,10 @@ int GetMonitorHeight(int monitor)
{
int height = 0;
const int monitorCount = SDL_GetNumVideoDisplays();
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
#else
if ((monitor >= 0) && (monitor < monitorCount))
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
#endif
{
SDL_DisplayMode mode;
@ -1088,11 +1068,10 @@ int GetMonitorPhysicalWidth(int monitor)
{
int width = 0;
const int monitorCount = SDL_GetNumVideoDisplays();
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
#else
if ((monitor >= 0) && (monitor < monitorCount))
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
#endif
{
float ddpi = 0.0f;
@ -1112,11 +1091,10 @@ int GetMonitorPhysicalHeight(int monitor)
{
int height = 0;
const int monitorCount = SDL_GetNumVideoDisplays();
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
#else
if ((monitor >= 0) && (monitor < monitorCount))
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
#endif
{
float ddpi = 0.0f;
@ -1136,11 +1114,10 @@ int GetMonitorRefreshRate(int monitor)
{
int refresh = 0;
const int monitorCount = SDL_GetNumVideoDisplays();
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
#else
if ((monitor >= 0) && (monitor < monitorCount))
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
#endif
{
SDL_DisplayMode mode;
@ -1155,12 +1132,10 @@ int GetMonitorRefreshRate(int monitor)
// Get the human-readable, UTF-8 encoded name of the selected monitor
const char *GetMonitorName(int monitor)
{
const int monitorCount = SDL_GetNumVideoDisplays();
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
#else
if ((monitor >= 0) && (monitor < monitorCount))
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
#endif
{
return SDL_GetDisplayName(monitor);

View File

@ -417,9 +417,6 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
int charSpacing = 0;
int lineSpacing = 0;
int x = 0;
int y = 0;
// Allocate a temporal arrays for glyphs data measures,
// once the actual number of glyphs is obtained, copy data to a sized array
int tempCharValues[MAX_GLYPHS_FROM_IMAGE] = { 0 };
@ -428,6 +425,8 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
Color *pixels = LoadImageColors(image);
// Parse image data to get charSpacing and lineSpacing
int x = 0;
int y = 0;
for (y = 0; y < image.height; y++)
{
for (x = 0; x < image.width; x++)
@ -438,7 +437,12 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
if (!COLOR_EQUAL(pixels[y*image.width + x], key)) break;
}
if ((x == 0) || (y == 0)) return font; // Security check
// Security check
if ((x == 0) || (y == 0))
{
UnloadImageColors(pixels);
return font;
}
charSpacing = x;
lineSpacing = y;