• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code font_add_sprite_ext HELP

Ednei

Member
Colleagues, I'm trying to improve the fonts of my project to make reading on mobile devices easier.

I'm using the font_add_sprite_ext function to create fonts based on sprites.

screen 1.png screen 2.png

I am using this function as follows:

Code:
font_main = font_add_sprite_ext(spWIN_Text2,"!#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÁÀÂÃáàãâÇçÉÊÍíÓÔÕóôõÚúéê",true,0)
The function has this syntax:

Font_add_sprite_ext (spr, string_map, prop, sep);

I can reduce the space between letters. But I would like to know how I can reduce the space between words.

As you can see in the screenshot, the spaces between the words are too large.

Does anyone know how to do this?

If there is no such possibility I leave here my suggestion to add an argument for this purpose.

Thanks

Ednei
 

Desix

Member
Add an image in the text sprite for the space, and give it the desired space width (as if it were a letter). It wont be drawn, but it'll be used for the space size.

Don't forget to add the space into the font_add function string too.


(I'm not 100% with GMS 2 here, but I don't see why it wouldn't still work)
 

Ednei

Member
Add an image in the text sprite for the space, and give it the desired space width (as if it were a letter). It wont be drawn, but it'll be used for the space size.

Don't forget to add the space into the font_add function string too.


(I'm not 100% with GMS 2 here, but I don't see why it wouldn't still work)


screen 4.png

Thanks for the tip!

It's working properly on GM2.

I think the manual tried to explain this to me but I did not understand.

Personally I think I should be adding an argument in the original syntax to allow for the fit between the words. Like for example:

Font_add_sprite_ext (spr, string_map, prop, sep, words_sep);

Words_sep (space between words)

Anyway the problem has been solved.

Thank you.
 

Mike

nobody important
GMC Elder
Word separation isn't a "thing". What if I have numbers with spaces? or even words then a space between brackets or something. Its the space that's important,not that space between words. So that's not going to change
 

Ednei

Member
Word separation isn't a "thing". What if I have numbers with spaces? or even words then a space between brackets or something. Its the space that's important,not that space between words. So that's not going to change
I understood you explanation.

I guess I did not express myself correctly. (my native language is Portuguese).

What I meant is that there could be an argument that defines the amount of pixels between groups of characters (not just words).

For me it would be a more elegant solution than adding a sprite that represents space in string_map.

It would be another option to adjust the text (through code) on different devices.

Well, the most important thing is that the function is working. I'm already satisfied with the result.

Thank you.
 

gnysek

Member
Nah, you define space size as one of images, so if you forget to add it, it will be some internal default value. Better than no space at all! :)
 

LtCoyote

Member
Hey folks,

Just a reminder, so maybe noone else runs into this problem I did (and it may be a noob thing, but hey, who knows, it may help someone :)):
So, should you set up your graphical font(s) like this, it's works nice and dandy, until you set your Automatically Crop checkbox off in Tools - Texture Groups.
Why would I do that? So I implemented an outline shader on my character, and that sprite needs this checkbox off, so the outline won't be cropped at the sides.
Solution: this sprites should go on a new texture group where you can turn off Automatically Crop.
The effect for me was I realized my font doesn't work properly, too wide space, thin letters have too wide gaps between them. I'm too tired so I didn't connected this to the outline shader, and I actually thought the checkbox works only on the selected image. :)
 

Mike

nobody important
GMC Elder
Cropping on sprite fonts makes no difference, its the shader that's affecting this - and it's the same for anything you put through a shader. You can not assume UV coordinates, or even scale of image sizes when something is cropped. You can get UVs and sizes from GM if you want, or you can switch off cropping.

But cropping has no effect on "normal" text rendering, only shaders, and that depends what you're doing.
 
Top