coastline 0.0.4
Loading...
Searching...
No Matches
coastline::MenuText Class Reference

The two fonts of the menus, their gradients, and the layout of their glyphs. More...

#include <menutext.h>

Public Member Functions

 ~MenuText ()
 Release font textures before the renderer's GPU device is destroyed.
 MenuText (const MenuText &)=delete
 Prevent copying GPU-backed font resources.
MenuText & operator= (const MenuText &)=delete
 Prevent assignment of GPU-backed font resources.
void Draw (SceneRenderer &renderer, std::string_view text, int x, int y, const TextStyle &style, const Matrix4 &projection) const
 Draw a string as DrawText() of the console draws it on a frame of high resolution.
int Width (std::string_view text, int size, bool doubled=true) const

Static Public Member Functions

static std::unique_ptr< MenuText > Load (SceneRenderer &renderer, const std::filesystem::path &fonts)
 Read the fonts of a release.

Detailed Description

The two fonts of the menus, their gradients, and the layout of their glyphs.

Constructor & Destructor Documentation

◆ ~MenuText()

coastline::MenuText::~MenuText ( )

Release font textures before the renderer's GPU device is destroyed.

◆ MenuText()

coastline::MenuText::MenuText ( const MenuText & )
delete

Prevent copying GPU-backed font resources.

Member Function Documentation

◆ Load()

std::unique_ptr< MenuText > coastline::MenuText::Load ( SceneRenderer & renderer,
const std::filesystem::path & fonts )
static

Read the fonts of a release.

Parameters
rendererThe renderer that draws the text.
fontsThe fonts directory of the import, with fonts.json.
Returns
The fonts, or nothing with the reason logged.

◆ operator=()

MenuText & coastline::MenuText::operator= ( const MenuText & )
delete

Prevent assignment of GPU-backed font resources.

◆ Draw()

void coastline::MenuText::Draw ( SceneRenderer & renderer,
std::string_view text,
int x,
int y,
const TextStyle & style,
const Matrix4 & projection ) const

Draw a string as DrawText() of the console draws it on a frame of high resolution.

Parameters
rendererThe renderer of the frame.
textThe string in UTF-8, with the colour codes of the console. A character without a glyph is not drawn. Each line after a newline is drawn as a string of its own, at TextStyle::lineGaps or TextStyle::lineHeight below the line before.
xThe left, centre, or right of each line, in pixels of the 320 by 240 screen.
yThe baseline of the first line, in pixels of the 320 by 240 screen.
styleHow the string is drawn.
projectionThe matrix from the 640 by 480 screen to the frame.

◆ Width()

int coastline::MenuText::Width ( std::string_view text,
int size,
bool doubled = true ) const
Parameters
textThe string in UTF-8.
sizeThe height of the text, in pixels of the 320 by 240 screen.
doubledWhether the size is of the 320 by 240 screen a frame of high resolution doubles, or of the 640 by 480 screen as it is.
Returns
The width of the string as MeasureTextWidth() of the console measures it, or of its widest line when it has a newline.

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