Giter Site home page Giter Site logo

gstxt's Introduction

GrooveStomp's Text Renderer

GPLv3 license Reference Documentation

This is a small demonstration program I put together to understand how to use stb_truetype.h. It creates a window and renders the text parameter to the window based on the parameters specified.

Development

Requirements

  • make
  • gcc
  • sdl2
  • doxygen (For documentation generation)

This is developed for Linux and no effort has been made to support it elsewhere. That said, with the exception of main.c using getopt.h for arg parsing and time.h for nanosleep(), I think the rest of the code should compile with little to no issue on other platforms. I would expect this to build on OSX with little issue.

Building

There are four targets in the Makefile:

  • clean
  • debug
  • release
  • docs

The default target is release. release builds gstxt at release/gstxt. debug builds gstxt at debug/gsxtxt. docs builds the documentation with Doxygen.

Usage

There is help built into the program. Invoke the program with -h or --help:

debug/gstxt -h
Usage: gstxt text [OPTIONS] ttf_file

Renders text on screen in software.

OPTIONS:
    --help|-h:   Show this help text
    --width|-w:  Screen width (defaults to 600)
    --height|-v: Screen height (defaults to 300)
    --x:         Text x position (defaults to 20)
    --y:         Text y position (defaults to 150)
    --scale|-s:  Scale of text (defaults to 40)
    --fg|-f:     Foreground color as a 32-bit hexadecimal RGBA value (defaults to 0x000000FF)
    --bg|-b:     Background color as a 32-bit hexadecimal RGBA value (defaults to 0xFFFFFFFF)

Here's a sample invocation that changes several attributes of the resulting image:

debug/gstxt "a quick brown fox jumped" /usr/share/fonts/truetype/noto/NotoMono-Regular.ttf -f 0xFF00FFFF -b 0x000000ff -v 150 -y 50 -s 80 -w 1000

ESC quits the program, as does closing the window.

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.