Add support for monospacing alignment modes to HUDFont

Moderator: GZDoom Developers

Post Reply
User avatar
Player701
 
 
Posts: 1640
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Add support for monospacing alignment modes to HUDFont

Post by Player701 »

With this commit, it became possible to pass monospacing parameters to Screen.DrawText. This includes the character alignment mode (left, center, or right). However, this is not yet supported by HUDFont. It appears that it always uses left alignment, as seen on this picture:



HUDFont should probably support these alignment modes as well.

Attached is an example WAD with the code to draw the strings as seen on the picture above. Enable fullscreen HUD to see them.
Attachments
hud_test.wad
(1.28 KiB) Downloaded 41 times
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Add support for monospacing alignment modes to HUDFont

Post by Graf Zahl »

The text printing code in the status bar really needs to be consolidated with the main printing function, but since this is a bigger piece of work I was planning to postpone this until after the next release.
User avatar
Player701
 
 
Posts: 1640
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Add support for monospacing alignment modes to HUDFont

Post by Player701 »

Well, if this gets added, it will allow me to get rid of the hack where I break the string down to invidual characters and print them separately. This part of code is HUD-related, so I can't use DrawText for that (since all other code there uses HUDFont and its parameters, so I would have to break the abstraction really badly). It seems that at least it is possible to change the type of the corresponding argument in HUDFont.Create from bool to EMonospacing and it won't break any existing code, because falsy values will translate to 0 (Mono_Off) and truthy values will translate to 1 (Mono_CellLeft).

Upd: So I've made a PR to implement the necessary changes. Everything seems to work fine, here's an updated test WAD and screenshot as proof:



The top 3 rows are rendered with Screen.DrawText, the bottom 3 with DrawString using different monospacing modes. The result is the same.
Attachments
hud_test.wad
(1.28 KiB) Downloaded 39 times
User avatar
Player701
 
 
Posts: 1640
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Add support for monospacing alignment modes to HUDFont

Post by Player701 »

The PR has been merged, I guess this can be closed?
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”