Giter Club home page Giter Club logo

love2d-bitmap-font-renderer's Introduction

A bitmap font renderer for love2d 0.10 using canvas and JS.

Worked fine in Firefox from day 1. Now works in Chrome too, after some serious hacking. If you get sans-serif please refresh the page O:)

The font used in the example comes from here:
https://www.behance.net/gallery/31268855/Determination-Better-Undertale-Font

What it does

var s = 2;
bitmapFontRenderer({
    font: 'DeterminationMonoWeb',
    ext: 'woff',
    size: 20*s,
    color: '#FFF',
    splitColor: '#F0F',
    splitW: s,
    gap: s,
    characters: ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.!?;:-_/|\\!\'"+*()[]{}&%$#@',
    //roundTo: 64,
    draw: function(c, ch, x, y, o) {
        c.fillStyle = '#00F';
        c.fillText(ch, x-s, y);
        c.fillText(ch, x+s, y);
        c.fillText(ch, x, y-s);
        c.fillText(ch, x, y+s);
        c.fillStyle = o.color;
        c.fillText(ch, x, y);
    }
});

and you get...

bitmap font result

Use Right click > Save image as... to save it

Params

  • all units in pixels
  • font and ext define the font family and filename to use
  • size determines the font height
  • color sets the font rendering color (ommit if you just want to render the splits in isolation)
  • splitColor sets the split color, ie. colored gaps between colors, searched for by love2d. (ommit if you just want to render the font itself and overlay the splits in photoshop/gimp/etc)
  • splitW sets the split width (use 1 or more so love2d works)
  • gap is only relevant for giving characters space for effects such as strokes, shadows, etc.
  • characters is the set of characters to render. save these for usage in love2d too
  • roundTo, if set, sets the image size to the nearest multiple of the number given (ex: 64)
  • draw is an optional function. if set, is used to render each character. signature is function(c, ch, x, y, o) where c is the context, ch character being rendered, x and y are coordinates and o are the options passed to the main function.

TODO

  • add simple form GUI
  • increase browser compatibility

love2d-bitmap-font-renderer's People

Contributors

josepedrodias avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.