Pages: 1
Author Topic: Custom Widgets  (55,595 Views)
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Posted on: May 05, 2010, 02:26:23 AM
If ENIGMA had its own, draw_*()-drawn widgets library, made of primitives, it would, for one thing, make some users' lives easier (Remember Roach's GMWidgets? I think that was his. It's been a while). More importantly, it would make build mode cross platform automatically. For this to work, ENIGMA requires a well-working draw_text(). Ism and I, as usual, need to talk about that...

I guess I'd write the library, though it's not a difficult task, really. Just tedious-ish, especially if it is to support any platform-specific features... I guess widgets_get_selected_text() could return last selected in-window text on Windows, and do what it's told on Linux, and that's the main difference between the two platforms. That and scroll bars.

Ism, when you see this; does Java have the ability to render a glyph to an image? Otherwise, I need to include some cross-platform glyph renderer in the compiler...
Offline (Unknown gender) IsmAvatar

LateralGM Developer
LGM Developer
Joined: Apr 2008
Posts: 877
View profile
Reply #1 Posted on: May 05, 2010, 05:22:57 AM
Wut?
Offline (Unknown gender) score_under

Member
Joined: Aug 2008
Posts: 308
View profile
Reply #2 Posted on: May 05, 2010, 03:59:07 PM
Quote from: Josh @ Dreamland on May 05, 2010, 02:26:23 AMsome cross-platform glyph renderer in the compiler...
Some function with many ifdefs, that is different on Win/Lin, using Win API to render the text and FreeType to render the text.
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #3 Posted on: May 05, 2010, 05:13:04 PM
Ism: I mean, can you create a bitmap containing a rendered font glyph? GM stores an array of bitmaps for each glyph. Fortunately, they are monochrome, and maybe monotone. I'm not sure how many colors they actually require; score_under, do you know? Also, I don't want platforms hardcoded in one file.
Offline (Unknown gender) luiscubal

Member
Joined: Jun 2009
Posts: 452
View profile
Reply #4 Posted on: May 05, 2010, 07:49:45 PM
It seems rather easy...

1. Create a BufferedImage(to get size you may use FontMetrics)
2. Get the associated Graphics instance
3. Use drawString in it.
4. Export to a PNG file or whatever format is being used
Offline (Unknown gender) retep998

Member
Joined: Jan 2010
Posts: 248
View profile
Reply #5 Posted on: May 05, 2010, 09:52:49 PM
Glyphs as in fonts?
In gm they are only black with an alpha channel, maybe 8 bits?
Offline (Unknown gender) IsmAvatar

LateralGM Developer
LGM Developer
Joined: Apr 2008
Posts: 877
View profile
Reply #6 Posted on: May 05, 2010, 10:29:25 PM
luis, using drawString would not work because of kerning.
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #7 Posted on: May 06, 2010, 12:25:38 AM
What does that mean for my request? :P
Offline (Unknown gender) luiscubal

Member
Joined: Jun 2009
Posts: 452
View profile
Reply #8 Posted on: May 06, 2010, 02:11:18 PM
Does GM implement kerning?
Offline (Unknown gender) IsmAvatar

LateralGM Developer
LGM Developer
Joined: Apr 2008
Posts: 877
View profile
Reply #9 Posted on: May 06, 2010, 02:30:38 PM
It has the data for it stored in the EXE. Heaven forbid we support a few more fonts that GM doesn't support.
Regardless, I thought I did something like this already. Should be easy enough to re-implement it (including kerning)
Pages: 1