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

[Feature Request] Parameter to disable smoothing in LuaCanvas.drawText #1411

Closed
HeyItsLollie opened this issue Dec 28, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@HeyItsLollie
Copy link

commented Dec 28, 2018

LuaCanvas.drawText adds smoothing to fonts, which is undesirable when using pixel fonts. There's currently no LuaCanvas equivalent for gui.pixelText to work around this - though, gui.pixelText doesn't currently allow for custom pixel fonts (only fceux and gens). With that in mind, I'd like to see a true/false parameter added to LuaCanvas.drawText, to enable/disable pixel text rendering (keep smooth text rendering as default behavior).

Screenshot of current LuaCanvas.drawText VS desired result (at 3x scale)
Current LuaCanvas.drawText VS the desired result (at 3x scale)


Context for how I'm trying to use LuaCanvas here:
I'm using BizHawk's Lua Console to create a live 16:9 info-border for Pokemon Red/Blue (at 640x360), with the intention of combining the emulator and the LuaCanvas border in OBS, and scaling both elements up by 300%. This unfortunately means that the text smoothing becomes very visible, and so the text ends up looking weirdly smeared.

I originally tried creating this border directly on top of the emulator via gui.***, as gui.drawText renders this pixel font cleanly. But BizHawk renders gui draw calls at the emulator core's output resolution - in this case: I'm limited to 256x224 for Same Boy + SGB, with no room for resolution-independent elements (everything renders at 1:1 pixel scale), or anything that extends past the output res (elements get cut off at the sides, so this border would be limited to 8:7 ratio).

@zeromus

This comment has been minimized.

Copy link
Contributor

commented Dec 30, 2018

can you build the code? change LuaPictureBox.cs code

			Rectangle rect = new Rectangle(new Point(x, y), sizeOfText);
			boxBackground = Graphics.FromImage(Image);
			boxBackground.FillRectangle(GetBrush(backcolor ?? _defaultTextBackground.Value), rect);
			boxBackground = Graphics.FromImage(Image);
			boxBackground.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
			boxBackground = Graphics.FromImage(Image);
			boxBackground.DrawString(message, font, new SolidBrush(forecolor ?? Color.Black), x, y);

to

			Rectangle rect = new Rectangle(new Point(x, y), sizeOfText);
			boxBackground = Graphics.FromImage(Image);
			boxBackground.FillRectangle(GetBrush(backcolor ?? _defaultTextBackground.Value), rect);
			boxBackground = Graphics.FromImage(Image);
			boxBackground.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
			boxBackground.DrawString(message, font, new SolidBrush(forecolor ?? Color.Black), x, y);
@HeyItsLollie

This comment has been minimized.

Copy link
Author

commented Dec 30, 2018

I was able to get everything set up to build BizHawk, so this edit works for the time being, thank you!

@zeromus

This comment has been minimized.

Copy link
Contributor

commented Dec 30, 2018

"works for the time being" or "fixes it totally"?

@HeyItsLollie

This comment has been minimized.

Copy link
Author

commented Dec 30, 2018

It fixes my issue completely! I only say "for the time being" because it's the result of an edit rather than an addition - it mucks with current default behavior for rendering text on a lua canvas, and requires a custom build to use it*. I'd love to see it as an on/off parameter that's available to everyone, and finally have a equivalent option for gui.pixelText in lua canvas.

*- to be clear, thanks to BizHawk's compile instructions, the build process was painless! Visual Studio itself was a bit of a hassle, 2015 refused to even install.

@zeromus

This comment has been minimized.

Copy link
Contributor

commented Dec 30, 2018

The code was broken. The mucking is fixing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.