LineSpacing feature (bug in GUI Editor)

Started by eri0o, Thu 26/04/2018 02:08:48

Previous topic - Next topic

eri0o

Hey!

I think since AGS 3.4.1 you can set the line spacing in fonts, over properties, inside AGS. It's awesome!

I just found a little bug, when editing a GUI in the editor (multiline label using [ character), the font LineSpacing is not considered for rendering the GUI in the Editor - but will be considered when the game runs in engine!

Just reporting for now.

morganw

I think the only place where game fonts are drawn into the Editor is for GUI's, and because .NET font rendering doesn't have equivalent methods for setting a vertical offset, line spacing, or outline, all of those properties are not considered. To fix it, someone needs to implement an engine-equivalent font renderer, but since the font spacing is slightly different between engine ports, if it exactly matches on one platform it may not match on another. It is probably best in the short term to just add a note to the manual and the interface, that these properties are only implemented by the actual engine.

Crimson Wizard

#2
Quote from: morganw on Thu 26/04/2018 20:39:19
I think the only place where game fonts are drawn into the Editor is for GUI's, and because .NET font rendering doesn't have equivalent methods for setting a vertical offset, line spacing, or outline, all of those properties are not considered.

No, in the Editor GUIs and GUI texts are drawn using native functions from AGS.Native.dll, they are literally same functions as engine uses. Which may not be right thing to do, but that is legacy remains from the 2.72 editor.
I believed that linespacing and vertical offset should be used in the Editor too. Might need to check why they are not. Maybe there is some difference in how font settings are initialized, because Editor uses same native structures internally.

morganw

I think I've mistaken the co-ordinate text being printed, for the actual GUI text. It is calling DrawGUI but I don't think there is anything being set related to fonts before that. I'll take another look tomorrow.

Crimson Wizard

The font settings are stored in a native global "fonts" array there. I have a guess that they are only loaded up at certain points, like when font is created or project loaded up. Because until recently there were no font properties that could be changed.

The true solution is of course to reimplement GUI drawing in .NET. The quick fix would probably require making an "update" function in AGS.Native.dll that would copy font properties over.

Gurok

But CW, plugins can change the way fonts are rendered at runtime. The only true solution (as I see it) is to go the other way -- make it possible to run AGS Script in the context of the editor*. Such a solution would be messy too, IMHO. I just take the editor's rendering of GUIs for what it is. It's a preview that's not perfect and probably never will be.

* I have long thought about this as a solution for AGS "custom controls". Provide a dropdown that allows users to choose the context of a script (editor or game) and have a particular method that controls must implement.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Crimson Wizard

#6
Ok, I don't know what to say. What I said about "true solution" it was just a random thought that came to mind; since there are too many native code in Editor which complicates things, so I mentioned that it should be moved to .NET part.
Doubt anyone was going to do that anyway.

Perfect or not, this preview is only one that exists right now, it has a problem that may be fixed, and not likely there is a reason not to.

morganw

Possibly this was a conscious design decision, as if editing the font property the actual font render isn't updated either. e.g. if you set an outline you don't see the change in the font pane.

Crimson Wizard

#8
Quote from: morganw on Fri 27/04/2018 11:55:49e.g. if you set an outline you don't see the change in the font pane.

Font drawing was actually split into engine and editor variant, with editor's drawing function ignoring outline parameter. Don't know why, maybe they thought was that outline would make it inconvenient to observe font preview?

There were other differences; you may find editor-specific variants of GUI functions in acgui_agsnative.cpp.

morganw

Okay, for my second attempt: in Editor/AGS.Native/agsnative.cpp, when initialize_native() calls new_font(), that function doesn't account for the new font properties.

Crimson Wizard

#10
Did this, but I had to edit many places: https://github.com/adventuregamestudio/ags/commit/8506b71dcc029ddb90c3d9930efce4b88be3f486

Also, there is an annoying thing that I could not find out how to get actual edited item in EditorComponent::PropertyChanged.

Oh:
Code: csharp

Font itemBeingEdited = ((FontEditor)_guiController.ActivePane.Control).ItemToEdit;

...but that still does not look very good. Imho this should be passed into this function as an argument.

SMF spam blocked by CleanTalk