Skip to content

Commit

Permalink
Test fix freeze when switching to TTF output (MinGW)
Browse files Browse the repository at this point in the history
  • Loading branch information
maron2000 committed Sep 16, 2023
1 parent 3888af5 commit bc3c9d9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/output/output_ttf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ void ttf_switch_on(bool ss=true) {
}
bool OpenGL_using(void), gl = OpenGL_using();
#if defined(WIN32) && !defined(C_SDL2)
change_output(3); // call OUTPUT_OPENGL_Select(GLBilinear) to initialize output before enabling TTF output on Windows builds (does nothing if OpenGL not available)
change_output(0); // call OUTPUT_SURFACE_Select() to initialize output before enabling TTF output on Windows builds
#endif
change_output(10); // call OUTPUT_TTF_Select()
SetVal("sdl", "output", "ttf");
Expand Down

9 comments on commit bc3c9d9

@emendelson
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maron2000 - Since you are working on ttf and scaling, is there any hope of getting #3731 fixed? It makes it impossible to use ttf output with sdl2 on macOS. I know this isn't an issue for many users, but it matters for some of us!

@maron2000
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, my fix is just initializing output to something besides TTF before switching to TTF.
You can do that manually to see if the idea works for your issue.
One idea is to config -set output=opengl (or surface) then switch to ttf, and go to fullscreen mode, which is the basic idea of this PR.
Another idea is to switch to TTF mode AFTER you go to fullscreen mode.
If one or both ideas work, it maybe worth adding that in the code so that it does the procedures for you.
The nightly build updated the SDL2 library just last week, but I assume it didn't work for your issue?

@emendelson
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maron2000 - I downloaded the current code two hours ago and built it on an M2 Mac: that will have the SDL2 library update that you mentioned, won't it? If not, I'll try the nightly build.

Those fixes did not work, unfortunately. I tried both output= settings that you mentioned (OpenGL and surface) with no luck, and tried switching to TTF after going to fullscreen mode, and every other variety I could think of. The last line of text is always cut off at the foot of the screen.

@maron2000
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can check the version of SDL library from the log.
If you build the in-tree library, the current version is 2.28.2.
If the version is so, we have to look for another possible cause.

@emendelson
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the log says SDL: version 2.28.2, so this is still a mystery. It started happening about a year ago, but I can't identify exactly when.

@maron2000
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we have to see which version used to work, if it ever did.
Or maybe try another font, such as sarasagothicfixed.ttf which comes with the release, if you haven't tried it yet.

@emendelson
Copy link
Contributor

@emendelson emendelson commented on bc3c9d9 Sep 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried all three additional fonts, with no luck. The nouveau_ibm.ttf font worked perfectly if the screen length was 25 lines, because it seems to be designed for an 80X25 screen, but as soon as I changed LINS=. to something else, the last line got cut off at the foot of the screen. The other two were worse: the last line (the current line at the prompt) was below the screen border and completely invisible.

EDIT: I posted the bug 11 September 2022. Later today I'll start experimenting with older versions of the code to see if I can narrow this down.

@emendelson
Copy link
Contributor

@emendelson emendelson commented on bc3c9d9 Sep 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maron2000 - Wait: I was wrong in thinking that this worked correctly in an older SDL2 build. I've been downloading older builds and cannot find any that allowed truetype output and that correctly scaled full-screen. I seem to have been confusing this with earlier builds that did not use TTF but that scaled correctly.

So this seems to be a bug that was always in the code, as long as TTF was supported, but which I only noticed when I started changing my custom apps to use truetype output. It works perfectly under Windows, but not at all under macOS.

EDIT: What seems to be going wrong is in something in the code (I can't find it) that should do something like this:

When switching to full screen, divide the screen height by the number of lines specified in LINS=nn; the result will be a number that should be used to set the point size of the TTF font. If the number is not a whole number, then round it down to the nearest smaller whole number, so that the lowest line on the screen will always be above the bottom of the screen.

My guess is that the fix will require one line of code, but I can't figure out where it would go or what it should be.

@maron2000
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, quick workarounds that I can think of did't work so the problem is quite complicated and the fix will not be related to this fix, we may continue the discussion in issue #3731.

Please sign in to comment.