mirror of
https://github.com/raysan5/raylib.git
synced 2026-10-11 04:01:54 -04:00
Compare commits
6 Commits
71643d8cda
...
a946097de4
| Author | SHA1 | Date | |
|---|---|---|---|
| a946097de4 | |||
| ba0ac542c5 | |||
| 173b854168 | |||
| 4c1dc51a6f | |||
| b7d7e70ac5 | |||
| d9bf63bdf4 |
@ -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 |
|
| [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 |
|
| [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 |
|
| [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-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-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 |
|
| [raylib-php](https://github.com/joseph-montanez/raylib-php) | 4.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | Zlib |
|
||||||
|
|||||||
@ -56,12 +56,13 @@
|
|||||||
#include "SDL3/SDL.h"
|
#include "SDL3/SDL.h"
|
||||||
#elif defined(USING_SDL2_PROJECT)
|
#elif defined(USING_SDL2_PROJECT)
|
||||||
#include "SDL2/SDL.h"
|
#include "SDL2/SDL.h"
|
||||||
#if !defined(__linux__)
|
|
||||||
// WARNING: On Linux this header includes Xlib.h that defines Font and
|
// WARNING: On Linux, this header includes Xlib.h, which defines Font
|
||||||
// conflicts with raylib Font, as it is only used on GetWindowHandle() and
|
// To prevent a conflict with raylib's own Font type, we temporarily
|
||||||
// most users do not need that function, just commenting for that case
|
// rename it to FontX11
|
||||||
|
#define Font FontX11
|
||||||
#include "SDL2/SDL_syswm.h" // Required to get window handlers
|
#include "SDL2/SDL_syswm.h" // Required to get window handlers
|
||||||
#endif
|
#undef Font
|
||||||
#else
|
#else
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#endif
|
#endif
|
||||||
@ -469,12 +470,11 @@ bool WindowShouldClose(void)
|
|||||||
void ToggleFullscreen(void)
|
void ToggleFullscreen(void)
|
||||||
{
|
{
|
||||||
const int monitor = SDL_GetWindowDisplayIndex(platform.window);
|
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 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
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
||||||
#else
|
#else
|
||||||
if ((monitor >= 0) && (monitor < monitorCount))
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE))
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE))
|
||||||
@ -495,12 +495,11 @@ void ToggleFullscreen(void)
|
|||||||
void ToggleBorderlessWindowed(void)
|
void ToggleBorderlessWindowed(void)
|
||||||
{
|
{
|
||||||
const int monitor = SDL_GetWindowDisplayIndex(platform.window);
|
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 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
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
||||||
#else
|
#else
|
||||||
if ((monitor >= 0) && (monitor < monitorCount))
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_BORDERLESS_WINDOWED_MODE))
|
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))
|
if (FLAG_IS_SET(flags, FLAG_FULLSCREEN_MODE))
|
||||||
{
|
{
|
||||||
const int monitor = SDL_GetWindowDisplayIndex(platform.window);
|
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 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
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
||||||
#else
|
#else
|
||||||
if ((monitor >= 0) && (monitor < monitorCount))
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
SDL_SetWindowFullscreen(platform.window, SDL_WINDOW_FULLSCREEN);
|
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))
|
if (FLAG_IS_SET(flags, FLAG_BORDERLESS_WINDOWED_MODE))
|
||||||
{
|
{
|
||||||
const int monitor = SDL_GetWindowDisplayIndex(platform.window);
|
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 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
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
||||||
#else
|
#else
|
||||||
if ((monitor >= 0) && (monitor < monitorCount))
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
SDL_SetWindowFullscreen(platform.window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
SDL_SetWindowFullscreen(platform.window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||||
@ -836,11 +833,10 @@ void SetWindowPosition(int x, int y)
|
|||||||
// Set monitor for the current window
|
// Set monitor for the current window
|
||||||
void SetWindowMonitor(int monitor)
|
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 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
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
||||||
#else
|
#else
|
||||||
if ((monitor >= 0) && (monitor < monitorCount))
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// NOTE 1: SDL started supporting moving exclusive fullscreen windows between displays on SDL3,
|
// NOTE 1: SDL started supporting moving exclusive fullscreen windows between displays on SDL3,
|
||||||
@ -960,17 +956,13 @@ void *GetWindowHandle(void)
|
|||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
handle = (void *)SDL_GetPointerProperty(props, SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, NULL); // Type: NSWindow*
|
handle = (void *)SDL_GetPointerProperty(props, SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, NULL); // Type: NSWindow*
|
||||||
#endif
|
#endif
|
||||||
#elif defined(USING_SDL2_PROJECT) && !defined(__linux__)
|
#elif defined(USING_SDL2_PROJECT)
|
||||||
// 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
|
|
||||||
SDL_SysWMinfo wmInfo = { 0 };
|
SDL_SysWMinfo wmInfo = { 0 };
|
||||||
SDL_VERSION(&wmInfo.version);
|
SDL_VERSION(&wmInfo.version);
|
||||||
if (SDL_GetWindowWMInfo(platform.window, &wmInfo))
|
if (SDL_GetWindowWMInfo(platform.window, &wmInfo))
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
handle = (void *)wmInfo.info.win.window; // Type: HWND
|
handle = (void *)wmInfo.info.win.window; // Type: HWND
|
||||||
/*
|
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
if (wmInfo.subsystem == SDL_SYSWM_X11)
|
if (wmInfo.subsystem == SDL_SYSWM_X11)
|
||||||
{
|
{
|
||||||
@ -984,7 +976,6 @@ void *GetWindowHandle(void)
|
|||||||
// NOTE: Alternative: wmInfo.info.wl.display
|
// NOTE: Alternative: wmInfo.info.wl.display
|
||||||
handle = (void *)wmInfo.info.wl.surface; // Type: struct wl_surface*
|
handle = (void *)wmInfo.info.wl.surface; // Type: struct wl_surface*
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
handle = (void *)wmInfo.info.cocoa.window; // Type: NSWindow*
|
handle = (void *)wmInfo.info.cocoa.window; // Type: NSWindow*
|
||||||
#endif
|
#endif
|
||||||
@ -997,32 +988,23 @@ void *GetWindowHandle(void)
|
|||||||
// Get number of monitors
|
// Get number of monitors
|
||||||
int GetMonitorCount(void)
|
int GetMonitorCount(void)
|
||||||
{
|
{
|
||||||
int monitorCount = 0;
|
return SDL_GetNumVideoDisplays();
|
||||||
|
|
||||||
monitorCount = SDL_GetNumVideoDisplays();
|
|
||||||
|
|
||||||
return monitorCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get current monitor where window is placed
|
// Get current monitor where window is placed
|
||||||
int GetCurrentMonitor(void)
|
int GetCurrentMonitor(void)
|
||||||
{
|
{
|
||||||
int currentMonitor = 0;
|
|
||||||
|
|
||||||
// Be aware that this returns an ID in SDL3 and a Index in SDL2
|
// Be aware that this returns an ID in SDL3 and a Index in SDL2
|
||||||
currentMonitor = SDL_GetWindowDisplayIndex(platform.window);
|
return SDL_GetWindowDisplayIndex(platform.window);
|
||||||
|
|
||||||
return currentMonitor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get selected monitor position
|
// Get selected monitor position
|
||||||
Vector2 GetMonitorPosition(int monitor)
|
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 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
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
||||||
#else
|
#else
|
||||||
if ((monitor >= 0) && (monitor < monitorCount))
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
SDL_Rect displayBounds;
|
SDL_Rect displayBounds;
|
||||||
@ -1046,11 +1028,10 @@ int GetMonitorWidth(int monitor)
|
|||||||
{
|
{
|
||||||
int width = 0;
|
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 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
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
||||||
#else
|
#else
|
||||||
if ((monitor >= 0) && (monitor < monitorCount))
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
SDL_DisplayMode mode;
|
SDL_DisplayMode mode;
|
||||||
@ -1067,11 +1048,10 @@ int GetMonitorHeight(int monitor)
|
|||||||
{
|
{
|
||||||
int height = 0;
|
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 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
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
||||||
#else
|
#else
|
||||||
if ((monitor >= 0) && (monitor < monitorCount))
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
SDL_DisplayMode mode;
|
SDL_DisplayMode mode;
|
||||||
@ -1088,11 +1068,10 @@ int GetMonitorPhysicalWidth(int monitor)
|
|||||||
{
|
{
|
||||||
int width = 0;
|
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 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
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
||||||
#else
|
#else
|
||||||
if ((monitor >= 0) && (monitor < monitorCount))
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
float ddpi = 0.0f;
|
float ddpi = 0.0f;
|
||||||
@ -1112,11 +1091,10 @@ int GetMonitorPhysicalHeight(int monitor)
|
|||||||
{
|
{
|
||||||
int height = 0;
|
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 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
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
||||||
#else
|
#else
|
||||||
if ((monitor >= 0) && (monitor < monitorCount))
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
float ddpi = 0.0f;
|
float ddpi = 0.0f;
|
||||||
@ -1136,11 +1114,10 @@ int GetMonitorRefreshRate(int monitor)
|
|||||||
{
|
{
|
||||||
int refresh = 0;
|
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 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
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
||||||
#else
|
#else
|
||||||
if ((monitor >= 0) && (monitor < monitorCount))
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
SDL_DisplayMode mode;
|
SDL_DisplayMode mode;
|
||||||
@ -1155,12 +1132,10 @@ int GetMonitorRefreshRate(int monitor)
|
|||||||
// Get the human-readable, UTF-8 encoded name of the selected monitor
|
// Get the human-readable, UTF-8 encoded name of the selected monitor
|
||||||
const char *GetMonitorName(int 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 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
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
||||||
#else
|
#else
|
||||||
if ((monitor >= 0) && (monitor < monitorCount))
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
return SDL_GetDisplayName(monitor);
|
return SDL_GetDisplayName(monitor);
|
||||||
|
|||||||
12
src/rtext.c
12
src/rtext.c
@ -417,9 +417,6 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
|
|||||||
int charSpacing = 0;
|
int charSpacing = 0;
|
||||||
int lineSpacing = 0;
|
int lineSpacing = 0;
|
||||||
|
|
||||||
int x = 0;
|
|
||||||
int y = 0;
|
|
||||||
|
|
||||||
// Allocate a temporal arrays for glyphs data measures,
|
// Allocate a temporal arrays for glyphs data measures,
|
||||||
// once the actual number of glyphs is obtained, copy data to a sized array
|
// once the actual number of glyphs is obtained, copy data to a sized array
|
||||||
int tempCharValues[MAX_GLYPHS_FROM_IMAGE] = { 0 };
|
int tempCharValues[MAX_GLYPHS_FROM_IMAGE] = { 0 };
|
||||||
@ -428,6 +425,8 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
|
|||||||
Color *pixels = LoadImageColors(image);
|
Color *pixels = LoadImageColors(image);
|
||||||
|
|
||||||
// Parse image data to get charSpacing and lineSpacing
|
// Parse image data to get charSpacing and lineSpacing
|
||||||
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
for (y = 0; y < image.height; y++)
|
for (y = 0; y < image.height; y++)
|
||||||
{
|
{
|
||||||
for (x = 0; x < image.width; x++)
|
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 (!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;
|
charSpacing = x;
|
||||||
lineSpacing = y;
|
lineSpacing = y;
|
||||||
|
|||||||
Reference in New Issue
Block a user