Results 1 to 8 of 8

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  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

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
  •