* Draw a multiline string, possibly over multiple lines, if the region is within the current display clipping area. * @note With clipping, it is not possible to determine how tall the rendered text will be, as it's not layouted. * Regular DrawStringMultiLine must be used if the height needs to be known. * * @param left The left most position to draw on. * @param right The right most
| 868 | * @return true iff the string was drawn. |
| 869 | */ |
| 870 | bool DrawStringMultiLineWithClipping(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize) |
| 871 | { |
| 872 | /* The string may contain control chars to change the font, just use the biggest font for clipping. */ |
| 873 | int max_height = std::max({GetCharacterHeight(FS_SMALL), GetCharacterHeight(FS_NORMAL), GetCharacterHeight(FS_LARGE), GetCharacterHeight(FS_MONO)}); |
| 874 | |
| 875 | /* Funny glyphs may extent outside the usual bounds, so relax the clipping somewhat. */ |
| 876 | int extra = max_height / 2; |
| 877 | |
| 878 | if (_cur_dpi->top + _cur_dpi->height + extra < top || _cur_dpi->top > bottom + extra || |
| 879 | _cur_dpi->left + _cur_dpi->width + extra < left || _cur_dpi->left > right + extra) { |
| 880 | return false; |
| 881 | } |
| 882 | |
| 883 | DrawStringMultiLine(left, right, top, bottom, str, colour, align, underline, fontsize); |
| 884 | return true; |
| 885 | } |
| 886 | |
| 887 | /** |
| 888 | * Return the string dimension in pixels. The height and width are returned |
no test coverage detected