1 module bindbc.raylib.bind.text;
2 
3 import bindbc.raylib.types;
4 
5 version (BindRaylib_Static) {
6    extern (C) @nogc nothrow {
7    }
8 } else {
9    extern (C) @nogc nothrow {
10       // Font loading/unloading functions
11       /**
12        * Get the default Font
13        */
14       alias pGetFontDefault = Font function();
15       /**
16        * Load font from file into GPU memory (VRAM)
17        */
18       alias pLoadFont = Font function(const(char)* fileName);
19       /**
20        * Load font from file with extended parameters
21        */
22       alias pLoadFontEx = Font function(const(char)* fileName, int fontSize, int* fontChars, int charsCount);
23       /**
24        * Load font from Image (XNA style)
25        */
26       alias pLoadFontFromImage = Font function(Image image, Color key, int firstChar);
27       /**
28        * Load font data for further use
29        */
30       alias pLoadFontData = CharInfo* function(const(char)* fileName, int fontSize, int* fontChars, int charsCount, int type);
31       /**
32        * Generate image font atlas using chars info
33        */
34       alias pGenImageFontAtlas = Image function(const(CharInfo)* chars, Rectangle** recs, int charsCount, int fontSize,
35             int padding, int packMethod);
36       /**
37        * Unload Font from GPU memory (VRAM)
38        */
39       alias pUnloadFont = void function(Font font);
40 
41       // Text drawing functions
42       /**
43        * Shows current FPS
44        */
45       alias pDrawFPS = void function(int posX, int posY);
46       /**
47        * Draw text (using default font)
48        */
49       alias pDrawText = void function(const(char)* text, int posX, int posY, int fontSize, Color color);
50       /**
51        * Draw text using font and additional parameters
52        */
53       alias pDrawTextEx = void function(Font font, const(char)* text, Vector2 position, float fontSize, float spacing, Color tint);
54       /**
55        * Draw text using font inside rectangle limits
56        */
57       alias pDrawTextRec = void function(Font font, const(char)* text, Rectangle rec, float fontSize, float spacing,
58             bool wordWrap, Color tint);
59       /**
60        * Draw text using font inside rectangle limits with support for text selection
61        */
62       alias pDrawTextRecEx = void function(Font font, const(char)* text, Rectangle rec, float fontSize, float spacing,
63             bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint);
64       /**
65        * Draw one character (codepoint)
66        */
67       alias pDrawTextCodepoint = void function(Font font, int codepoint, Vector2 position, float scale, Color tint);
68 
69       // Text misc. functions
70       /**
71        * Measure string width for default font
72        */
73       alias pMeasureText = int function(const(char)* text, int fontSize);
74       /**
75        * Measure string size for Font
76        */
77       alias pMeasureTextEx = Vector2 function(Font font, const(char)* text, float fontSize, float spacing);
78       /**
79        * Get index position for a unicode character on font
80        */
81       alias pGetGlyphIndex = int function(Font font, int codepoint);
82 
83       // Text strings management functions (no utf8 strings, only byte chars)
84       // NOTE: Some strings allocate memory internally for returned strings, just be careful!
85       /**
86        * Copy one string to another, returns bytes copied
87        */
88       alias pTextCopy = int function(char* dst, const(char)* src);
89       /**
90        * Check if two text string are equal
91        */
92       alias pTextIsEqual = bool function(const(char)* text1, const(char)* text2);
93       /**
94        * Get text length, checks for '\0' ending
95        */
96       alias pTextLength = ushort function(const(char)* text);
97       /**
98        * Text formatting with variables (sprintf style)
99        */
100       alias pTextFormat = const(char)* function(const(char)* text, ...);
101       /**
102        * Get a piece of a text string
103        */
104       alias pTextSubtext = const(char)* function(const(char)* text, int position, int length);
105       /**
106        * Replace text string (memory must be freed!)
107        */
108       alias pTextReplace = char* function(char* text, const(char)* replace, const(char)* by);
109       /**
110        * Insert text in a position (memory must be freed!)
111        */
112       alias pTextInsert = char* function(const(char)* text, const(char)* insert, int position);
113       /**
114        * Join text strings with delimiter
115        */
116       alias pTextJoin = const(char)* function(const(char*)* textList, int count, const(char)* delimiter);
117       /**
118        * Split text into multiple strings
119        */
120       alias pTextSplit = const(char*)* function(const(char)* text, char delimiter, int* count);
121       /**
122        * Append text at specific position and move cursor!
123        */
124       alias pTextAppend = void function(char* text, const(char)* append, int* position);
125       /**
126        * Find first text occurrence within a string
127        */
128       alias pTextFindIndex = int function(const(char)* text, const(char)* find);
129       /**
130        * Get upper case version of provided string
131        */
132       alias pTextToUpper = const(char)* function(const(char)* text);
133       /**
134        * Get lower case version of provided string
135        */
136       alias pTextToLower = const(char)* function(const(char)* text);
137       /**
138        * Get Pascal case notation version of provided string
139        */
140       alias pTextToPascal = const(char)* function(const(char)* text);
141       /**
142        * Get integer value from text (negative values not supported)
143        */
144       alias pTextToInteger = int function(const(char)* text);
145       /**
146        * Encode text codepoint into utf8 text (memory must be freed!)
147        */
148       alias pTextToUtf8 = char* function(int* codepoints, int length);
149 
150       // UTF8 text strings management functions
151       /**
152        * Get all codepoints in a string, codepoints count returned by parameters
153        */
154       alias pGetCodepoints = int* function(const(char)* text, int* count);
155       /**
156        * Get total number of characters (codepoints) in a UTF8 encoded string
157        */
158       alias pGetCodepointsCount = int function(const(char)* text);
159       /**
160        * Returns next codepoint in a UTF8 encoded string; 0x3f('?') is returned on failure
161        */
162       alias pGetNextCodepoint = int function(const(char)* text, int* bytesProcessed);
163       /**
164        * Encode codepoint into utf8 text (char array length returned as parameter)
165        */
166       alias pCodepointToUtf8 = const(char)* function(int codepoint, int* byteLength);
167    }
168 
169    __gshared {
170       pGetFontDefault GetFontDefault;
171       pLoadFont LoadFont;
172       pLoadFontEx LoadFontEx;
173       pLoadFontFromImage LoadFontFromImage;
174       pLoadFontData LoadFontData;
175       pGenImageFontAtlas GenImageFontAtlas;
176       pUnloadFont UnloadFont;
177       pDrawFPS DrawFPS;
178       pDrawText DrawText;
179       pDrawTextEx DrawTextEx;
180       pDrawTextRec DrawTextRec;
181       pDrawTextRecEx DrawTextRecEx;
182       pDrawTextCodepoint DrawTextCodepoint;
183       pMeasureText MeasureText;
184       pMeasureTextEx MeasureTextEx;
185       pGetGlyphIndex GetGlyphIndex;
186       pTextCopy TextCopy;
187       pTextIsEqual TextIsEqual;
188       pTextLength TextLength;
189       pTextFormat TextFormat;
190       pTextSubtext TextSubtext;
191       pTextReplace TextReplace;
192       pTextInsert TextInsert;
193       pTextJoin TextJoin;
194       pTextSplit TextSplit;
195       pTextAppend TextAppend;
196       pTextFindIndex TextFindIndex;
197       pTextToUpper TextToUpper;
198       pTextToLower TextToLower;
199       pTextToPascal TextToPascal;
200       pTextToInteger TextToInteger;
201       pTextToUtf8 TextToUtf8;
202       pGetCodepoints GetCodepoints;
203       pGetCodepointsCount GetCodepointsCount;
204       pGetNextCodepoint GetNextCodepoint;
205       pCodepointToUtf8 CodepointToUtf8;
206    }
207 }