Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect text position in menu [ImGUI] #77297

Closed
LeSHi4 opened this issue Oct 24, 2024 · 17 comments · Fixed by #76513
Closed

Incorrect text position in menu [ImGUI] #77297

LeSHi4 opened this issue Oct 24, 2024 · 17 comments · Fixed by #76513
Labels
ImGui Anything related to the new ImGui UI for SDL/tiles or ImTui for curses builds (P2 - High) High priority (for ex. important bugfixes) (S2 - Confirmed) Bug that's been confirmed to exist SDL: Tiles / Sound Tiles visual interface and sounds.

Comments

@LeSHi4
Copy link

LeSHi4 commented Oct 24, 2024

Describe the bug

I open item description and text trying to hide for me.
I try to make fully clean game without old saves and config files and have same situation.

Attach save file

N/A

Steps to reproduce

  1. Start the game
  2. Open inventory (i)
  3. (e) Open item description

Expected behavior

Can read and text not trying to escape :)

Screenshots

info 1
info 2
info 3
info 4

Versions and configuration

Windows 10 24H2
cdda-experemental-2024-10-24-1253 2d90bfe
English, Russian
Default mod configuration

Additional context

No response

@LeSHi4 LeSHi4 added the (S1 - Need confirmation) Report waiting on confirmation of reproducibility label Oct 24, 2024
@LeSHi4 LeSHi4 changed the title Incorrect text in menu [ImGUI] Incorrect text position in menu [ImGUI] Oct 24, 2024
@mqrause
Copy link
Contributor

mqrause commented Oct 24, 2024

Only gave it a cursory glance, but it looks like #76529 changed it so the font is set only after the wrap width is calculated. That means it's calculated for the wrong font and thus wrapping in the wrong place.

@Termineitor244
Copy link
Contributor

imagen

/confirmed for me, also...

imagen

The action menu in the item view of the inventory is invisible

@github-actions github-actions bot added (S2 - Confirmed) Bug that's been confirmed to exist and removed (S1 - Need confirmation) Report waiting on confirmation of reproducibility labels Oct 24, 2024
@yamil-90
Copy link

a lot of the text boxes look off
the gravestone that appears when your character dies got all messed up since it was ascii art
image

when studying or doing some long activity the boxes also are not rendered properly
image

@ampersand55
Copy link
Contributor

A temporary fix is to switch ImGui font to terminus.

https://old.reddit.com/r/cataclysmdda/comments/1gdgwyx/guide_how_to_fix_item_descriptions_menu_being_cut/

@NetSysFire NetSysFire added (P2 - High) High priority (for ex. important bugfixes) SDL: Tiles / Sound Tiles visual interface and sounds. ImGui Anything related to the new ImGui UI for SDL/tiles or ImTui for curses builds labels Oct 28, 2024
@NetSysFire NetSysFire pinned this issue Oct 28, 2024
@db48x
Copy link
Contributor

db48x commented Oct 31, 2024

#76513 fixes the wrapping. Fixing the gravestone will be easy enough; we have a monospaced font for just that purpose.

db48x added a commit to db48x/Cataclysm-DDA that referenced this issue Oct 31, 2024
because ascii art. Also, vertically align the “Last Words:” label in
front of the textbox, so that the baselines of the two are lined up.

Partially fixes CleverRaven#77297
@Abalieno
Copy link
Contributor

Abalieno commented Nov 2, 2024

While I personally dislike the move to ImGui, at the very least it needs a load option to set the font size.

It uses the same font size of the standard font for the ImGui font, that in almost all cases produces very blurry and very badly scaled fonts in all ImGui panels.

This is especially a mess because the main game takes bitmap fonts that aren't easily converted to truetype fonts. And truetype fonts look terrible without a very precise scaling that matches the bitmap.

@db48x
Copy link
Contributor

db48x commented Nov 2, 2024

that in almost all cases produces very blurry and very badly scaled fonts in all ImGui panels.

I don’t think that’s true. If it is, file a bug report of your own and show us your configuration, screenshots, etc.

@ampersand55
Copy link
Contributor

ampersand55 commented Nov 2, 2024

This is especially a mess because the main game takes bitmap fonts that aren't easily converted to truetype fonts. And truetype fonts look terrible without a very precise scaling that matches the bitmap.

Scaling issues might be fixed by setting font blending to true in Settings > Graphics > font settings and restart the game.

It's set to false by default for some reason.

@Abalieno
Copy link
Contributor

Abalieno commented Nov 2, 2024

I don't think font blending affects ImGui, and I had it disabled anyway.

This is a quick test. Take for example an "official" screenshot from here: https://github.com/ocornut/imgui/blob/master/docs/FONTS.md

prog1

As you can see it's very sharp, and it's loaded at size 13. Since it's monospace and looking fine, I decided to try it on Cataclysm.

This is how the same font looks in Cataclysm (name of the font is different, but the source is the same, I just changed the name to switch faster configs):

tujuk

But it's the same even for the currently embedded fonts. This is is using Unifont:

ykyik

And it is indeed crisp. But if you change the size...

yukyukr

At size 18 it exhibits some corruption.

As I said, truetype fonts will only look fine at certain sizes, there needs to be a way to be able to give them a size different from the main game font, since the two follow different rules.

As a confirmation to what I'm saying, this is the same font that looks blurry above, in the same Cataclysm version:

yilil

