[Fixed] StatusBarCore::DrawString doesn't scale correctly

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

StatusBarCore::DrawString doesn't scale correctly

Postby arookas » Sun Oct 24, 2021 4:01 pm

The scale parameter of the ZScript function StatusBarCore::DrawString doesn't work correctly:

  • Spaces are not scaled when rendering, but are scaled when measuring for alignment. Most right- or center- aligned text will not align correctly.
  • The horizontal shifting to the draws makes all glyphs render to the left (as well as each be less wide). This can be mostly worked around by setting the left offset of each glyph's image to -1.

In my specific scenario, all scale factors are integral (1x, 2x, 3x, or 4x only) so it would be nice if text rendered consistently for the larger scales as it does for 1x.
Included is an example with a test statusbar and test room for a clearer background:

You do not have the required permissions to view the files attached to this post.
User avatar
arookas
...but only sometimes.
 
Joined: 24 Jan 2011

Re: StatusBarCore::DrawString doesn't scale correctly

Postby Player701 » Tue Nov 23, 2021 5:52 am

I was the one who originally authored the PR to implement the scaling feature for DrawString, so I've looked into this and applied some fixes. Your example now looks like this to me:



The overlapping of texts is because the strings on the left are now longer (the shifting issue has been fixed). Please tell me if this looks OK, and I'll submit a PR with the fixes then.
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: StatusBarCore::DrawString doesn't scale correctly

Postby arookas » Tue Nov 23, 2021 11:23 pm

It looks to be improved, but it's unfortunately hard to tell with the filter enabled on the text.

The lengths appear to be correct, but the right-aligned scaled text overlaps the red line by one pixel. There is an offset font and non-offset font in the files, the former having an offset X of -1 on each glyph's texture. In theory, this offset should offset the text rendering over to the right by one pixel (multiplied by the draw scale) and should not affect the width of the glyphs. On the unscaled text, you can see the offset font and non-offset font start on the same column despite this. On the right-aligned scaled text, this is likely the cause of the overlap, but it's strange that the offset isn't scaled with the scale parameter.

Unrelated to this, when making this demo I noticed DI_ITEM_* flags do not actually change where the text renders and it is always anchored on the top-left (as you can see with the yellow squares).
User avatar
arookas
...but only sometimes.
 
Joined: 24 Jan 2011

Re: StatusBarCore::DrawString doesn't scale correctly

Postby Player701 » Wed Nov 24, 2021 12:35 am

arookas wrote:The lengths appear to be correct, but the right-aligned scaled text overlaps the red line by one pixel.

Fixed this, see screenshot below. Filters off.



arookas wrote:On the unscaled text, you can see the offset font and non-offset font start on the same column despite this.

If offsets do not work with unscaled text, then this is definitely an unrelated issue. I will see what I can do though.

arookas wrote:Unrelated to this, when making this demo I noticed DI_ITEM_* flags do not actually change where the text renders and it is always anchored on the top-left (as you can see with the yellow squares).

There is no code in the current implementation that checks for these flags, so this is probably an unimplemented feature.
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: StatusBarCore::DrawString doesn't scale correctly

Postby arookas » Thu Nov 25, 2021 7:10 am

That looks fixed to me. Thanks!

Player701 wrote:If offsets do not work with unscaled text, then this is definitely an unrelated issue. I will see what I can do though.

Fortunately, if this fix were implemented I would no longer need the offset. This and the anchor flags could be saved for a separate feature request.
User avatar
arookas
...but only sometimes.
 
Joined: 24 Jan 2011

Re: StatusBarCore::DrawString doesn't scale correctly

Postby Player701 » Thu Nov 25, 2021 7:20 am

PR here, calling in the dev team to comment and/or suggest other fixes if necessary.
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 0 guests