mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2025-12-18 23:27:44 +03:00
Merge b45d0238f4 into c262f222de
This commit is contained in:
commit
6ba5d9dcec
@ -122,7 +122,10 @@ void ParsedText::layoutAndExtractLines(const GfxRenderer& renderer, const int fo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate spacing
|
// Calculate spacing
|
||||||
const int spareSpace = pageWidth - lineWordWidthSum;
|
int spareSpace = pageWidth - lineWordWidthSum;
|
||||||
|
if (!extraParagraphSpacing && wordWidthIndex ==0) {
|
||||||
|
spareSpace -= 3*spaceWidth;
|
||||||
|
}
|
||||||
int spacing = spaceWidth;
|
int spacing = spaceWidth;
|
||||||
const bool isLastLine = lineBreak == totalWordCount;
|
const bool isLastLine = lineBreak == totalWordCount;
|
||||||
|
|
||||||
@ -132,6 +135,9 @@ void ParsedText::layoutAndExtractLines(const GfxRenderer& renderer, const int fo
|
|||||||
|
|
||||||
// Calculate initial x position
|
// Calculate initial x position
|
||||||
uint16_t xpos = 0;
|
uint16_t xpos = 0;
|
||||||
|
if (!extraParagraphSpacing && wordWidthIndex ==0) {
|
||||||
|
xpos = 3*spaceWidth;
|
||||||
|
}
|
||||||
if (style == TextBlock::RIGHT_ALIGN) {
|
if (style == TextBlock::RIGHT_ALIGN) {
|
||||||
xpos = spareSpace - (lineWordCount - 1) * spaceWidth;
|
xpos = spareSpace - (lineWordCount - 1) * spaceWidth;
|
||||||
} else if (style == TextBlock::CENTER_ALIGN) {
|
} else if (style == TextBlock::CENTER_ALIGN) {
|
||||||
|
|||||||
@ -16,9 +16,11 @@ class ParsedText {
|
|||||||
std::list<std::string> words;
|
std::list<std::string> words;
|
||||||
std::list<EpdFontStyle> wordStyles;
|
std::list<EpdFontStyle> wordStyles;
|
||||||
TextBlock::BLOCK_STYLE style;
|
TextBlock::BLOCK_STYLE style;
|
||||||
|
bool extraParagraphSpacing;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ParsedText(const TextBlock::BLOCK_STYLE style) : style(style) {}
|
explicit ParsedText(const TextBlock::BLOCK_STYLE style, const bool extraParagraphSpacing)
|
||||||
|
: style(style), extraParagraphSpacing(extraParagraphSpacing) {}
|
||||||
~ParsedText() = default;
|
~ParsedText() = default;
|
||||||
|
|
||||||
void addWord(std::string word, EpdFontStyle fontStyle);
|
void addWord(std::string word, EpdFontStyle fontStyle);
|
||||||
|
|||||||
@ -25,7 +25,7 @@ constexpr int NUM_IMAGE_TAGS = sizeof(IMAGE_TAGS) / sizeof(IMAGE_TAGS[0]);
|
|||||||
const char* SKIP_TAGS[] = {"head", "table"};
|
const char* SKIP_TAGS[] = {"head", "table"};
|
||||||
constexpr int NUM_SKIP_TAGS = sizeof(SKIP_TAGS) / sizeof(SKIP_TAGS[0]);
|
constexpr int NUM_SKIP_TAGS = sizeof(SKIP_TAGS) / sizeof(SKIP_TAGS[0]);
|
||||||
|
|
||||||
bool isWhitespace(const char c) { return c == ' ' || c == '\r' || c == '\n'; }
|
bool isWhitespace(const char c) { return c == ' ' || c == '\r' || c == '\n' || c == '\t'; }
|
||||||
|
|
||||||
// given the start and end of a tag, check to see if it matches a known tag
|
// given the start and end of a tag, check to see if it matches a known tag
|
||||||
bool matches(const char* tag_name, const char* possible_tags[], const int possible_tag_count) {
|
bool matches(const char* tag_name, const char* possible_tags[], const int possible_tag_count) {
|
||||||
@ -48,7 +48,7 @@ void ChapterHtmlSlimParser::startNewTextBlock(const TextBlock::BLOCK_STYLE style
|
|||||||
|
|
||||||
makePages();
|
makePages();
|
||||||
}
|
}
|
||||||
currentTextBlock.reset(new ParsedText(style));
|
currentTextBlock.reset(new ParsedText(style, extraParagraphSpacing));
|
||||||
}
|
}
|
||||||
|
|
||||||
void XMLCALL ChapterHtmlSlimParser::startElement(void* userData, const XML_Char* name, const XML_Char** atts) {
|
void XMLCALL ChapterHtmlSlimParser::startElement(void* userData, const XML_Char* name, const XML_Char** atts) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user