Author Topic: Fonts in 64k intros  (Read 8757 times)

0 Members and 1 Guest are viewing this topic.

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Fonts in 64k intros
« on: September 30, 2012 »
I was wondering if anyone had any thoughts or suggestions for handling fonts in 64k intros?

The normal approaches seem to be either a 1 bit bitmap font (black & white) or using existing system fonts (TTF such as Arial etc). Both of these methods seem quite limited to me, so I'm wondering if there are alternatives. I guess the SDF font stuff Hellfire posted about a little while ago would be excluded on size grounds as it needs a fairly large PNG to represent distance fields. My only other thought would be to write something to process existing vector based fonts and somehow recreate these in code using a minimal number of points and some curves (bezier or whatever). I can see this last technique being quite difficult to implement, so I wonder if anyone else has an other insights?

Cheers,

raizor
raizor

Challenge Trophies Won:

Offline Blacksheep8Bit

  • *Custum Title goes here*
  • C= 64
  • **
  • Posts: 91
  • Karma: 36
  • *useless thing to write goes here*
    • View Profile
Re: Fonts in 64k intros
« Reply #1 on: September 30, 2012 »
Well, if you are planning to make some oldskool demo, i would recomend converting the font bitmap in an byte array so you don't have to deal with headers, you should make a code generator if you don't want to spend time converting from binary to hex.

Code: [Select]
the 'a' letter is stored in each bit of 8 bytes, so we have 8x8 bits in the end

00011100 = 0x1C
00100010 = 0x22
01000001 = 0x41
01111111 = 0x7F
01000001 = 0x41
01000001 = 0x41
01000001 = 0x41
00000000 = 0x00

Code: [Select]
byte letters[32][8] = { { 0x1c,0x22,0x41,0x7F,0x41,0x41,0x41,0x00 }, // a
{ ... }, // b
{ ... }, ... };


Or again like you said, you can use windows fonts with opengl, but they tend to be slow, VERY slow if you want great detail... And vector fonts aren't easy to make, specially if you want something that looks great.

I Still prefer the oldskool fonts btw, since thats the kind of demo i like to make.
« Last Edit: September 30, 2012 by Blacksheep8Bit »
Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: Fonts in 64k intros
« Reply #2 on: September 30, 2012 »
I was wondering if anyone had any thoughts or suggestions for handling fonts in 64k intros?
I guess the SDF font stuff Hellfire posted about a little while ago would be excluded on size grounds
There's already a version of the tool which creates a vectorized outline of the character data.
Drop me a note if that's of any use for you.
Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Fonts in 64k intros
« Reply #3 on: September 30, 2012 »
@Blacksheep8Bit, thanks. I'm trying to avoid any bitmaps at all at the moment if possible, so I think some kind of vectorized font is the way to go. Not sure how small I'll be able to get things, will keep you posted :)

@Hellfire, note dropped :)
raizor

Challenge Trophies Won:

Offline mrmudlord

  • ZX 81
  • *
  • Posts: 18
  • Karma: 1
    • View Profile
Re: Fonts in 64k intros
« Reply #4 on: October 14, 2012 »
In my craptro, I use a custom font which loads from memory.

The handle given to CreateFont is like this:
Quote
HANDLE m_fonthandle = AddFontMemResourceEx(
         fontdata,          // font resource
         fontdata_len,          // number of bytes in font resource
         NULL,             // Reserved. Must be 0.
         &nFonts         // number of fonts installed
         );
where  *fontdata is a pointer and fontdata_len is the length in bytes of the resource. Then on end you do RemoveFontMemResourceEx().

In my most recent prod I am working on for a demoparty, I just use a bitmap for the raster font.

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Fonts in 64k intros
« Reply #5 on: October 14, 2012 »
In my craptro, I use a custom font which loads from memory.

The handle given to CreateFont is like this:
Quote
HANDLE m_fonthandle = AddFontMemResourceEx(
         fontdata,          // font resource
         fontdata_len,          // number of bytes in font resource
         NULL,             // Reserved. Must be 0.
         &nFonts         // number of fonts installed
         );
where  *fontdata is a pointer and fontdata_len is the length in bytes of the resource. Then on end you do RemoveFontMemResourceEx().

In my most recent prod I am working on for a demoparty, I just use a bitmap for the raster font.

