Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Font txt format? — Gideros Forum

Font txt format?

malessandrinimalessandrini Member
edited February 2014 in General questions
Hi, I'm new to Gideros but very excited to try it!
I'm trying to port an old (free) PC game to android as an exercise, and it has a font already in png format (with characters in a grid). Now, the Font Creator takes a ttf font file and generates a png+txt, but there's no way of starting from a png, in other words I need the matching txt file. I can try to guess its format from a generated one, but is there a safer way? Possibly a little documentation on its format would be enough.
Thank you very much
Michele

Comments

  • Basically you need to generate an .fnt format from your png, I have not seen full blown solutions for this, but there were some provided tools outside Gideros, like this one:
    http://www.html5gamedevs.com/topic/1743-how-to-create-fnt-file-from-bitmap-font/?p=13436
  • Hi, thank you for your reply, I'm not sure what a .fnt file is, Gideros uses a simple txt file with (if I'm right) the coordinate of every glyph in the bitmap, so I think there should be a more direct approach instead of passing through a font format and back...
    Bye
    Michele
  • What I meant was that you can load BMFonts with Font object like this:
    Font.new("font.fnt", "font.png")

    Or name it txt if you want, it does not matter :)
    The format is called .fnt which can be also generated by GlyphDesigner or BMFont generator, etc.

    But what you need is the reverse tool, which I think the one I provided in the link should help you with ;)
  • But you have to go through two other programs, and I cannot even download the code from that forum without registering.

    Can we have an explanation of the txt format? It's so simple, it should not be industry secret :-)

    Thanks
    Michele
  • update: in another post (http://giderosmobile.com/forum/discussion/65/is-unicode-supported/p1) atilim posted an example, where the txt file is only numbers, but if I produce one with Font Creator is more complex, with tags, etc...

    I'd be happy with the numbers-only format, too, maybe can it be simplified further?

    Bye
    Michele
  • another update:

    Ok, I managed to start from a txt generated by Gideros Font Creator and recreate it for my bitmap font.

    I did a little lua program to generate it (just to practice lua!), I post it here if it can be useful to someone else (it only works for fixed width characters):
    #! /usr/bin/lua
     
    w = 64  -- png width
    h = 192   -- png height
    nx = 8   -- number of characters on x
    ny = 12  -- number of characters on y
     
     
    id = 32
    stepx = w / nx
    stepy = h / ny
    print("common lineHeight=" .. stepy .. "  base=0")
    print("page id=0")
    print("chars count=" .. nx *ny)
    for j = 0, ny -1 do
    	for i = 0, nx - 1 do
    		io.write("char id=" .. id)
    		id = id + 1
    		io.write("  x=" .. stepx * i .. "  y=" .. stepy * j)
    		io.write("  width=" .. stepx .. "  height=" .. stepy)
    		io.write("  xoffset=0  yoffset=0")
    		io.write("  xadvance=" .. stepx)
    		io.write("  page=0")
    		print()
    	end
    end
    Bye!

    Likes: GregBUG

    +1 -1 (+1 / -0 )Share on Facebook
  • ar2rsawseenar2rsawseen Maintainer
    edited February 2014
    @malessandrini sorry for misunderstanding, I meant the fnt is the format used in txt, you can look for it on the internet, probably there should be some sort of description, it is not Gideros internal format, but widely used bitmap font format :)

    I unfortunately don't know it from the top of my head ;)
  • No no you've been very kind and clear, thank you.

    Bye
    Michele
Sign In or Register to comment.