Giter VIP home page Giter VIP logo

sdl_inprint's Introduction

SDL_inprint

Add simplest text output to your SDL program. Inline font included. Font collection included.

Has almost no good use cases; however, I found myself reusing this code/font format over and over, so maybe you would find some use for it too.

  • If you're serious about inlining your images, use something like GRIT instead.
  • If you're serious about bitmap fonts, a meta-data-less bitmap is not enough, use Sfont instead.
  • If you're really serious about fonts, and want Unicode and italics and everything, use SDL_ttf instead.

how to use

Build inprint.c with your project. Bundle inline_font.h. Include SDL_inprint.h.

Now, you can:

    screen = SDL_SetVideoMode(width, height, bpp, flags);

    prepare_inline_font();

    incolor(0xFF0000, 0x333333);
    inprint(screen, "Hello World!", 10, 10);

    kill_inline_font();

The whole demo is in 'example.c'.

You can also do something like

    infont(SDL_LoadBMP("fontfile.bmp")); //use bitmap font

and

    infont(NULL); //revert to inline font

You would also probably want to automate the inlining into the build process, which shouldn't be hard. See 'Makefile' for an example.

SDL2

SDL2 version also exists, with a slightly different API. See SDL2_inprint.h, inprint2.c and example2.c.

font collection

All the fonts in the 'fonts/' directory are free (or should be free, correct me when I'm wrong) and adhere to the convention described below. Feel free to add your fonts or make old ones prettier (it's actually quite fun to work on bitmap fonts even if you're not that good at graphics).

bitmap fonts

  • First half of ASCII table (128 symbols).
  • Formatted as 16 x 8 table.
  • Color 0 is background.
  • Color 1 is foreground.
  • One Bit Per Pixel. 1BPP. Bitmap.

inline fonts

Inline fonts are in XBM format.

You can generate them, using the included bmp2xbm tool.

sdl_inprint's People

Contributors

driedfruit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.