From 345ff1de0720af61e66fb99946817c5c34981b35 Mon Sep 17 00:00:00 2001 From: xolatile Date: Fri, 5 Apr 2024 06:52:11 -0400 Subject: [PATCH] More font functions and C_String function... --- raylib.ads | 102 ++++++++++++++++++++++++++++++++++++++++++------------------- window.adb | 11 +++++-- 2 files changed, 78 insertions(+), 35 deletions(-) diff --git a/raylib.ads b/raylib.ads index c226cda..5def8ce 100644 --- a/raylib.ads +++ b/raylib.ads @@ -3065,40 +3065,75 @@ package Raylib is Convention => C, External_Name => "LoadFont"; - --~function Font LoadFontEx (const char *fileName, int fontSize, int *codepoints, int codepointCount) with - --~Import => True, - --~Convention => C, - --~External_Name => ""; + function Load_Font_Ex ( + File_Name : String := ""; + Font_Size : Integer := 32; + Code_Points : access Integer := null; + Code_Point_Count : Natural := 0 + ) return Font with + Import => True, + Convention => C, + External_Name => "LoadFontEx"; - --~function Font LoadFontFromImage (Image image, Color key, int firstChar) with - --~Import => True, - --~Convention => C, - --~External_Name => ""; + function Load_Font_From_Image ( + Data : Image := No_Image; + Key : Color := White; + First_Character : Integer := 0 + ) return Font with + Import => True, + Convention => C, + External_Name => "LoadFontFromImage"; - --~function Font LoadFontFromMemory (const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount) with - --~Import => True, - --~Convention => C, - --~External_Name => ""; + function Load_Font_From_Memory ( + File_Type : String := ""; + File_Data : Pointer := null; + Data_Size : Natural := 0; + Font_Size : Integer := 32; + Code_Points : access Integer := null; + Code_Point_Count : Natural := 0 + ) return Font with + Import => True, + Convention => C, + External_Name => "LoadFontFromMemory"; - --~function bool IsFontReady (Font font) with - --~Import => True, - --~Convention => C, - --~External_Name => ""; + function Is_Font_Ready ( + Data : Font := No_Font + ) return Logical with + Import => True, + Convention => C, + External_Name => "IsFontReady"; - --~function GlyphInfo *LoadFontData (const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount, int type) with - --~Import => True, - --~Convention => C, - --~External_Name => ""; + function Load_Font_Data ( + File_Data : Pointer := null; + Data_Size : Natural := 0; + Font_Size : Integer := 32; + Code_Points : access Integer := null; + Code_Point_Count : Natural := 0; + Kind : Integer := 0 + ) return access Glyph_Info with + Import => True, + Convention => C, + External_Name => "LoadFontData"; - --~function Image GenImageFontAtlas (const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyphCount, int fontSize, int padding, int packMethod) with - --~Import => True, - --~Convention => C, - --~External_Name => ""; + function Gen_Image_Font_Atlas ( + Glyphs : access Glyph_Info := null; + Glyph_Rectangles : access Rectangle := null; + Glyph_Count : Integer := 0; + Font_Size : Integer := 32; + Padding : Integer := 0; + Pack_Method : Integer := 0 + ) return Image with + Import => True, + Convention => C, + External_Name => "GenImageFontAtlas"; - --~procedure UnloadFontData (GlyphInfo *glyphs, int glyphCount) with - --~Import => True, - --~Convention => C, - --~External_Name => ""; + procedure Unload_Font_Data ( + Glyphs : access Glyph_Info := null; + Glyph_Count : Integer := 0 + ) with + Import => True, + Convention => C, + External_Name => "UnloadFontData"; procedure Unload_Font ( Data : Font := No_Font @@ -3107,10 +3142,13 @@ package Raylib is Convention => C, External_Name => "UnloadFont"; - --~function bool ExportFontAsCode (Font font, const char *fileName) with - --~Import => True, - --~Convention => C, - --~External_Name => ""; + function Export_Font_As_Code ( + Data : Font := No_Font; + File_Name : String := "" + ) return Logical with + Import => True, + Convention => C, + External_Name => "ExportFontAsCode"; procedure Draw_FPS ( X : Integer := 0; diff --git a/window.adb b/window.adb index f6b8086..0afc910 100644 --- a/window.adb +++ b/window.adb @@ -3,7 +3,12 @@ use Raylib; procedure Window is - Text : String := "Heyo world!" & Character'Val (0); + function C_String (Data : String) return String is + begin + return (Data & Character'Val (0)); + end C_String; + + Text : String := C_String ("Heyo world!"); Dragdown : Texture; @@ -12,12 +17,12 @@ procedure Window is begin - Open_Window (720, 360, "Heyo Raylib!" & Character'Val (0)); + Open_Window (720, 360, C_String ("Heyo Raylib!")); Set_Exit_Key (Key_Q); -- Default is Key_Escape Set_Target_FPS (72); -- Default is 60 - Dragdown := Load_Texture ("./texture.png" & Character'Val (0)); + Dragdown := Load_Texture (C_String ("./texture.png")); Main_Loop: loop exit when Window_Should_Close;