Code Monkey home page Code Monkey logo

easy-sdf-font's Introduction

easy-sdf-font banner

A single-file small embeddable single-stroke font for use with existing signed distance field (SDF) text rendering engines.

Only supports the 95 ASCII printable characters (space to tilde).

1. Why?

I needed a small embeddable font for use as a debug/fallback font for SDF text rendering.

Truetype outline fonts were ruled out because SDF generation is very expensive for them (around 5-9x slower compared to single-stroke fonts, the pause becomes noticeable to the user with Javascript which runs around 3x slower compared to C).

SDF font atlas generation for single-stroke fonts, on the other hand, is very cheap since the formula for the distance to a straight line is very simple.

On my system with -O2, easy-sdf-font.h takes around 3ms for SDF generation, whereas a truetype outline font (with stb_truetype) takes around 21ms.

2. Usage

Two implementations are provided: easy_sdf_font.h (for C) and easy_sdf_font.js (for Javascript).

See the header comments of those files or demo.c/demo.html for information of how to use them.

easy-sdf-font demo screenshot
Figure 1. Screenshot of demo.c / demo.html

3. License

Public domain.

easy-sdf-font's People

Contributors

pyokagan avatar

Stargazers

 avatar

Watchers

 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.