|
size_t | maxPixelWidth () const |
|
| TextLineBreakdown (std::string_view text, size_t char_height, size_t max_pixels_per_line) |
|
|
etl::vector< TextLine, kMaxNumLines > | lines |
|
size_t | max_width_per_line |
|
◆ 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
-
text | the string to be broken down |
text_height | the height of the text in pixels |
max_pixels_per_line | the 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:
- src/deluge/hid/display/oled.cpp