Adventure Game Studio | Forums

AGS Development => Editor Development => Topic started by: eri0o on Thu 26/04/2018 02:08:48

Title: LineSpacing feature (bug in GUI Editor)
Post by: eri0o on Thu 26/04/2018 02:08:48
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.
Title: Re: LineSpacing feature (bug in GUI Editor)
Post by: 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. 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.
Title: Re: LineSpacing feature (bug in GUI Editor)
Post by: Crimson Wizard on Thu 26/04/2018 20:44:16
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.
Title: Re: LineSpacing feature (bug in GUI Editor)
Post by: morganw on Fri 27/04/2018 00:20:52
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.
Title: Re: LineSpacing feature (bug in GUI Editor)
Post by: Crimson Wizard on Fri 27/04/2018 02:59:50
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.
Title: Re: LineSpacing feature (bug in GUI Editor)
Post by: Gurok on Fri 27/04/2018 04:03:06
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.
Title: Re: LineSpacing feature (bug in GUI Editor)
Post by: Crimson Wizard on Fri 27/04/2018 10:56:09
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.
Title: Re: LineSpacing feature (bug in GUI Editor)
Post by: morganw on Fri 27/04/2018 11:55:49
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.
Title: Re: LineSpacing feature (bug in GUI Editor)
Post by: Crimson Wizard on Fri 27/04/2018 12:55:37
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.
Title: Re: LineSpacing feature (bug in GUI Editor)
Post by: morganw on Fri 27/04/2018 21:04:40
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.
Title: Re: LineSpacing feature (bug in GUI Editor)
Post by: Crimson Wizard on Sat 12/05/2018 21:23:23
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) Select

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.