Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
deluge::hid::display::TextLineBreakdown Struct Reference

Public Member Functions

size_t maxPixelWidth () const
 
 TextLineBreakdown (std::string_view text, size_t char_height, size_t max_pixels_per_line)
 

Public Attributes

etl::vector< TextLine, kMaxNumLines > lines
 
size_t max_width_per_line
 

Constructor & Destructor Documentation

◆ TextLineBreakdown()

deluge::hid::display::TextLineBreakdown::TextLineBreakdown ( std::string_view text,
size_t char_height,
size_t max_pixels_per_line )

Take a string and break it down into lines that fit within a given width

Parameters
textthe string to be broken down
text_heightthe height of the text in pixels
max_pixels_per_linethe maximum width of a line in pixels This function iterates through the string character by character, calculating the width of each character and the spacing after it. If adding a character would exceed the maximum width, it looks for the first word break character (space or underscore) to break the line. If no word break character is found, it breaks at the end of the string. The function also handles newline characters by breaking the line at that point. The resulting lines are stored in the lines vector and their pixel widths are calculated. The function also keeps track of the maximum width of any line for later use.
Note
The function assumes that the input string is valid and does not contain any invalid characters.

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