StatusBarCore::DrawString doesn't scale correctly

Is there something that doesn't work right in the latest GZDoom? Post about it here.

Moderator: GZDoom Developers

Forum rules
Please construct and post a simple demo whenever possible for all bug reports. Please provide links to everything.

If you can include a wad demonstrating the problem, please do so. Bug reports that include fully-constructed demos have a much better chance of being investigated in a timely manner than those that don't.

Please make a new topic for every bug. Don't combine multiple bugs into a single topic. Thanks!
User avatar
arookas
Posts: 264
Joined: Mon Jan 24, 2011 6:04 pm
Discord: arookas#8397
Github ID: arookas

StatusBarCore::DrawString doesn't scale correctly

Post by arookas »

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
Player701
 
 
Posts: 1401
Joined: Wed May 13, 2009 3:15 am
Discord: Player701#8214
Graphics Processor: nVidia with Vulkan support
Location: Russia

Re: StatusBarCore::DrawString doesn't scale correctly

Post by Player701 »

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
arookas
Posts: 264
Joined: Mon Jan 24, 2011 6:04 pm
Discord: arookas#8397
Github ID: arookas

Re: StatusBarCore::DrawString doesn't scale correctly

Post by arookas »

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
Player701
 
 
Posts: 1401
Joined: Wed May 13, 2009 3:15 am
Discord: Player701#8214
Graphics Processor: nVidia with Vulkan support
Location: Russia

Re: StatusBarCore::DrawString doesn't scale correctly

Post by Player701 »

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
arookas
Posts: 264
Joined: Mon Jan 24, 2011 6:04 pm
Discord: arookas#8397
Github ID: arookas

Re: StatusBarCore::DrawString doesn't scale correctly

Post by arookas »

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
Player701
 
 
Posts: 1401
Joined: Wed May 13, 2009 3:15 am
Discord: Player701#8214
Graphics Processor: nVidia with Vulkan support
Location: Russia

Re: StatusBarCore::DrawString doesn't scale correctly

Post by Player701 »

PR here, calling in the dev team to comment and/or suggest other fixes if necessary.
Accensus
Posts: 2354
Joined: Thu Feb 11, 2016 9:59 am

Re: StatusBarCore::DrawString doesn't scale correctly

Post by Accensus »

Requesting reopening this. I don't know if it is a regression or not, but running the example on 4.8.2 produces the same results as in the OP's screenshot. Went as far back as 4.8.0 and it's broken in all 3 versions.
User avatar
Player701
 
 
Posts: 1401
Joined: Wed May 13, 2009 3:15 am
Discord: Player701#8214
Graphics Processor: nVidia with Vulkan support
Location: Russia

Re: StatusBarCore::DrawString doesn't scale correctly

Post by Player701 »

Just for the record: I haven't done any more PRs affecting the relevant code since that last one, so if it's indeed broken again, it must be something unrelated. Better start a new thread though (and link back to this one).
User avatar
Rachael
Admin
Posts: 12911
Joined: Tue Jan 13, 2004 1:31 pm
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Preferred Pronouns: She/Her

Re: StatusBarCore::DrawString doesn't scale correctly

Post by Rachael »

I reopened this one - it can always be closed again if that's the best choice of action.
User avatar
Player701
 
 
Posts: 1401
Joined: Wed May 13, 2009 3:15 am
Discord: Player701#8214
Graphics Processor: nVidia with Vulkan support
Location: Russia

Re: StatusBarCore::DrawString doesn't scale correctly

Post by Player701 »

All right, then.
Accensus
Posts: 2354
Joined: Thu Feb 11, 2016 9:59 am

Re: StatusBarCore::DrawString doesn't scale correctly

Post by Accensus »

Seems that this commit reverts it. Possibly by accident from the looks of it.

Return to “Bugs”