Pages: 1 2 »
  Print  
Author Topic: Default Font Glyph  (Read 4383 times)
Offline (Male) Goombert
Posted on: August 06, 2013, 04:24:15 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
Some of you may not be aware as you have not much interaction with the plugin to LateralGM. canthelp discovered that the default font is rendered inside the plugin using Java AWT, you see ENIGMA uses sprite fonts, like every other game engine including Game Maker. So for there to be a default one, the plugin takes the default Java font and renders it and passes the glyphs over to ENIGMA. This is very dumb, this is done every time you compile, not that slow, but is part of the reason why compile is slow. It should be done internally by ENIGMA, otherwise ENIGMA basically depends on Java or something else to render that default font. canthelp discovered it when building the CLI that he could not call draw_text when he had no font resources. We should include a default sprite font with ENIGMA, what do you think Josh?
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Male) DaSpirit
Reply #1 Posted on: August 06, 2013, 04:37:41 PM

Member
Location: New York City
Joined: Mar 2013
Posts: 124

View Profile
Everything should be done internally by ENIGMA. ENIGMA should be its own executable. I'm for it.
Logged
Offline (Unknown gender) TheExDeus
Reply #2 Posted on: August 06, 2013, 04:49:48 PM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Well including a default sprite font for CLI would be good. But I don't think ENIGMA plugin should generate all font textures. I don't think there would be an easy cross-platform way to do it in C++ for ENIGMA plugin.
Logged
Offline (Male) Josh @ Dreamland
Reply #3 Posted on: August 06, 2013, 06:53:23 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2958

View Profile Email
Having ENIGMA exclusively as a separate binary is asinine. Syntax checking is done frequently; in an increasing number of modern IDEs, it is done continually. Are you going to have the OS spawn a process every half second or so to check the syntax of an open script? If that isn't enough to frighten you out of that idea, what about for all open scripts? Good luck.

As far as whose job it is to generate font textures, letting the plugin do it has an advantage: the IDE can pass textures it gets from anywhere. Anything goes. The disadvantage is, of course, that all IDEs must do that. Perhaps some kind of compromise is in order (eg, an option to pass a null bitmap and have ENIGMA generate the glyphs using libttf).
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Male) Goombert
Reply #4 Posted on: August 06, 2013, 09:35:19 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
Well I don't know, I just thought maybe you hadn't given that some thought in a while Josh, because it seems like something you would traditionally be against. But I kinda get now why it is the way that it is. I just don't like ENIGMA having to rely on Java. How big are font files anyway? I think we could pack quite a few of them in at a small size if we really wanted couldn't we?
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) TheExDeus
Reply #5 Posted on: August 07, 2013, 01:29:34 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
The default one which is always included is 128x64 with about half the texture empty.
Logged
Offline (Unknown gender) ssss
Reply #6 Posted on: August 07, 2013, 02:20:00 AM
Member
Joined: Jun 2013
Posts: 24

View Profile
If everyones forgotten, I found out that theres the GML function font_add that can create a font. It crashes ENIGMA right now because it never actually creates the fnt->texture, but someone should fix it for GM compatibility. That means ENIGMA has to have the ability to render a font on its own. That doesnt mean the compiler can do it though.

None of the game formats include glyph data I think, do they? Any program that reads game formats and compiles them with libcompileEGMf will have to be able to render the glyphs or the ENIGMA compiler will have to be able to render them.
« Last Edit: August 07, 2013, 02:24:28 AM by ssss » Logged
Offline (Male) Goombert
Reply #7 Posted on: August 07, 2013, 04:01:24 AM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
btw everyone, ssss is canthelp on the IRC, he is building a Command Line Interface for ENIGM'R
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) TheExDeus
Reply #8 Posted on: August 07, 2013, 08:02:32 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Quote
If everyones forgotten, I found out that theres the GML function font_add that can create a font. It crashes ENIGMA right now because it never actually creates the fnt->texture, but someone should fix it for GM compatibility. That means ENIGMA has to have the ability to render a font on its own. That doesnt mean the compiler can do it though.
We know about that function and it was investigated. The problem is that there is no really painless way to do it. I guess the best bet is to use libttf: http://www.freetype.org, but previously when this was investigated (years ago) either the library didn't exist in the current form or we just didn't find it (we experimented with OS level stuff, like Windows font generation functions). I haven't investigated that though.
Logged
Offline (Male) Josh @ Dreamland
Reply #9 Posted on: August 07, 2013, 10:32:27 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2958

