Author Topic: Create custom OpenGL stroked fonts, Ready for release!  (Read 9085 times)

0 Members and 1 Guest are viewing this topic.

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1390
  • Karma: 84
    • View Profile
Hello dear chaps.

I've started work on a font program that should let the user make their own characters and then export to a usable OpenGL format in the form of a text file.

Consult the drHelp file for more info.

« Last Edit: January 22, 2008 by Pixel_Outlaw »
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17427
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: Create custom OpenGL stroked fonts.
« Reply #1 on: January 21, 2008 »
That's a really helpful idea that I will be sure to check out Pixel :)

I was thinking about making a similar (but not identical) version of this http://www.intro-inferno.com/production.php?id=2505 so a vector font editor is a great idea :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1390
  • Karma: 84
    • View Profile
Re: Create custom OpenGL stroked fonts.
« Reply #2 on: January 21, 2008 »
Yes it would look great if you were going for an early look of simply didn't like the anti-aliasing done on image based fonts.

I'll work on an OpenGL exporter today.

I plan to export to an OpenGL list with each sublist a character.

Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Create custom OpenGL stroked fonts.
« Reply #3 on: January 21, 2008 »
Cool project. Good luck with it !!!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1390
  • Karma: 84
    • View Profile
Re: Create custom OpenGL stroked fonts.
« Reply #4 on: January 21, 2008 »

I guess since I'm ready to export to some usable OpenGL text, my question becomes what are my options.

In the "red book" they have a demonstration program of using a stroked vector font on page 228-290 of chapter 7.

I think that this will work well. It would be up to the user to write a string drawing function, they would have all of the font information however.
Challenge Trophies Won:

Offline stormbringer

  • Time moves by fast, no second chance
  • Amiga 1200
  • ****
  • Posts: 453
  • Karma: 73
    • View Profile
    • www.retro-remakes.net
Re: Create custom OpenGL stroked fonts.
« Reply #5 on: January 22, 2008 »
What would be nice is to draw also filled chars, not just wireframe ones. And pre-tesselate them for faster processing.

I did that for this remake: http://www.intro-inferno.com/production.php?id=6025 but it's just a piece of dirty code, not a tool... could be helpful to have a tool that can make my life easier...
We once had a passion
It all seemed so right
So young and so eager
No end in sight
But now we are prisoners
In our own hearts
Nothing seems real
It's all torn apart

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: Create custom OpenGL stroked fonts.
« Reply #6 on: January 22, 2008 »
Cool project. I did a couple of these back when I was using BlitzPlus to help me do some wireframe demos. It looks like you are off to a good start. One thing I was thinking that you might want to have as an option is to be able to do lines that do not have to connect all the way through. For instance when doing the character "i" or "!" it would be nice to be able to have the point seperate, but ofcause then you might not be able to utilize displaylist, but I can't remember exactly how those are setup.

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1390
  • Karma: 84
    • View Profile
Re: Create custom OpenGL stroked fonts.
« Reply #7 on: January 22, 2008 »
I think you can have some lines as line_strips and some lines as just plain lines in a disply sublist. This should fix letters with disconnected parts such as i and j. I have no idea how to begin making filled characters. I know that polygon triangulization is a huge pain in the ass and probably too complex for my current skills.
Challenge Trophies Won:

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1390
  • Karma: 84
    • View Profile
Re: Create custom OpenGL stroked fonts.
« Reply #8 on: January 22, 2008 »
OK well it is now fully operational. You can export your fonts to a handy .bmx file. (Or do some editing in notepad to make it fit other languages). There will probably be support for individual spacing on letters and things of that nature in later releases. I have included a test font, test application and also all source from everything.

DAMN the file is exactly 300 KB. I shall have to upload somewhere.

HERE: character designer WORKING.rar

EDIT sorry I've forgotten the "demofont" file that has a saved and loadable vector font. You may want to load this in the editor to see where I exported the font1 file from.
« Last Edit: January 22, 2008 by Pixel_Outlaw »
Challenge Trophies Won:

Offline Dr.Death

  • Senior Member
  • Amiga 1200
  • ********
  • Posts: 445
  • Karma: 9
    • View Profile
