Results 1 to 8 of 8

Thread: Modern, opensource automaticly-growing runtime font packer for games

  1. #1

    Modern, opensource automaticly-growing runtime font packer for games



    I've taken a different approach to font rendering, this is an example implementation.

    In essence, it uses multiple texture sprite atlases, and depending on which characters you need, it will render them on the fly at runtime.
    In a proper game you would then update your texture in opengl via texsubimage2d.
    When creating a font atlas you pick your font (which can be a truetype font directly from file (it uses AddFontResourceEx) ), font size and textures size - based on max texture size that gpu supports.
    Then you pre-generate glyphs for say.. ansi character range, and if at later time your game needs chinise font characters it will add them to texture - texture atlas will automaticly grow and will allocate amout of additional textures that are needed based on texture atlas resolution.

    This in essence gives you really great control over your characters, you can easily add custom graphical hacks / characters into your fonts (like arrows, sprites, smileys).
    It is a really great for unicode support too - if your characters are not yet generated, it'll add new ones on the fly, if a player wants to write his name in chinise, korean or arabic it should all work properly.

    You can use one font atlas instance + one font size and then scale it in your gui app, or just use multiple instances of TFontAtlas for different font sizes and styles.

    Demo & implementaton requires vampyre imaging library - probably the best pascal image library in existing, you should be using this anyways

    Currently fonts are rendered via winapi using GetGlyphOutlineW - i hope to change this to lazfreetype or something else that is more pure pascal for portability - i'll take any help i can get, if anybody wants to do this.

    Benefits of this are.. you are not limited to few offline pre-generated fonts, you have access to all truetype fonts and all unicode characters with excellent rendering quality.
    Downsides: I can't think of any, prove me wrong


    Source code + test app implementation
    http://partyserver.us/temp/FontExperiment.rar

    The example uses partitions.pas which i cannot figure out who the real author or licence was, i guess original author was Nitrogen and / or Paul Nicholls?

    I've documented some places where the files could have came from but none has a license and no clear original author is mentioned, i'm not sure who nitrogen is or where to reach him to clarify this:

    // source: http://fpc4gp2x.eonclash.com/downloads/Partitions.pas
    // An updated version of the TPartition class that Nitrogen wrote for his Font Studio?
    // http://www.nitrogen.za.org/projectinfo.asp?id=12
    // http://www.pascalgamedevelopment.com...packer-project
    // http://web.archive.org/web/201010231...info.asp?id=12
    // http://borland.newsgroups.archived.a...806267270.html

    I'll put this on github later, my code (FontAtlas and demo) is under MIT license.
    Last edited by JernejL; 17-05-2018 at 08:25 AM.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  2. #2
    This is interesting.

    So, does it exports the generated atlas in to one or more bitmaps? And does it tell the UNICODE point range (or ranges) generated? I'm looking for a tool that allows to build bitmapped fonts to use with Allegro. Right now I'm using ASCII-127 only because I had to build them by myself with The GIMP, but I want to use UTF-8 enconding and it is quite annoying to use The GIMP for that (also I don't know what UNICODE points I should use ).

    [edit] You can see the format I'm looking for in this link.
    No signature provided yet.

  3. #3
    It generates bitmaps, and when you need additional characters it adds them to existing bitmaps, and if out of space it adds a new bitmap, i guess you could use it with that.

    character bindings are unicode, the example uses widechar winapi for rendering - we'd need to convert this somehow to freetype2.. freetype1 in lazarus repo is buggy as hell and can't use font hinting.

    if you use lazarus utf8string then you can do this to get unicode numbers:

    http://wiki.freepascal.org/UTF8_stri...UTF8_codepoint
    Last edited by JernejL; 17-05-2018 at 12:52 PM.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  4. #4
    Based on the information presented in the thread bellow the original author of partitions.pas is Nitrogen. but the unit was latter updated by Paul_Nicholls

    https://www.pascalgamedevelopment.co...partitions.pas

  5. #5
    Quote Originally Posted by SilverWarior View Post
    Based on the information presented in the thread bellow the original author of partitions.pas is Nitrogen. but the unit was latter updated by Paul_Nicholls

    https://www.pascalgamedevelopment.co...partitions.pas
    That's same conclusion i had, i'm not sure who nitrogen is irl and not sure on the license, but i think it's safe to say it's in public domain.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  6. #6
    Quote Originally Posted by Delfi View Post
    i'm not sure who nitrogen is irl and not sure on the license, but i think it's safe to say it's in public domain.
    I'm also not sure who Nitrogen is. But as far as licence goes I guess Paul will know best since he was the one who updated the code last. So it is best to ask him about that.

  7. #7
    Quote Originally Posted by SilverWarior View Post
    I'm also not sure who Nitrogen is. But as far as licence goes I guess Paul will know best since he was the one who updated the code last Pnr Status TextNow VPN. So it is best to ask him about that.
    To avoid it all,
    You can check the Font Studio by mikepote on bitbucket.org, its OPen Source (so Free).
    Last edited by NOUR; 14-02-2019 at 08:00 PM.

  8. #8
    Quote Originally Posted by NOUR View Post
    To avoid it all,
    You can check the Font Studio by mikepote on bitbucket.org, its OPen Source (so Free).
    It uses what looks like same unit (packing.pas), but it seems like it's an older or a modified version of it - https://bitbucket.org/mikepote/font-...e-view-default

    packing insert routine seems identical, except that it uses constants rather than enums, but the order of checks and all seems all identical, so i'd say this is same unit, or at least the files are related.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •