OpenTTD Source  20241108-master-g80f628063a
FallbackParagraphLayout Class Reference

Class handling the splitting of a paragraph of text into lines and visual runs. More...

Inheritance diagram for FallbackParagraphLayout:
ParagraphLayouter

Data Structures

class  FallbackLine
 A single line worth of VisualRuns. More...
 
class  FallbackVisualRun
 Visual run contains data about the bit of text with the same font. More...
 

Public Member Functions

 FallbackParagraphLayout (char32_t *buffer, int length, FontMap &runs)
 Create a new paragraph layouter. More...
 
void Reflow () override
 Reset the position to the start of the paragraph.
 
std::unique_ptr< const LineNextLine (int max_width) override
 Construct a new line with a maximum width. More...
 

Data Fields

const char32_t * buffer_begin
 Begin of the buffer.
 
const char32_t * buffer
 The current location in the buffer.
 
FontMapruns
 The fonts we have to use for this paragraph.
 

Detailed Description

Class handling the splitting of a paragraph of text into lines and visual runs.

One constructs this class with the text that needs to be split into lines. Then nextLine is called with the maximum width until nullptr is returned. Each nextLine call creates VisualRuns which contain the length of text that are to be drawn with the same font. In other words, the result of this class is a list of sub strings with their font. The sub strings are then already fully laid out, and only need actual drawing.

The positions in a visual run are sequential pairs of X,Y of the begin of each of the glyphs plus an extra pair to mark the end.

Note
This variant does not handle right-to-left properly.

Definition at line 38 of file gfx_layout_fallback.cpp.

Constructor & Destructor Documentation

◆ FallbackParagraphLayout()

FallbackParagraphLayout::FallbackParagraphLayout ( char32_t *  buffer,
int  length,
FontMap runs 
)

Create a new paragraph layouter.

Parameters
bufferThe characters of the paragraph.
lengthThe length of the paragraph.
runsThe font mapping of this paragraph.

Definition at line 194 of file gfx_layout_fallback.cpp.

References runs.

Member Function Documentation

◆ NextLine()

std::unique_ptr< const ParagraphLayouter::Line > FallbackParagraphLayout::NextLine ( int  max_width)
overridevirtual

Construct a new line with a maximum width.

Parameters
max_widthThe maximum width of the string.
Returns
A Line, or nullptr when at the end of the paragraph.

Implements ParagraphLayouter.

Definition at line 212 of file gfx_layout_fallback.cpp.

References buffer, buffer_begin, IsWhitespace(), and runs.


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