Nugget
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Friends | List of all members
psyqo::FontBase Class Referenceabstract

The Font drawing class. More...

#include <psyqo/font.hh>

Inheritance diagram for psyqo::FontBase:
Inheritance graph
[legend]

Classes

struct  GlyphsFragmentPrologue
 
struct  XPrintfInfo
 

Public Member Functions

virtual ~FontBase ()
 
void uploadSystemFont (GPU &gpu, Vertex location={{.x=960,.y=464}})
 Uploads the system font to VRAM, and initializes the object.
 
void uploadKromFont (GPU &gpu, Vertex location={{.x=960,.y=422}})
 Uploads the Kernel rom font to VRAM, and initializes the object.
 
void initialize (GPU &gpu, Vertex location, Vertex glyphSize)
 Initializes the object for use.
 
void print (GPU &gpu, eastl::string_view text, Vertex pos, Color color)
 These method immediately print text to the screen.
 
void print (GPU &gpu, eastl::string_view text, Vertex pos, Color color, eastl::function< void()> &&callback, DMA::DmaCallback dmaCallback)
 
void print (GPU &gpu, const char *text, Vertex pos, Color color)
 
void print (GPU &gpu, const char *text, Vertex pos, Color color, eastl::function< void()> &&callback, DMA::DmaCallback dmaCallback)
 
void printf (GPU &gpu, Vertex pos, Color color, const char *format,...)
 
void printf (GPU &gpu, Vertex pos, Color color, eastl::function< void()> &&callback, DMA::DmaCallback dmaCallback, const char *format,...)
 
void vprintf (GPU &gpu, Vertex pos, Color color, const char *format, va_list ap)
 
void vprintf (GPU &gpu, Vertex pos, Color color, eastl::function< void()> &&callback, DMA::DmaCallback dmaCallback, const char *format, va_list ap)
 
void chainprint (GPU &gpu, eastl::string_view text, Vertex pos, Color color)
 These methods use the DMA chaining system to print text to the screen.
 
void chainprint (GPU &gpu, const char *text, Vertex pos, Color color)
 
void chainprintf (GPU &gpu, Vertex pos, Color color, const char *format,...)
 
void chainvprintf (GPU &gpu, Vertex pos, Color color, const char *format, va_list ap)
 

Static Public Member Functions

static void unpackFont (GPU &gpu, const uint8_t *data, Vertex location, Vertex textureSize)
 Unpacks and uploads a font to VRAM.
 

Protected Types

typedef Fragments::FixedFragmentWithPrologue< GlyphsFragmentPrologue, Prim::Sprite, 48 > GlyphsFragment
 

Protected Member Functions

virtual GlyphsFragmentgetGlyphFragment (bool increment)=0
 
virtual void forEach (eastl::function< void(GlyphsFragment &)> &&cb)=0
 
void innerprint (GlyphsFragment *fragment, GPU &gpu, eastl::string_view text, Vertex pos, Color color)
 
void innerprint (GlyphsFragment *fragment, GPU &gpu, const char *text, Vertex pos, Color color)
 
void innervprintf (GlyphsFragment *fragment, GPU &gpu, Vertex pos, Color color, const char *format, va_list ap)
 

Friends

struct XPrintfInfo
 

Detailed Description

The Font drawing class.

This class is used to draw text to the screen. It is a template class that takes a number of fragments as a template parameter. The number of fragments determines how many times a chainprint can be called. If not using chainprint, then the number of fragments is irrelevant, and should be set to 1. The font is expected to be uploaded to VRAM before use. It is expected to be a 4bpp texture, 256 pixels wide. While the location and size are user-defined, it is the user's responsibility to ensure that the font properly fits in a texture page. It should be in ASCII order, with the first character being ASCII 0x20 (space), which has to be completely transparent. Even though the font is 4bpp, it really should be monochrome, with the color being set by the color parameter of the various print methods.

Member Typedef Documentation

◆ GlyphsFragment

Constructor & Destructor Documentation

◆ ~FontBase()

virtual psyqo::FontBase::~FontBase ( )
inlinevirtual

Member Function Documentation

◆ chainprint() [1/2]

void psyqo::FontBase::chainprint ( GPU gpu,
const char *  text,
Vertex  pos,
Color  color 
)

◆ chainprint() [2/2]

void psyqo::FontBase::chainprint ( GPU gpu,
eastl::string_view  text,
Vertex  pos,
Color  color 
)

These methods use the DMA chaining system to print text to the screen.

These methods use the DMA chaining system to print text to the screen. They are meant to be used when constructing a frame using DMA chaining. When not using DMA chaining, you should use the print method family instead. See the GPU class for more details on DMA chaining.

◆ chainprintf()

void psyqo::FontBase::chainprintf ( GPU gpu,
Vertex  pos,
Color  color,
const char *  format,
  ... 
)
inline

◆ chainvprintf()

void psyqo::FontBase::chainvprintf ( GPU gpu,
Vertex  pos,
Color  color,
const char *  format,
va_list  ap 
)

◆ forEach()

