#pragma once #include #include #include #include #include #include #include "blocks/TextBlock.h" class GfxRenderer; class ParsedText { std::list words; std::list wordStyles; TextBlock::Style style; bool extraParagraphSpacing; std::vector computeLineBreaks(int pageWidth, int spaceWidth, const std::vector& wordWidths) const; void extractLine(size_t breakIndex, int pageWidth, int spaceWidth, const std::vector& wordWidths, const std::vector& lineBreakIndices, const std::function)>& processLine); std::vector calculateWordWidths(const GfxRenderer& renderer, int fontId); public: explicit ParsedText(const TextBlock::Style style, const bool extraParagraphSpacing) : style(style), extraParagraphSpacing(extraParagraphSpacing) {} ~ParsedText() = default; void addWord(std::string word, EpdFontFamily::Style fontStyle); void setStyle(const TextBlock::Style style) { this->style = style; } TextBlock::Style getStyle() const { return style; } size_t size() const { return words.size(); } bool isEmpty() const { return words.empty(); } void layoutAndExtractLines(const GfxRenderer& renderer, int fontId, uint16_t viewportWidth, const std::function)>& processLine, bool includeLastLine = true); };