AGS 4.0 - Alpha 22 for public test

Started by Crimson Wizard, Thu 01/06/2023 14:00:59

Previous topic - Next topic

Baguettator

Quote from: Crimson Wizard on Thu 17/07/2025 17:45:51In the latest AGS 4 you can import only 1 font file and create any number of fonts from it, each with different settings. Is that what you are referring to?

Well I was thinking about :

- importing a font file
- create a button
- give this button the font you just imported
- choose the size of the font for THIS button (and eventually its style if possible)
- allow to manipulate font's property for each button or things using texts (labels etc...), such as the font's size, dynamically in scripts. My best example for it is about translations : if you have a button with the text "ABCD" inside, and when you change translation the texts becomes "ABCDEFGHIJ", the button could be too small to have the text properly inside, so you could just change the font's size to fit the text there.

Crimson Wizard

#381
Quote from: Baguettator on Yesterday at 22:29:41Well I was thinking about :

- importing a font file
- create a button
- give this button the font you just imported
- choose the size of the font for THIS button (and eventually its style if possible)
- allow to manipulate font's property for each button or things using texts (labels etc...), such as the font's size, dynamically in scripts. My best example for it is about translations : if you have a button with the text "ABCD" inside, and when you change translation the texts becomes "ABCDEFGHIJ", the button could be too small to have the text properly inside, so you could just change the font's size to fit the text there.

Giving each control additional font settings will be suboptimal IMO, not only because that's going to be an extra hassle to configure font on each control, but also because the font renderers must cache the glyphs (letters) in each separate size and style (they don't load font once and then display resized, they actually precreate letters in each size). If there will be a setting for each button, label, etc, that may give users an idea that they may ignore the number of font variants, and they will eventually boost the amount of cached fonts. So I'd rather not do that.

I'd rather keep a single "Font" property on things, and have all settings in a Font object. You can already have any number of Fonts from a single file in AGS 4, where you import a font file once, and create any number of font variants from that font file. We may have a "style" added later as well, if we support attaching multiple style font files as a single "font file source".

This leaves a translation problem, and ability to create Font objects at runtime, either as a command in script, or an instruction in the translation file. That's something that has to be developed from ground up, as right now there's no font structure in script at all, nor a collection of fonts that one could iterate, only numbers. But that should be feasible in theory.

Baguettator

OK I understand ! I thought Fonts were scaled according to their size, the glyphs being vectorized. I was wrong !

So perhaps I can try something in my script as a workaround :

- create an enum with all iteration of one font (so TimeNewRomans 10, TimeNewRomans 15, TimeNewRomans 20 etc... for example), from the smallest to the biggest

- change the translation

- verify each button/label/whatever that has text inside : while text.Width > object's size, object.font-- (using the enum) OR while text.Width < my_minimum_I_defined, object.font++

It could take some time to proceed, but could work I presume.

Another thing I just thought about : possibility for buttons having their text displayed on several lines (same way as labels) ?

SMF spam blocked by CleanTalk