Fonts compatible with devkitarm (or how to make them!) (libnds)

Discussion in 'NDS - Emulation and Homebrew' started by kerneldev, Jan 13, 2012.

  1. kerneldev
    OP

    Newcomer kerneldev Member

    Joined:
    Jan 11, 2012
    Messages:
    26
    Location:
    The Mud Ball
    Country:
    United States
    Hi,

    I've been compiling resources for homebrew fonts suitable for the DS:
    • http://www.proggyfonts.com/index.php?menu=download
    • http://www.angelcode.com/products/bmfont/
    But thus far I've been unable to grok how the fonts, especially TTF ones, can be converted to a BMP bitmap font suitable to be used with libnds. I'm writing a tool I plan on releasing when it has produced fruits (it has to do with investigating the DS mode in 3DS) and would love to be able to use crisp fonts rather than the default console one (which looks mildly wrong with DeSmuME).

    Can anybody help with understanding how to create fonts for libnds? Perhaps a HOWTO?
     
  2. DanTheManMS

    Member DanTheManMS aka Ricochet Otter

    Joined:
    Jun 2, 2007
    Messages:
    4,325
    Location:
    Georgia
    Country:
    United States
    You could look into whatever DSReader used for rendering TTF fonts on the DS on the fly.
     
  3. Foxi4

    Reporter Foxi4 On the hunt...

    pip
    Joined:
    Sep 13, 2009
    Messages:
    22,705
    Location:
    Gaming Grotto
    Country:
    Poland
    It's my understanding that the DS may use two types of fonts - based on a tiled background, where each tile represents one letter, and those are made quite easily, since all you have to do is put each letter in its corresponding "slot" and fonts that are actively drawn on-screen on a bitmap-like layer, difference being that tiled fonts cannot be resized and take less space while drawn fonts work exactly the same as their equivalents on the PC.

    I have no idea how to create the latter, but for the former you may dig up a program called dsFont which will do most of the work for you, leaving you with a pre-rendered image with each letter in a separate tile for you to "re-touch" where needed. If you won't be able to find it, PM me for a copy - it's freeware.
     
  4. iSubaru

    Member iSubaru Kitsune

    Joined:
    Apr 14, 2009
    Messages:
    358
    Location:
    Gensokyo
    Country:
    Poland
    Foxi4 You are 100% correct, that's how it goes
    Basically (but not exactly) it's like this
    - Free Line
    - Special characters and numbers
    - Capital Letters
    - Small Letters
    It's not exact because explaining it from table would take a bit of time...but idea is the same, it's BMP image with letters, symbols and numbers in their proper "slots" (XY positions)
    Dunno, maybe Devkitpro has example image somewhere? Like in "text" examples?
     
  5. Schmendrick

    Newcomer Schmendrick Advanced Member

    Joined:
    Sep 12, 2009
    Messages:
    55
    Country:
    Netherlands
    Another option is to use the 3D engine to display text. I made a little program that takes a font pcx file, and adds a header in front of it containing letter sizes. Then I just use the 3D engine to draw quads with the proper uv coordinates. Works like a charm! And without too much extra work allows you to scale and rotate everything.
     
  6. LeRodeur

    Member LeRodeur GBAtemp Regular

    Joined:
    Dec 12, 2009
    Messages:
    162
    Country:
    France
    Would be easier to do as said before, make a bmp with your file, convert it into a tileset in the good order with the ascii table so that when you have to draw a string you only have to do something like this
    For(i=0;*sting != /0;i++)
    Bgmap[x+(x+i)%32][y+(x+i)/32]=*string;
    string++;

    You could also check for /n etc
    the latter tool should place the characters in the right order
    the only problem is that you can't make your characters of various sizes
     
  7. Schmendrick

    Newcomer Schmendrick Advanced Member

    Joined:
    Sep 12, 2009
    Messages:
    55
    Country:
    Netherlands
    Yes, using a tiled bg may be easier, but much less flexible. My text system uses identical font images (or tilesets), it just uses the 3D engine to render them to the screen, and it allows for non-fixed width text, custom colors, etc. Anyway, I just figured I'd give another alternative to writing text to the screen :)
     
  8. LeRodeur

    Member LeRodeur GBAtemp Regular

    Joined:
    Dec 12, 2009
    Messages:
    162
    Country:
    France
    Actually, if he meant a font compatible with the iprintf function from libnds, it will be a bit more difficult to generate, as libnds seems not use the ascii, but a slightly different one (used in all nintendo ds games? with strange smileys etc)
    to see the table just use this litle code:
    Code:
    int i;
    char test[256];
    for (i=1;i
     
  9. CoolAs

    Newcomer CoolAs Advanced Member

    Joined:
    Oct 21, 2011
    Messages:
    75
    Country:
    Australia
    Hrm, well I know that Dirbaio made a .ttf to .bin (Dirbaio's own format) converter.
    Then he wrote some code to print user specified characters and strings (using the font from the .bin file) onto a bitmap background. It was commited to the home-smash svn repo ages a go... then was deleted.
    But if you checkout the current revision then run "svn update -r x" (replacing x fom 0 to 24) untill you find the font printing code... You will still have to ask him for the converter though - that was not commited at all, and I don't have a copy of it.
     

Share This Page