OpenTTD Source 20261112-master-gbcbec5e63f
FontState Class Reference

Text drawing parameters, which can change while drawing a line, but are kept between multiple parts of the same text, e.g. More...

#include <gfx_layout.h>

Inheritance diagram for FontState:
Font

Public Member Functions

 FontState ()=default
 Create the font state with an invalid state.
 FontState (FontSize fontsize, ExtendedTextColour colour)
 Create the font state.
auto operator<=> (const FontState &) const =default
 Compare with another instance of this class.
void SetColour (ExtendedTextColour c)
 Switch to new colour c.
void PopColour ()
 Switch to and pop the last saved colour on the stack.
void PushColour ()
 Push the current colour on to the stack.
void SetFontSize (FontSize f)
 Switch to using a new font f.
Public Member Functions inherited from Font
constexpr auto operator<=> (const Font &) const =default
 Compare with another instance of this class.
FontCache & GetFontCache () const
 Get the font cache of this font.

Data Fields

std::vector< ExtendedTextColour > colour_stack
 Stack of colours to assist with colour switching.
Data Fields inherited from Font
FontSize fontsize = FontSize::End
 The font size.
ExtendedTextColour colour = TextColour::Invalid
 The text colour.

Detailed Description

Text drawing parameters, which can change while drawing a line, but are kept between multiple parts of the same text, e.g.

on line breaks.

Definition at line 43 of file gfx_layout.h.

Constructor & Destructor Documentation

◆ FontState()

FontState::FontState ( FontSize fontsize,
ExtendedTextColour colour )
inline

Create the font state.

Parameters
colourThe colour of the font.
fontsizeThe size of the font.

Definition at line 55 of file gfx_layout.h.

References Font::colour, and Font::fontsize.

Member Function Documentation

◆ operator<=>()

auto FontState::operator<=> ( const FontState & ) const
default

Compare with another instance of this class.

Returns
The std::strong_ordering of the comparison.

References FontState().

◆ PopColour()

void FontState::PopColour ( )
inline

Switch to and pop the last saved colour on the stack.

Definition at line 77 of file gfx_layout.h.

References colour_stack, and SetColour().

Referenced by GetLayouter().

◆ PushColour()

void FontState::PushColour ( )
inline

Push the current colour on to the stack.

Definition at line 87 of file gfx_layout.h.

References Font::colour, and colour_stack.

Referenced by GetLayouter().

◆ SetColour()

void FontState::SetColour ( ExtendedTextColour c)
inline

Switch to new colour c.

Parameters
cNew colour to use.

Definition at line 67 of file gfx_layout.h.

References Begin, ExtendedTextColour::colour, Font::colour, End, ExtendedTextColour::flags, Forced, Invalid, IsPaletteColour, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by GetLayouter(), and PopColour().

◆ SetFontSize()

void FontState::SetFontSize ( FontSize f)
inline

Switch to using a new font f.

Parameters
fNew font to use.

Definition at line 96 of file gfx_layout.h.

References Font::fontsize.

Referenced by GetLayouter().

Field Documentation

◆ colour_stack

std::vector<ExtendedTextColour> FontState::colour_stack

Stack of colours to assist with colour switching.

Definition at line 45 of file gfx_layout.h.

Referenced by PopColour(), and PushColour().


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