Previous Thread
Next Thread
Print Thread
Any easy way to draw text on a bitmap? #117896 09/22/20 06:33 PM
Joined: Feb 2014
Posts: 473
G
Golden Child Online Content OP
Senior Member
OP Online Content
Senior Member
G
Joined: Feb 2014
Posts: 473
Hi guys,

I was wondering if there's an easy way to draw text on a bitmap.

There's a function in luaengine.cpp that looks like it could be used but I'm having trouble with the includes and wanted something that wouldn't depend on ui.
Code
screen_dev_type.set("draw_text", [this](screen_device &sdev, sol::object xobj, float y, const char *msg, sol::object color, sol::object bcolor) {

...
	mame_machine_manager::instance()->ui().draw_text_full(sdev.container(), msg, x, y, (1.0f - x),
			justify, ui::text_layout::WORD, mame_ui_manager::OPAQUE_, textcolor, bgcolor);
		});

I'm not particular about the font, just something that's readable to indicate status.

I suppose I could just load a rom character set and use that...

Last edited by Golden Child; 09/22/20 06:34 PM.
Re: Any easy way to draw text on a bitmap? [Re: Golden Child] #117897 09/22/20 06:37 PM
Joined: May 2009
Posts: 1,875
J
Just Desserts Offline
Very Senior Member
Offline
Very Senior Member
J
Joined: May 2009
Posts: 1,875
That would require a library for parsing "normal" fonts (as opposed to the custom BDF format that MAME uses) and rasterizing them to glyphs. Don't think we can do that.

Re: Any easy way to draw text on a bitmap? [Re: Golden Child] #117898 09/22/20 07:31 PM
Joined: Mar 2001
Posts: 16,590
R
R. Belmont Online Content
Very Senior Member
Online Content
Very Senior Member
R
Joined: Mar 2001
Posts: 16,590
We actually *do* rasterize fonts (both BDF and TrueType) to glyphs though. It's just that nothing outside of the UI uses them right now.

Re: Any easy way to draw text on a bitmap? [Re: Just Desserts] #117899 09/22/20 08:02 PM
Joined: Feb 2004
Posts: 2,176
Vas Crabb Online Content
Very Senior Member
Online Content
Very Senior Member
Joined: Feb 2004
Posts: 2,176
Originally Posted by Just Desserts
That would require a library for parsing "normal" fonts (as opposed to the custom BDF format that MAME uses) and rasterizing them to glyphs. Don't think we can do that.

BDF isn’t custom, it’s a published standard from Adobe. It must be close to 40 years old now. And yeah, what ArBee said. Depending on the target MAME can rasterise fonts for the UI. On Linux, BSD, etc. where there’s no font server as such it uses an SDL library to handle TrueType fonts directly. On Windows it can use Win32 or DirectWrite, and on macOS it uses CoreText. Of course, MAME’s approach to fonts is dumb. It rasterises characters at a fixed size and then scales them, so hinting doesn’t work, and it can’t deal with combining characters at all.


Who's Online Now
1 registered members (Vas Crabb), 46 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
ShoutChat Box
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Forum Statistics
Forums9
Topics8,818
Posts116,083
Members4,915
Most Online890
Jan 17th, 2020
Powered by UBB.threads™ PHP Forum Software 7.7.3