virtual void psyqo::FontBase::forEach ( eastl::function< void(GlyphsFragment &)> &&  cb)
protectedpure virtual

◆ getGlyphFragment()

virtual GlyphsFragment * psyqo::FontBase::getGlyphFragment ( bool  increment)
protectedpure virtual

◆ initialize()

void psyqo::FontBase::initialize ( GPU gpu,
Vertex  location,
Vertex  glyphSize 
)

Initializes the object for use.

When using your own font, you should call this method to initialize the Font object. This includes when using the unpackFont method. This method should not be called if you are using the uploadSystemFont method.

Parameters
locationThe location of the font in VRAM.
glyphSizeThe size of each glyph in the font.

◆ innerprint() [1/2]

void psyqo::FontBase::innerprint ( GlyphsFragment fragment,
GPU gpu,
const char *  text,
Vertex  pos,
Color  color 
)
protected

◆ innerprint() [2/2]

void psyqo::FontBase::innerprint ( GlyphsFragment fragment,
GPU gpu,
eastl::string_view  text,
Vertex  pos,
Color  color 
)
protected

◆ innervprintf()

void psyqo::FontBase::innervprintf ( GlyphsFragment fragment,
GPU gpu,
Vertex  pos,
Color  color,
const char *  format,
va_list  ap 
)
protected

◆ print() [1/4]

void psyqo::FontBase::print ( GPU gpu,
const char *  text,
Vertex  pos,
Color  color 
)

◆ print() [2/4]

void psyqo::FontBase::print ( GPU gpu,
const char *  text,
Vertex  pos,
Color  color,
eastl::function< void()> &&  callback,
DMA::DmaCallback  dmaCallback 
)

◆ print() [3/4]

void psyqo::FontBase::print ( GPU gpu,
eastl::string_view  text,
Vertex  pos,
Color  color 
)

These method immediately print text to the screen.

These methods immediately print text to the screen. They are meant to be used when not using DMA chaining. When using DMA chaining, you should use the chainprint method family instead. When a callback is provided, it will be called when the text has been printed, while the method will return immediately. See the GPU class for more details on DMA callbacks.

◆ print() [4/4]

void psyqo::FontBase::print ( GPU gpu,
eastl::string_view  text,
Vertex  pos,
Color  color,
eastl::function< void()> &&  callback,
DMA::DmaCallback  dmaCallback 
)

◆ printf() [1/2]

void psyqo::FontBase::printf ( GPU gpu,
Vertex  pos,
Color  color,
const char *  format,
  ... 
)
inline

◆ printf() [2/2]

void psyqo::FontBase::printf ( GPU gpu,
Vertex  pos,
Color  color,
eastl::function< void()> &&  callback,
DMA::DmaCallback  dmaCallback,
const char *  format,
  ... 
)
inline

◆ unpackFont()

void psyqo::FontBase::unpackFont ( GPU gpu,
const uint8_t *  data,
Vertex  location,
Vertex  textureSize 
)
static

Unpacks and uploads a font to VRAM.

This method unpacks and uploads a font to VRAM. The compressed font data is expected to be in the format generated by the font-compress.lua script. See this script for more details.

◆ uploadKromFont()

void psyqo::FontBase::uploadKromFont ( psyqo::GPU gpu,
psyqo::Vertex  location = {{.x = 960, .y = 422}} 
)

Uploads the Kernel rom font to VRAM, and initializes the object.

This method uploads the built-in Kernel rom font to VRAM, and initializes the object. There is no need to call this method if you are using your own font. Also, when using this method, you should not call initialize() afterwards. The Kernel rom font is a 16x15 font created by Sony, and built into the PSX rom chip. Its appearance is variable, depending on the version of the PSX bios. It may not be available on all PSX models. The footprint for this font is 192 bytes of read-only data, and a 256x90x4bpp texture. This font isn't going to work if psyqo took over the kernel. See the Kernel namespace for more information.

◆ uploadSystemFont()

void psyqo::FontBase::uploadSystemFont ( psyqo::GPU gpu,
psyqo::Vertex  location = {{.x = 960, .y = 464}} 
)

Uploads the system font to VRAM, and initializes the object.

This method uploads the built-in system font to VRAM, and initializes the object. There is no need to call this method if you are using your own font. Also, when using this method, you should not call initialize() afterwards. The footprint for this font is 877 bytes of read-only data, and a 256x48x4bpp texture. It is a 8x16 clean and simple ASCII font called mig68000, available for free with attribution, made by Zingot Games. See https://www.zingot.com/ and https://zingot.itch.io/fontpack

◆ vprintf() [1/2]

void psyqo::FontBase::vprintf ( GPU gpu,
Vertex  pos,
Color  color,
const char *  format,
va_list  ap 
)

◆ vprintf() [2/2]

void psyqo::FontBase::vprintf ( GPU gpu,
Vertex  pos,
Color  color,
eastl::function< void()> &&  callback,
DMA::DmaCallback  dmaCallback,
const char *  format,
va_list  ap 
)

Friends And Related Symbol Documentation

◆ XPrintfInfo

friend struct XPrintfInfo
friend

The documentation for this class was generated from the following files: