Code Monkey home page Code Monkey logo

ttf2ugui's Introduction

ttf2ugui

uGUI is a free open source graphics library for embedded systems. To display text, it uses bitmap/raster fonts, that are included in application as C-language structs & arrays. uGUI includes some fonts in itself, but I wanted to use some TrueType fonts.

I didn't find a tool that would convert a .ttf file into C structures used by uGUI easily, so I wrote one using Freetype library.

This is a simple utility to convert TrueType fonts into uGUI compatible structures. It reads font file, renders each character into bitmap and outputs it as uGUI compatible C structure.

Optionally it can display ascii art sample of font by using UGUI to render pixels as '*' with ansi escape sequences. Fonts generated with 8BPP show in blue pixels with less then 100% fill.

Please remember to respect font copyrights when converting.

Examples:

Convert font in Luna.ttf to 14 point size bitmap font for 140 DPI display:

ttf2ugui --font Luna.ttf --dpi 140 --size 14 --dump

Results are in Luna.c and Luna.h, just compile the .c and include .h in your uGUI application.

Show ascii art of same font:

ttf2ugui --font Luna.ttf --dpi 140 --size 14 --show "aString"

If you want to generate 8BPP fonts ( so you get anti alliased fonts ) use

ttf2ugui --font Luna.ttf --dpi 140 --size 14 --show "aString" --bpp=8

On MacOS, use ful path to the font ttf file, e.g.

ttf2ugui --font /System/Library/Fonts/Supplemental/Arial.ttf --dpi 140 --size 14

Compiling

To compile, freetype library is needed. Easiest way to get is to install suitable package for your operating system.

  • For FreeBSD, install "print/freetype2".
  • For Debian, install libfreetype6-dev with apt-get.
  • For MacOS, install freetype with brew.

Then, just type "make".

Please note that ugui.c and ugui.h in this repository are just copies from uGUI project and included only for definitions and simple font display operation. Maintenance and development to those files happens in uGUI project itself, not here.

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.