View Profile Email
Quote
The default one which is always included is 128x64 with about half the texture empty.
Okay, that's gross. The rectangle packer is supposed to generate an optimal map. If half the texture is empty, it means there were just enough glyphs to require one more resize (Each resize doubles the texture atlas size, for obvious reasons).

Anyway, font_add isn't really my biggest concern, largely because it's ugly and inconsistent between platforms, and as Harri so elegantly pointed out, we pack a default font with each game. Yes, it would be nice to be able to acquire glyphs (especially Unicode glyphs) on demand, so we might invest in the matter down the road. The rectangle packer, despite its apparent issues, is capable of adding more glyphs on the fly, as it does not do any planning in advance.

That said, perhaps we could gain a more optimal solution by providing the texture size in advance, eg, by calculating a solution, halving the larger (or vertical) side, then recomputing the map. Could you upload the texture generated on your system, Harri?
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) TheExDeus
Reply #10 Posted on: August 08, 2013, 01:22:30 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Quote
Okay, that's gross. The rectangle packer is supposed to generate an optimal map. If half the texture is empty, it means there were just enough glyphs to require one more resize (Each resize doubles the texture atlas size, for obvious reasons).
Well, yeah, it didn't fit in 64x64, so it expanded to 128x64. I don't see that as a big issue taking into account how tiny the texture is. Maybe later with texture atlas we could pack several fonts together into one texture.

Quote
Anyway, font_add isn't really my biggest concern, largely because it's ugly and inconsistent between platforms, and as Harri so elegantly pointed out, we pack a default font with each game. Yes, it would be nice to be able to acquire glyphs (especially Unicode glyphs) on demand, so we might invest in the matter down the road. The rectangle packer, despite its apparent issues, is capable of adding more glyphs on the fly, as it does not do any planning in advance.
I think libttf would be quite consistent and the more I read about it the more I think that is a good solution (and it's GPL).

Quote
That said, perhaps we could gain a more optimal solution by providing the texture size in advance, eg, by calculating a solution, halving the larger (or vertical) side, then recomputing the map. Could you upload the texture generated on your system, Harri?
I think they are generated the same on all systems (or at least platforms). On Windows, for example, everyone should see this:

I inverted the colors so it easier to see (normally the text is white so blending works). I think it packs quite good and maybe even too tightly, because that causes rendering artifacts. Like when you render a scaled text or something, then the texture coordinate slightly goes into the other letter. This was a massive problem with GM and I see artifacts like that in ENIGMA as well.

Also, the default font doesn't look so well and because of size and no AA the lines are not straight when they should be (like in X or Y), so we should at least turn AA on. That would probably make the font use more of the 128x64 texture, but it's empty anyway.
« Last Edit: August 08, 2013, 01:26:16 AM by TheExDeus » Logged
Offline (Male) Goombert
Reply #11 Posted on: August 08, 2013, 02:51:51 AM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile

Harri, I think that is why at first that draw_text was screwing up in OpenGL 3 before you fixed it, cause that whiteness kind of looked like it was just the sprites using the font texture. Just saying, its already fixed, just sayin though.
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) TheExDeus
Reply #12 Posted on: August 08, 2013, 03:30:32 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Also, the font texture interpolation bug mentioned in git is still a problem? I think maybe that is the reason why GL3 font drawing sucks to bad right now. Maybe though I just need to change floats back to ints.
Logged
Offline (Male) Goombert
Reply #13 Posted on: August 08, 2013, 05:19:19 AM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
Harri, it was that, and it was also the half pixel alignment. I can easily fix OpenGL 3 fonts, simply add a boolean flag to GmTexture struct called isFont, and check that when looping the textures in texture_set_interpolation
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Male) Josh @ Dreamland
Reply #14 Posted on: August 08, 2013, 08:35:34 AM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2958

View Profile Email
Sorry, Harri; that's life. There's not a damn thing I can do about the L being just big enough to not fit. Now, as for packing tightness, that's a reaaaally easy fix. You'd just need to up the width and height of the rectangles that get passed to the packing algorithm. You'd probably also need to offset the glyphs in the texture by half that margin as to avoid artifacts from clamping on the top and left edges of the texture. Interpolation gets a little ugly when that happens. The idea is that it would not matter in most games, but we've been seeing that behavior with increasing frequency...
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Pages: 1 2 »
  Print