Skip to content

BusyStudent/Lilim

Repository files navigation

Lilim

nanovg fontstash reimplementation in C++.

Examples

#include "fontstash.hpp"
#include "fons_backend.hpp"

int main(){
    //Setup
    Llilim::Manager manager;
    auto face = manager.new_face(FACE_FILE,FACE_IDX);
    //Set DPI if you want
    face->set_dpi(96,96);
    
    Fons::Fontstash stash(manager);
    Fons::Context context(stash);

    int id = stash.add_font(face);

    //Using orginal C fontstash api
    FONStextIter iter;
    FONSquad     quad;
    fonsSetAlign(&context,FONS_ALIGN_LEFT | FONS_ALIGN_TOP);
    fonsSetSize(&context,12);
    fonsSetFont(&context,id);
    fonsTextIterInit(&context,&iter,0,0,"Hello",nullptr,FONS_GLYPH_BITMAP_REQUIRED);
    fonsTextIterNext(&context,&iter,&quad);
    //etc...
    //Or C++ style fontstash api
    context.set_font(id);
    context.set_size(12);

    //etc...

    //Or new style api 
    Fons::SDLTextRenderer renderer(sdl_render,stash);
    renderer.draw_text(0,0,"Hello World");
    renderer.flush();
    //Add your backend by inheriting Fons::TextRenderer

    //End
}

Portable

If you want to make them all into a file
Just run python3 make_all.py and you will got a file with all the source code.

Todo List

  • Add harfbuzz support.
  • Add Embedded bitmap font support.
  • Improve LCD Rendering mode support.

Fixme List

  • stb_truetype backend has some bugs(in kerning of big size).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages