What is freetype?

simply put freetype is a text rendering library that''s used across different platforms for a variety of different reasons, that''s also true for text in game.

if you haven''t heard of freetype before, then you might be surprised to learn that there is a good chance the text you''re reading right now is rendered using the freetype2 library, especially if you''re on Linux based OS, Android or iOS.

What is libPS4freetype2?

libPS4freetype2 is a simple wrapper around the original upstream freetype2 library that I wrote that (I hope) simplifies the process of printing text on the screen.

At the time of writing the only other text rendering solution for the PS4 was from @TheoryWrong, PR, which used the linux kernel text rendering method, which by nature prints really simple text as the kernel doesn''t really need to render fancy text of different style or of different font size so the results where limited and somewhat crude. which is where this library comes in.

How-To-Add the library to your app

  • clone the github project into your app (into project root or perhaps if you''d like to be tidy into a folder called extern)
    • git clone
    • cd libPS4freetype2 followed by git submodule update --init
  • if you followed my last post and setup your app with cmake then adding this to your app is as simple as adding the following lines to your CMakeLists.txt
# this goes after project() in your app
if (NOT TARGET PS4freetype2)
# this goes just after your add_executable()
target_link_libraries(whateveryourappiscalled PS4freetype2)
  • what if your app is not setup with cmake?
    1. you''ll have to compile this project manually with cmake
    2. copy the includes & library over to your app
      • or you could just point your makefile at them


how to use the library to render text
as of this writing we only have one library/method for rendering/printing pixels into the screen and that''s using @psxdev''s (bigboss) liborbis2d library, so by nature you will still need to use that to render the resulting text to the screen.

  • if you''re using C
    • initPS4FreeType(int height, int width, DrawText drawText) should be called 1st, height/width is the screen height/width, while DrawText is a pointer to the draw method provided by your app that takes 3 parameters int x, int y, int color e.g orbis2dWritePixelColor()
      • this is how this would look like initPS4FreeType(720, 1280, &orbis2dWritePixelColor);
    • drawPS4FreeTypeText(int x, int y, const char *text, int size, int color) is self explanatory, x/y are screen positions, size is point per 30 dpi, color is in the format your draw method takes
      • color is expected in RGB format 0x80000000|R<<16|G<<8|B
    • addFontPS4FreeType(char* filename) takes path location to otf or ttf font, on success return value font_index > 0, on fail returns -1
    • drawCustomFontPS4FreeTypeText(int x, int y, const char *text, int size, int color, int font_index) works the same as drawPS4FreeTypeText() except the method requires font_index which is provided by addFontPS4FreeType()
  • if you''re using C++
    • methods work exactly the same, as they''re merely wrappers for convenience
    • PS4freetype2(int height, int width, DrawText drawText) the constructor takes place instead of initPS4FreeType()
    • there is no equivalent to finishPS4FreeType(), as it will be called automatically on deconstructor
    • since C++ methods can be overloaded drawCustomFontText() will be removed in-favour of an overloaded drawText() method


  • I haven''t tested the C++ methods yet, but i don''t expect any issues since they''re just wrappers over the C methods
  • DrawText will be updated in the feature to reflect the available rendering method that will exist
  • currently the current rendering method orbis2dWritePixelColor() does not support alpha rendering, as such the text will not look as smooth as it can/should
  • "You said freetype2 can be compiled directly from upstream, does that mean we don''t have to use libPS4freetype2?"
    • yup, if you like to use upstream directly without the wrapper you can clone upstream from adding it to your app will work much the same way, except you''ll have to call freetype methods directly instead of the ones mentioned above.
  • "The PS4 already has freetype2 support, why shouldn''t i just use that and why did you decide not to support it?"
    • there are few reasons
      • to start as of this post the freetype2 library interface has not been reverse engineered as such it''s not accessible
      • this project also came about as I was working on cmake, it took Zer0 effort to build the library from source, so I decided to work with it
      • fun fact, I also don''t own a hackable console (and likely won''t for the foreseeable future, as I''m a digital gamer with over 50(+?) PS4 games on PSN so I''m usually always close to latest FW) as such it was much easier to work with the upstream library which is fully documented, as oppose to attempting to reverse engineer the PS4 builtin implementation with plenty of guess work, trail and error.


  • Special Thanks to @ZeraTron_ for the time he spent testing this for me

With all that said the pictures below are to show case the progress from Zer0 until fully working :)








Post Cover image: