wavelength 1.0.0
Loading...
Searching...
No Matches
RndFont Class Reference

Bitmap font, a grid of character cells in the texture of a material's first stage. More...

#include <rndfont.h>

Inheritance diagram for RndFont:
Collaboration diagram for RndFont:

Classes

class  CharInfo
 The placement of one character. More...

Public Member Functions

 RndFont (const char *pszName)
 Construct a font of one cell without a material or characters.
 ~RndFont () override
 Drop the reference on the material.
void * operator new (size_t nSize)
 Allocate a font, billed to the class name.
void operator delete (void *pBlock)
 Release a font.
void DumpText (PrnStream &stream) override
 Write a description of the font.
void Save (BinStream &stream) override
 Write the font.
void Replace (RndObject *pFrom, RndObject *pTo) override
 Replace the material when it is the object being replaced.
const char * ClassName () const override
 Report the class name.
void Copy (const RndObject *pSource, int nFlags) override
 Copy another font, then place the characters again.
void Load (BinStream &stream) override
 Read what Save() wrote, or an earlier version of it, then place the characters.
void Set (RndMat *pMat, const char *pszChars, float fRows, float fCols, float fSize, float fSpace)
 Set the material, the characters, and the grid, then place the characters.
void BuildCharMap ()
 Measure the cell of each character in the texture and record its placement.
CharInfo CellInfo (int nRow, int nCol) const
 Measure the opaque columns of one cell of the texture.
void CharUv (char ch, Vector2 &uvStart, Vector2 &uvEnd) const
 Report the texture coordinates of a character.
float CharWidth (char ch) const
 Report the advance of a character.
const String & GetChars () const
float GetCols () const
RndMat * GetMat () const
float GetRows () const
float GetSize () const
float GetSpace () const
Public Member Functions inherited from RndObject
 RndObject (const char *pszName)
 Construct an object and register it under a name.
virtual ~RndObject ()
 Notify every referrer, then erase the registration.
void SetName (const char *pszName)
 Register the object under a different name.
void AddRef (RndObject *pReferrer)
 Register an object as a store of a pointer to this one.
void RemoveRef (RndObject *pReferrer)
 Drop the first registration AddRef() made for a referrer.
const char * GetName () const
const std::list< RndObject * > & GetRefs () const
int GetInternal () const
void SetInternal (int nInternal)

Static Public Member Functions

static RndObject * New (const char *pszName)
 Create a font.

Static Public Attributes

static const char * sClassName
 The class name a .rnd file writes, Font.
static int sRev
 The format version Save() writes and Load() accepts.
Static Public Attributes inherited from RndObject
static constexpr int kCopyChildLists = 0x200
 The bit of the Copy() flags that copies the child lists of the mix-ins.

Protected Member Functions

void ReleaseRefs ()
 Drop the reference on the material.

Additional Inherited Members

Protected Attributes inherited from RndObject
std::list< RndObject * > mRefs
String mName

Detailed Description

Bitmap font, a grid of character cells in the texture of a material's first stage.

The RTTI includes the class name and records RndObject as the one base. The characters fill the cells row by row in the order mChars lists them.

Constructor & Destructor Documentation

◆ RndFont()

RndFont::RndFont ( const char * pszName)
explicit

Construct a font of one cell without a material or characters.

Parameters
pszNameThe registry key.
Ghidra address:
NTSC-U/C: 0x00226740
Ghidra address:
PAL: 0x0022f4f0

◆ ~RndFont()

RndFont::~RndFont ( )
override

Drop the reference on the material.

Ghidra address:
NTSC-U/C: 0x003822f0
Ghidra address:
PAL: 0x003f09f8

Member Function Documentation

◆ operator new()

void * RndFont::operator new ( size_t nSize)
inline

Allocate a font, billed to the class name.

Parameters
nSizeThe object size the compiler supplies.
Returns
The block.

◆ operator delete()

void RndFont::operator delete ( void * pBlock)
inline

Release a font.

Parameters
pBlockThe block.

◆ DumpText()

void RndFont::DumpText ( PrnStream & stream)
overridevirtual

Write a description of the font.

Parameters
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x00225e38
Ghidra address:
PAL: 0x0022ebf0

Reimplemented from RndObject.

◆ Save()

void RndFont::Save ( BinStream & stream)
overridevirtual

Write the font.

Parameters
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x00225f70
Ghidra address:
PAL: 0x0022ed28

Implements RndObject.

◆ Replace()

void RndFont::Replace ( RndObject * pFrom,
RndObject * pTo )
overridevirtual

Replace the material when it is the object being replaced.

Parameters
pFromThe object being replaced.
pToThe replacement, or null.
Ghidra address:
NTSC-U/C: 0x00225d90
Ghidra address:
PAL: 0x0022eb48

Implements RndObject.

◆ ClassName()

const char * RndFont::ClassName ( ) const
inlineoverridevirtual

Report the class name.

Returns
sClassName.
Ghidra address:
NTSC-U/C: 0x003823a8
Ghidra address:
PAL: 0x003f0ab0

Implements RndObject.

◆ Copy()

void RndFont::Copy ( const RndObject * pSource,
int nFlags )
overridevirtual

Copy another font, then place the characters again.

Parameters
pSourceThe font to copy from.
nFlagsThe set of fields to copy.
Ghidra address:
NTSC-U/C: 0x00226690
Ghidra address:
PAL: 0x0022f440

Implements RndObject.

◆ Load()

void RndFont::Load ( BinStream & stream)
overridevirtual

Read what Save() wrote, or an earlier version of it, then place the characters.

The characters of an early version are the printable ASCII range.

Parameters
streamThe stream to read from.
Ghidra address:
NTSC-U/C: 0x00226358
Ghidra address:
PAL: 0x0022f110

Implements RndObject.

◆ Set()

void RndFont::Set ( RndMat * pMat,
const char * pszChars,
float fRows,
float fCols,
float fSize,
float fSpace )

Set the material, the characters, and the grid, then place the characters.

A row or column count below 1 becomes 1. The name is inferred.

Parameters
pMatThe material.
pszCharsThe characters, in cell order.
fRowsThe number of rows of cells.
fColsThe number of columns of cells.
fSizeThe size of the characters.
fSpaceThe space between characters.
Ghidra address:
NTSC-U/C: 0x00225cc0
Ghidra address:
PAL: 0x0022ea78

◆ BuildCharMap()

void RndFont::BuildCharMap ( )

Measure the cell of each character in the texture and record its placement.

A character past the last cell is reported and ends the placement. The name is inferred.

Ghidra address:
NTSC-U/C: 0x00226080
Ghidra address:
PAL: 0x0022ee38

◆ CellInfo()

CharInfo RndFont::CellInfo ( int nRow,
int nCol ) const

Measure the opaque columns of one cell of the texture.

A cell without an opaque pixel is a quarter of the cell wide. A font without a texture reports zeros. The name is inferred.

Parameters
nRowThe row of the cell.
nColThe column of the cell.
Returns
The placement of the cell's character.
Ghidra address:
NTSC-U/C: 0x00225918
Ghidra address:
PAL: 0x0022e6d0

◆ CharUv()

void RndFont::CharUv ( char ch,
Vector2 & uvStart,
Vector2 & uvEnd ) const

Report the texture coordinates of a character.

A character the font does not have reports zeros. The name is inferred.

Parameters
chThe character.
uvStartReceives the top left corner.
uvEndReceives the bottom right corner.
Ghidra address:
NTSC-U/C: 0x00226840
Ghidra address:
PAL: 0x0022f5f0

◆ CharWidth()

float RndFont::CharWidth ( char ch) const

Report the advance of a character.

The name is inferred.

Parameters
chThe character.
Returns
The advance, or 0 for a character the font does not have.
Ghidra address:
NTSC-U/C: 0x002268f8
Ghidra address:
PAL: 0x0022f6a8

◆ New()

RndObject * RndFont::New ( const char * pszName)
inlinestatic

Create a font.

Parameters
pszNameThe registry key.
Returns
The font.
Ghidra address:
NTSC-U/C: 0x003823b8
Ghidra address:
PAL: 0x003f0ac0

◆ GetChars()

const String & RndFont::GetChars ( ) const
inline
Returns
The characters, in cell order.

◆ GetCols()

float RndFont::GetCols ( ) const
inline
Returns
The number of columns of cells.

◆ GetMat()

RndMat * RndFont::GetMat ( ) const
inline
Returns
The material whose first stage has the texture.

◆ GetRows()

float RndFont::GetRows ( ) const
inline
Returns
The number of rows of cells.

◆ GetSize()

float RndFont::GetSize ( ) const
inline
Returns
The size of the characters.

◆ GetSpace()

float RndFont::GetSpace ( ) const
inline
Returns
The space between characters.

◆ ReleaseRefs()

void RndFont::ReleaseRefs ( )
protected

Drop the reference on the material.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x00226050
Ghidra address:
PAL: 0x0022ee08

Member Data Documentation

◆ sClassName

const char* RndFont::sClassName
static

The class name a .rnd file writes, Font.

Ghidra address:
NTSC-U/C: 0x003b09b8
Ghidra address:
PAL: 0x0042f850

◆ sRev

int RndFont::sRev
static

The format version Save() writes and Load() accepts.

Ghidra address:
NTSC-U/C: 0x003b09bc
Ghidra address:
PAL: 0x0042f854

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