Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
Classes | Functions
font.cpp File Reference
#include "psyqo/font.hh"
#include <EASTL/atomic.h>
#include <stdarg.h>
#include <cstdint>
#include "common/syscalls/syscalls.h"
#include "common/util/sjis-fullwidth-ascii.hh"
#include "psyqo/gpu.hh"
#include "psyqo/kernel.hh"
#include "system-font.inc"
Include dependency graph for font.cpp:

Classes

struct  psyqo::FontBase::XPrintfInfo
 

Functions

int vxprintf (void(*func)(const char *, int, void *), void *arg, const char *format, va_list ap)
 Prints a formatted string to a callback.
 

Function Documentation

◆ vxprintf()

int vxprintf ( void(*)(const char *, int, void *)  func,
void *  arg,
const char *  format,
va_list  ap 
)

Prints a formatted string to a callback.

This function behaves mostly as you'd expect from a typical printf, with some extra formatting options: The '=' flag (similar to '-') causes the output to be centered in the appropriately sized field. The b field outputs an integer in binary notation. The c field now accepts a precision. The character output is repeated by the number of times the precision specifies. The ' field works like c, but takes as its character the next character of the format string, instead of the next. This is useful for when using the precision modifier. For example, ‘printf("%.78&rsquo;-")` prints 78 minus signs, the same as `printf("%.78c", '-')would. S will display a string that has its control characters escaped using the caret notation. For example, character 26, also known as EOF, will be displayed as ^Z. z will display a string, and immediately dispose of it using libc_free()‘. r will display a number as an English ordinal. For example, 1 will be displayed as "1st", 2 as "2nd", etc... Another difference with normal printf, is that %#x will output "0x0" instead of "0" for the value 0. Last but not least, the f, e, and a format specifiers are expecting fixed point values. The scale of the fixed point value will default to 4096 for f and e, and 1024 for a, making it suitable for displaying angles. The scale can be specified using the ’/' sign. For instance, "%8.3/255f" will render a fixed point number using 8 characters, with 3 decimal places, and a scale of 255. The f and a format specifiers will render the fixed point number as a signed number, while the e format specifier will render it as an unsigned one. Finally, the callback function will be called with the string to print, and the length of the string. The third argument will be the opaque pointer passed through. The xprintf variant is also available.

Parameters
funcThe callback function to use.
opaqueThe opaque pointer to pass to the callback.
fmtThe format string.
apThe vararg list of arguments.
Returns
int The number of bytes written.