Giter VIP home page Giter VIP logo

libpsf's Introduction

libpsf:

This is a simple library that can be used to read PSF format fonts (Linux console fonts). With this library, you can render text on the screen without using overly complicated TTF fonts. This library works with both type 1 and type 2 PSF fonts. It can also read gzipped fonts if built with zlib support (default).

Full credit to the original author โ†’ prushik better know as maintainer of betteros.org (no pun intended).

Disclaimer:

This library is made to be useful for people who want to use it for what it was meant to do. If you are not one of those people, then don't get mad.

Intro:

The purpose of this library is to read files in the PC Screen Font format (PSF) and prepare the data so that it can be displayed on the screen. PC Screen Fonts are very useful fonts, particularly on Linux machines. Because PSF is a bitmap font format, it is not scalable, and hence not perfect for all applications. However, it can be rendered much faster than vector fonts and most applications do not require font scaling. Plus, on Linux computers, these fonts are already present (Linux Console Fonts), meaning that they do not need to be distributed with your Linux software. Also, the format is very simple can be read with low overhead, which is what this library aims to do. This library is useful in applications such as small game. since these typically do not require scalable fonts. Many other lightweight applications may benefit from this library as well due to its small size and simplicity.

Caveats:

Linux Console Fonts are typically gzipped, so the library must be built with zlib support in order to work with some stock Linux distributions (Ubuntu).

Building and Installing:

Building & installing is simple

  • native
make
make install
  • cross-compile
export CC=${CROSS_COMPILE}gcc
export SYSROOT=<path_to_sdk_sysroot>
make

If you wish to install in a different location, use the PREFIX environment variable while installing. If you want to build without zlib support, then add "-DNO_ZLIB" to the CFLAGS environment variable while compiling.

If you wish to compile without libc support, add "-DNO_CLIB" to CFLAGS. This requires disabling zlib as well. This assumes you have an implementation of several functions including memcpy and several syscall functions. Examples are included in amd64_syscalls.s and mem.s, although some versions of gcc also provide a usable built-in memcpy implementation.

Build an example to display psf font with SDL1.2 backend (showpsf.c):

  • native
make install
make example
  • cross-compile
export CC=${CROSS_COMPILE}gcc
export SYSROOT=<path_to_sdk_sysroot>
make install
make example-dist

# then copy "dist/" to your target machine and run "showpsf.sh" script

Run binary:

./showpsf #use "font.psf" in CWD

--or--

./showpsf <font_name.psf> #pass [arg] as PSF font

Add "-DINPUT_STR" to show chars only passed by kbd inputs, otherwise display all glyphs (default).

Using:

Include psf.h in your application. It is possible to link dynamically, but this is not recommended for releases, linking statically or including libpsf.c in your project is the recommended usage since it avoids adding a runtime dependency.

API documentation is found in the file called API.

libpsf's People

Contributors

deeice avatar apaczer avatar misson20000 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.