I assume this is a bitmap font Mudlord? I'm aiming more for vector based fonts that are nice and small. Looks like extracting and optimising font outlines from TTF is the way to go at the moment. Still haven't had time to look into it properly yet, but will post my findings here when I do. Thanks.
raizor

Challenge Trophies Won:

Offline mrmudlord

  • ZX 81
  • *
  • Posts: 18
  • Karma: 1
    • View Profile
Re: Fonts in 64k intros
« Reply #6 on: October 14, 2012 »
Sadly thats the case, its a bitmap font. D:
I am also looking for the same thing you are looking for (ways to do decent font rendering/kerning).
« Last Edit: October 14, 2012 by mrmudlord »

Offline Blacksheep8Bit

  • *Custum Title goes here*
  • C= 64
  • **
  • Posts: 91
  • Karma: 36
  • *useless thing to write goes here*
    • View Profile
Re: Fonts in 64k intros
« Reply #7 on: October 14, 2012 »
This:
http://nehe.gamedev.net/tutorial/outline_fonts/15004/
(wglUseFontOutlines)

But i guess this is what you mentioned with the "using existing system fonts (TTF such as Arial etc).", i only didn't understood why do you think this is limited...
Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Fonts in 64k intros
« Reply #8 on: October 14, 2012 »
This:
http://nehe.gamedev.net/tutorial/outline_fonts/15004/
(wglUseFontOutlines)

But i guess this is what you mentioned with the "using existing system fonts (TTF such as Arial etc).", i only didn't understood why do you think this is limited...

That requires that the font is already installed on the target machine, so you're pretty limited in what fonts you can use (arial, helvetica etc). If you wanted to use a font that's not included in a standard Windows install, you'd need to carry it with you exe, which is gonna eat up a lot of space (and likely bump the intro size over 64k).
raizor

Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Fonts in 64k intros
« Reply #9 on: October 14, 2012 »
Sadly thats the case, its a bitmap font. D:
I am also looking for the same thing you are looking for (ways to do decent font rendering/kerning).

If you're not worried about size, this is worth checking out: BMFont.
raizor

Challenge Trophies Won:

Offline mrmudlord

  • ZX 81
  • *
  • Posts: 18
  • Karma: 1
    • View Profile
Re: Fonts in 64k intros
« Reply #10 on: October 15, 2012 »
This:
http://nehe.gamedev.net/tutorial/outline_fonts/15004/
(wglUseFontOutlines)

But i guess this is what you mentioned with the "using existing system fonts (TTF such as Arial etc).", i only didn't understood why do you think this is limited...

That requires that the font is already installed on the target machine, so you're pretty limited in what fonts you can use (arial, helvetica etc). If you wanted to use a font that's not included in a standard Windows install, you'd need to carry it with you exe, which is gonna eat up a lot of space (and likely bump the intro size over 64k).

Unless you use the code I posted, yes, thats true. My lines just allows you to pick other fonts not installed on the end users system, thus removing that problem. Doesn't matter if they are outline or not, as long as they are TTF, they should be fine. I even tried *.FON files with degrees of success. Though depending on the font type, quality can vary. :/
« Last Edit: October 15, 2012 by mrmudlord »

Offline Faun

  • ZX 81
  • *
  • Posts: 15
  • Karma: 6
    • View Profile
Re: Fonts in 64k intros
« Reply #11 on: December 09, 2012 »
I was wondering if anyone had any thoughts or suggestions for handling fonts in 64k intros?

The normal approaches seem to be either a 1 bit bitmap font (black & white) or using existing system fonts (TTF such as Arial etc). Both of these methods seem quite limited to me, so I'm wondering if there are alternatives. I guess the SDF font stuff Hellfire posted about a little while ago would be excluded on size grounds as it needs a fairly large PNG to represent distance fields. My only other thought would be to write something to process existing vector based fonts and somehow recreate these in code using a minimal number of points and some curves (bezier or whatever). I can see this last technique being quite difficult to implement, so I wonder if anyone else has an other insights?

Cheers,

raizor

I used Efgen to generate fonts to binary, that way you can embed it into your intro. It does not add much to the size and is the most nifty thing I have done to this day. Just follow the tutorial on the Efgen site and feel free to see how I did in my source for "Fauntastic!".
"If car technology had advanced as quickly as computer technology, a Dodge Viper would cost $3.99, get a million miles per gallon, and explode twice every year."