• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Why is there not a font_get_range?

Evanski

Raccoon Lord
Forum Staff
Moderator
Why is there not a function that gets the available range of a font?
For example,
you have a font (fnt_arial), with a range of 65 - 68
so the available characters from the font is A,B,C,D

Now imagine your making a user text input system or just want to see if a font has the character in it
So you would use:
Code:
font_get_range(fnt_arial,65);
and what that would do is return true or false if that font has that character in it.
Now you can do something like this:
Code:
if ( font_get_range(fnt_arial,65) )
{
    key_available = true;
}
else
{
    key_available = false;
    show_messsage("The requested Character is not available in this font.");
}
To go more into this:
Description: This function will get the range of characters in the applied font.
Syntax: font_get_range(font,character)
Argument | Description
font | The ID or name of the font to get the range of
character | (Optional) The character to look for in the supplied font.

Returns: Boolean
Example:
Code:
font_get_range(font,65);
The above code will return true or false if "A" is in the character range of the font.

there should also be a way to just type
Code:
font_get_range(font,A);
and the A returned into the correct number relating to A in the font range (65)
 
Last edited:

XanthorXIII

Member
Can you provide a specific use Case for why this would be needed? I guess outside of checking with other languages I’m not sure how useful this would be.
 

Evanski

Raccoon Lord
Forum Staff
Moderator
Can you provide a specific use Case for why this would be needed? I guess outside of checking with other languages I’m not sure how useful this would be.
Well like with a user text system, you would need to define which keys are allowed to be typed and which are not, so It would be easier to just get the characters from the font and use that as the allowed keys, rather then trying to define them all separately. Also it can be used for the same reason but for defining which keys can have controls set to them, Any case where you need to define a set of allowed keys/ or needing to see if a font has that character, this would be useful and a time saver
 

Gamebot

Member
Have them set their own keys using a global:
global.keys = "ABCDEFGHIJKLMNOPQRSTUVWXYZaabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*():<>?' "

Or use a sprite(s) and have them define which ones can be used. You would simply check with an array if that image is available. You could get fancy and set each charater to its ascii picture...so space " " would be image 32...

Also keyboard_string, keyboard_lastchar, keyboard_lastkey will act differently...
 

Evanski

Raccoon Lord
Forum Staff
Moderator
Have them set their own keys using a global:
global.keys = "ABCDEFGHIJKLMNOPQRSTUVWXYZaabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*():<>?' "

Or use a sprite(s) and have them define which ones can be used. You would simply check with an array if that image is available. You could get fancy and set each charater to its ascii picture...so space " " would be image 32...

Also keyboard_string, keyboard_lastchar, keyboard_lastkey will act differently...
I came up with sort of a way to do my function but yeah i tried that but the symbols wouldnt work and using sprites takes up memory and game assets and just more hassel then its worth

I just stuck with using keyboard_key and keyboard_lastchar to get the keycode and set which keycodes are allowed to be typed
 
Top