Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » al_load_bitmap_font makes no sense

This thread is locked; no one can reply to it. rss feed Print
al_load_bitmap_font makes no sense
Chris Katko
Member #1,881
January 2002
avatar

It expects at least 1px border between glyphs.

I dare you to google "code page 437" and find a single upload that includes borders and the extended-ASCII set.

Dwarf Fortress ASCII tilesets? Nope.

VGA font? Nope.

code page 437? Nope.

I can't find a single font that works with this function.

Why isn't there a switch (or function) to use either:

- Specify arguments for size and padding values.

- Figure out the font dimensions automatically by assuming fixed-width, and (optionally?) a set number of characters (or just default to 256).

My only guess here (and it's likely) is that this function was intended for use with variable-length fonts? (Hence the px border) But you would almost always use TTF for variable length fonts.

So it seems like we implemented the rarest possible case... and left out the most common one.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

SiegeLord
Member #7,827
October 2006
avatar

We could certainly add a function to handle these formats... like al_load_fixed_bitmap_font or al_load_grid_bitmap_font.

As it is, I think the easiest thing would actually be to create a bmfont XML file to tell Allegro how to read such things:

<font>
  <info face="font" size="8" bold="0" italic="0" charset="" unicode="" />
  <common lineHeight="8" base="0" pages="1" />
  <pages>
    <page id="0" file="the_font.png"/>
  </pages>
    <chars count="100">
      <char id="32" x="0" y="0" width="8" height="8 xoffset="0" yoffset="0" xadvance="8" page="0" chnl="15"/>
...and so on...
</font>

Save that with .fnt extension and load that with al_load_font.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

It's a relic of the Allegro 4 bitmap fonts, which had the same restrictions.

What you need is one of those pink yellow and black or white fonts, like this :

https://www.allegro.cc/files/attachment/611937
{"name":"611937","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/9\/a90dfae616d349f7544d7f9715430b6f.png","w":294,"h":228,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/9\/a90dfae616d349f7544d7f9715430b6f"}611937

You can download my Allegro 4 Font Maker here :

https://www.allegro.cc/forums/thread/606083/898918#target

Go to: