Author Topic: LineSpacing feature (bug in GUI Editor)  (Read 544 times)

LineSpacing feature (bug in GUI Editor)
« on: 26 Apr 2018, 02:08 »
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.

Re: LineSpacing feature (bug in GUI Editor)
« Reply #1 on: 26 Apr 2018, 20:39 »
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

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: LineSpacing feature (bug in GUI Editor)
« Reply #2 on: 26 Apr 2018, 20:44 »
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.
« Last Edit: 26 Apr 2018, 20:49 by Crimson Wizard »

Re: LineSpacing feature (bug in GUI Editor)
« Reply #3 on: 27 Apr 2018, 00:20 »
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

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: LineSpacing feature (bug in GUI Editor)
« Reply #4 on: 27 Apr 2018, 02:59 »
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

  • Rottwheelers
  • When life hands you lemons, combine them with the mop
    • I can help with AGS tutoring
    •  
    • Best Innovation Award Winner 2016, for improving and extending the AGS scripting language
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • Gurok worked on a game that was nominated for an AGS Award!
      Gurok worked on a game that won an AGS Award!
Re: LineSpacing feature (bug in GUI Editor)
« Reply #5 on: 27 Apr 2018, 04:03 »
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.

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: LineSpacing feature (bug in GUI Editor)
« Reply #6 on: 27 Apr 2018, 10:56 »
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.
« Last Edit: 27 Apr 2018, 11:45 by Crimson Wizard »

Re: LineSpacing feature (bug in GUI Editor)
« Reply #7 on: 27 Apr 2018, 11:55 »
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

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: LineSpacing feature (bug in GUI Editor)
« Reply #8 on: 27 Apr 2018, 12:55 »
e.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.
« Last Edit: 27 Apr 2018, 13:18 by Crimson Wizard »

Re: LineSpacing feature (bug in GUI Editor)
« Reply #9 on: 27 Apr 2018, 21:04 »
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

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: LineSpacing feature (bug in GUI Editor)
« Reply #10 on: 12 May 2018, 21: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: C#
  1. Font itemBeingEdited = ((FontEditor)_guiController.ActivePane.Control).ItemToEdit;
  2.  
...but that still does not look very good. Imho this should be passed into this function as an argument.
« Last Edit: 12 May 2018, 21:29 by Crimson Wizard »