What a cool idea this should come in handy  :goodpost:
Proud member of DAWN

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: Create custom OpenGL stroked fonts, Ready for release!
« Reply #10 on: January 22, 2008 »
Its really nice that it generates ready to use code (at least bmax ready).

As far as filled vector goes, you could instead of automatic tesselation, offer that the user can draw them using either triangles or quads. Here is a picture to help explain:



The user can add either quads or triangles and then display lists of these are built. As you can see the character A could be done with 4 quads or 10 triangles. I did something like that for a demo I made and it worked just fine. At least with this manual way of producing the vector, you are in control of the number of triangles/quads and how they are put together to form the character.

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1390
  • Karma: 84
    • View Profile
Re: Create custom OpenGL stroked fonts, Ready for release!
« Reply #11 on: January 22, 2008 »
I just realized that you are right. I could use the exact same system only change the file output to include the proper list type. Perhaps a small strip of check boxes next to the font would select the drawing list type. Later today I'll try to add support for automatically finding the spacing for each character, and saving the drawing type for each character. I think I will add this information to the file after the letter vertex information. This will let you still load the old version fonts. I doubt anyone has made a font in the last 8 hours, but you never know.
Challenge Trophies Won:

Offline stormbringer

  • Time moves by fast, no second chance
  • Amiga 1200
  • ****
  • Posts: 453
  • Karma: 73
    • View Profile
    • www.retro-remakes.net
Re: Create custom OpenGL stroked fonts, Ready for release!
« Reply #12 on: January 22, 2008 »
for the tesselation, you could stick to the tesselation functions in the GLU (gluNewTess() etc). It's not the best tesselator ever, but should be enough for this project. Basically (as it is the case in any font design tool) a glyph (the graphical representation of a letter) is made of contours (inner and outter contours). The orientation of the contour (the order in which you define them, clockwise or counter-clockwise) tell the tesselator if it's an inner or an outter contour (to create holes for example).

In about 1 hour you should be able to have this working properly, it's not that difficult.

And yes, looks like a very useful tool (at least for me!)

Good job!
We once had a passion
It all seemed so right
So young and so eager
No end in sight
But now we are prisoners
In our own hearts
Nothing seems real
It's all torn apart

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1390
  • Karma: 84
    • View Profile
Re: Create custom OpenGL stroked fonts, Ready for release!
« Reply #13 on: January 23, 2008 »
Nobody told me that I sent the broken version in the upload like.


This one has a working export to .bmx option and also a gradient font option. You have 2 gradient colors one is changed by hitting the 1 key and the second is changed by hitting the 2 key. This will carry over to the solid vector fonts when I get time to work on the display methods as choices. The color gradient is exported into the .bmx file but is not yet saved into the custom reloadable file.


Here is the full version with my apologies. You can export with this version.
http://myfreefilehosting.com/f/502cc73be1_0.31MB
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Create custom OpenGL stroked fonts, Ready for release!
« Reply #14 on: January 23, 2008 »
'glut' provides some font routines, the stroke character stuff is very like your first example.  Apologies for not posting this before - I couldn't remember which API it was from.:(
http://www.opengl.org/resources/libraries/glut/spec3/node75.html#SECTION000110000000000000000

Jim
Challenge Trophies Won:

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1390
  • Karma: 84
    • View Profile
Re: Create custom OpenGL stroked fonts, Ready for release!
« Reply #15 on: January 26, 2008 »

I got a little something up and running. This time I should be able to directly upload this.

Currently every type of OpenGL primative is supported except GL_TRIANGLE_FAN. It exports pretty well now and you simply add the OpenGL data directly into your work. There are some options for gradient font of your choice. Just remember when you make solid letters, if you want the polygons to work in a lighting mode you need to wind them properly.

I've got a migrane and have stayed up coding untill 2 am so enjoy folks.



Now for the file.
« Last Edit: January 26, 2008 by Pixel_Outlaw »
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: Create custom OpenGL stroked fonts, Ready for release!
« Reply #16 on: January 26, 2008 »
Really nice work on this. Great to see that you are sticking with.