agraef / pd-lua

Lua bindings for Pd, updated for Lua 5.3+
https://agraef.github.io/pd-lua/
GNU General Public License v2.0
51 stars 11 forks source link

Windows fixes for randomness and hi-dpi scaling #40

Closed timothyschoen closed 8 months ago

timothyschoen commented 8 months ago

Fixes 2 problems on Windows:

timothyschoen commented 8 months ago

I still have one small PR coming up. The way I currently store the currently active object in the Lua registry is hacky and needs to be fixed. It could also potentially cause bugs.

I can't get rid of it entirely without changing the API, but I think I can at least minimise its usage as much as possible.

sebshader commented 8 months ago

the errors seem to be gone now. while the font in pd for windows already looks somewhat small, is it supposed to be this small? it's kind of difficult to read here (though maybe my font/display settings are just too small overall somehow..) pdlua-font

edit: I see the font is scaled down to match plug-data, is it that small in plug-data too?

timothyschoen commented 8 months ago

the errors seem to be gone now. while the font in pd for windows already looks somewhat small, is it supposed to be this small? it's kind of difficult to read here (though maybe my font/display settings are just too small overall somehow..) pdlua-font

edit: I see the font is scaled down to match plug-data, is it that small in plug-data too?

Yeah, I guess the problem is that the text is set too small in the example, since you can set your own font size. It's also too small in plugdata

agraef commented 8 months ago

Indeed, the example uses 10pt for the text, which is really small on hi-dpi displays. Also, the yellow foreground color on the pink background make the Bezier example just barely visible, at least for my eyes. We should maybe change that in hello-gui.pd_lua. E.g., here is how it looks like with a dark gray background and the font size set to 12 pt, which also seems to be the default in new patch windows in vanilla:

image

I think that this looks a lot better. Obviously, I still need to change the text a bit to make everything fit again. But first let me merge this PR so that those annyoing bugs on Windows are fixed.

agraef commented 8 months ago

@timothyschoen I don't think that the new factor of 0.75 applied at line 1013 is correct. After merging this, the font sizes are even smaller than before, at least on Linux (this is with desktop scaling at 100%, but on Linux the desktop scale doesn't seem to affect the canvas anyway, only the GUI):

image

Everything is back to normal after commenting out line 1013:

image

So I think that we need to get rid of that line. Maybe you could adjust the scaling on the plugdata side instead? Or adjust the scaling depending on the OS and the desktop scaling that is in effect? Gets complicated, I know, but the way it is now, the font sizes are way off in vanilla and 10 is completely illegible.

agraef commented 8 months ago

Ok, here's how the demo looks now after fiddling with some of the positions, and after commenting out line 1013:

image

I've included the [osc~] object for reference, with the canvas font size set to 12, which matches the font size in the gfx example. The font sizes look alright to me.

I'm ready to commit this so that you can test it on vanilla in Windows, and on plugdata. Opinions?

agraef commented 8 months ago

Here's the example that I used for testing, with the modified hello-gui.pd_lua included. But note that you'll need to comment out line 1013 and recompile to compare with the screenie that I posted above.

gfx-test.zip

agraef commented 8 months ago

Ok, I just went ahead and commited my changes now, so that you can test. @timothyschoen I'm ready to revert the font scaling change (rev. d7f6fe8875b1a38f458d08214c446634efcc6440) as soon as you come up with something better.

timothyschoen commented 8 months ago

Ok, I just went ahead and commited my changes now, so that you can test. @timothyschoen I'm ready to revert the font scaling change (rev. d7f6fe8) as soon as you come up with something better.

Screenshot 2024-03-03 at 16 56 09

I've now just scaled the fontsize on plugdata's side so it's about the same as in pd-vanilla. I removed your comment in #42 as well.