SPHERE FONTS IN C

C Source For Loading Sphere Fonts to SDL2 Surfaces

C source code to load a Sphere RFN font into an array of SDL2 surfaces. It is easily modified to load into another type of surface or image for other graphics libraries.

It provides a simple and efficient form of font loading and text writing for custom engines that use SDL2, much simpler and easier to get working than SDL_TTF, which uses TrueType fonts rather than bitmapped fonts, and requires freetype. It is also easy to modify to store the fonts in other surface formats, not just SLD2.

Fonts are loaded using standard C file streams on Windows, and memory mapped files (faster) on Linux, OS X, FreeBSD, Haiku, and most other Unix-like OSes. Font loading is also sensitive to the endianness of the host machine. It also provides a means to load fonts from a buffer in memory.

It includes a system font, 'cynical', which is a modified version of the Sphere 1.5 system font, as well as a smaller font called 'samson'. The system font can be included directly in the source by defining the macro EMBED_CYNICAL.

It has been tested in Windows 64-bit, Gentoo Linux amd64 and ARMv6/Raspberry Pi, OS X (intel), Solaris 10 ultrasparc, FreeBSD 10.1 amd64, and JavaScript with Emscripten.

Details

  • 16.2 KB
  • 34
  • 11/13/2023 11:26 PM

Actions