The reason why this looks crisp is because this font is built for size 13, if you change it, it becomes a mess. But if I wanted to use it in Cataclysm, I cannot. Because I use a different font size, and there's no way to customize the two to what they need to be to look readable.

@ampersand55
Copy link
Contributor

I think that's an issue with the version of unifont shipped with the game (v.12). I get the same bad rendering at 18px even in other applications.

I get a better result with (OpenType unifont v16 ).

Truetype unifont v12:

image

Opentype unifont v16:

image

@db48x
Copy link
Contributor

db48x commented Nov 2, 2024

Two things: file a separate bug report for font stuff, because it has nothing to do with this bug!

Secondly, you should not care how unifont looks. The goal of unifont is to have a glyph for every character in Unicode, not for the glyphs to look good. It doesn’t have hinting tables, or ligatures, or shaping tables, or anything. Just one glyph per character. It is only intended as a fallback.

You should pick a font that you actually like at your chosen font size. We can add more control over size, hinting, anti–aliasing, and so on at a later date, but fundamentally you just need to pick a nicer font.

@Abalieno
Copy link
Contributor

Abalieno commented Nov 3, 2024

No, it's not related to the font. Different fonts, depending on how they are originally built, look well at their native resolution and poorly when scaled. I made the example using ProggyFont (and as you can see opentype at size 16 already looks blurred, look at those s, l and w, that's hideous).

And yes, I COULD pick a font I actually like at the size I need, or just load the font at the size I need, which was the original request that makes the most logical sense.

But if you can find a monospace font that is rendered correctly at size 16, then tell me. I spent a few hours without luck.

Using a non monospace font for a grid-based UI is not going to work unless you really enjoy having everything misaligned.

en2en1

See the t of throw or r of reload all shoved to the left of that column of shortcuts. You either have a sensible eye to the correctness of good UI design and alignment or not. Some people I guess won't even notice.

But I think everyone at a glance will agree that the first example looks a lot better and is easier to read. Beside the second example (default) also taking more screen space for doing a worse job, which will be a very big problem once you do the same treatment to the sidebar and other panels where vertical space is precious.

Before you ask, I did try converting and loading the same font. I wasn't quite successful.

uykyk

I hope we can agree this needs a better solution.

@db48x
Copy link
Contributor

db48x commented Nov 3, 2024

Different fonts, depending on how they are originally built, look well at their native resolution and poorly when scaled.

This is simply not true. TrueType fonts are vector fonts, and will look just as good at any size (above a sensible minimum font size; nothing looks good when 2px high). If the font you’re using doesn’t look good at 16px or whatever, then choose a different one.

Using a non monospace font for a grid-based UI

We’re not doing that. The ASCII art remains monospaced. We can right–align that column of shortcuts if you want, or use monospace for that column. Or we can challenge ourselves to think of an even better UI.

@Abalieno
Copy link
Contributor

Abalieno commented Nov 3, 2024

If the font you’re using doesn’t look good at 16px or whatever, then choose a different one.

Before replying to this issue I already had spent a few hours trying to find a solution. I tried more than 20 fonts. I tried converting fonts, I tried editing them in FontForge.

As I said, if you have a monospace font that looks good at size 16, then I gladly accepts suggestions.

But if I can, I'd rather use the same good looking font everywhere, as long I can load the correct size.

@0xToast
Copy link

0xToast commented Nov 4, 2024

I can confirm the same issue in the latest CDDA experimental build (2024-11-03-2221); it also affects the rendering of the action bar at the top of the screen, as shown below.

Screenshot 2024-11-03 155950

Moving the mouse while the action bar is displayed temporarily resolves the issue, but the problem reappears as soon as another action triggers the rendering of the action bar again.

Screenshot 2024-11-03 160001

I've noticed that the latest build also cuts off the item description, as previously reported. I’m adding the action bar issue here as well, as I believe both may stem from the same underlying problem.

I can confirm that setting gui_typeface in fonts.json resolves reported issues; however, this fix only works with the Terminus font.

{
  "gui_typeface": [
                 "data/font/Terminus.ttf",
                 "data/font/unifont.ttf"
  ]
}

The bug appears to have been introduced sometime after experimental build 2024-10-24-0244. When rolling back to this version, the text/menu wraps properly when using other fonts. I hope this helps narrow down the cause.

@db48x
Copy link
Contributor

db48x commented Nov 4, 2024

As already mentioned, there is already a pull request that fixes the text wrapping.

@0xToast
Copy link

0xToast commented Nov 7, 2024

As already mentioned, there is already a pull request that fixes the text wrapping.

Thanks mate, sorry I only noticed the PR after your comment.

I do see that the merge got blocked due to checks failing on the Text Changes Analyzer with Error: Process completed with exit code 1.

Pretty sure you know about this already, but thought I would mention it.

@RenechCDDA RenechCDDA unpinned this issue Nov 10, 2024
ZhilkinSerg pushed a commit that referenced this issue Nov 15, 2024
because ascii art. Also, vertically align the “Last Words:” label in
front of the textbox, so that the baselines of the two are lined up.

Partially fixes #77297
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ImGui Anything related to the new ImGui UI for SDL/tiles or ImTui for curses builds (P2 - High) High priority (for ex. important bugfixes) (S2 - Confirmed) Bug that's been confirmed to exist SDL: Tiles / Sound Tiles visual interface and sounds.
Projects
None yet
9 participants