mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2025-12-18 23:27:44 +03:00
Compare commits
No commits in common. "96a88493cd0270ae6bd6752afb48c4010912f368" and "b372353a01b45867bc8f5154cf41519c585a80b4" have entirely different histories.
96a88493cd
...
b372353a01
@ -27,8 +27,6 @@ void ParsedText::layoutAndExtractLines(const GfxRenderer& renderer, const int fo
|
|||||||
const size_t totalWordCount = words.size();
|
const size_t totalWordCount = words.size();
|
||||||
const int pageWidth = renderer.getScreenWidth() - horizontalMargin;
|
const int pageWidth = renderer.getScreenWidth() - horizontalMargin;
|
||||||
const int spaceWidth = renderer.getSpaceWidth(fontId);
|
const int spaceWidth = renderer.getSpaceWidth(fontId);
|
||||||
// width of 1em to indent first line of paragraph if Extra Spacing is enabled
|
|
||||||
const int indentWidth = (!extraParagraphSpacing) ? 1 * renderer.getTextWidth(fontId, "m", REGULAR) : 0;
|
|
||||||
|
|
||||||
std::vector<uint16_t> wordWidths;
|
std::vector<uint16_t> wordWidths;
|
||||||
wordWidths.reserve(totalWordCount);
|
wordWidths.reserve(totalWordCount);
|
||||||
@ -53,7 +51,7 @@ void ParsedText::layoutAndExtractLines(const GfxRenderer& renderer, const int fo
|
|||||||
ans[totalWordCount - 1] = totalWordCount - 1;
|
ans[totalWordCount - 1] = totalWordCount - 1;
|
||||||
|
|
||||||
for (int i = totalWordCount - 2; i >= 0; --i) {
|
for (int i = totalWordCount - 2; i >= 0; --i) {
|
||||||
int currlen = -spaceWidth + indentWidth;
|
int currlen = -spaceWidth;
|
||||||
dp[i] = MAX_COST;
|
dp[i] = MAX_COST;
|
||||||
|
|
||||||
for (size_t j = i; j < totalWordCount; ++j) {
|
for (size_t j = i; j < totalWordCount; ++j) {
|
||||||
@ -125,10 +123,12 @@ void ParsedText::layoutAndExtractLines(const GfxRenderer& renderer, const int fo
|
|||||||
|
|
||||||
// Calculate spacing
|
// Calculate spacing
|
||||||
int spareSpace = pageWidth - lineWordWidthSum;
|
int spareSpace = pageWidth - lineWordWidthSum;
|
||||||
if (wordWidthIndex == 0) {
|
// width of 1em to indent first line of paragraph
|
||||||
spareSpace -= indentWidth;
|
const int indentWidth = 1 * renderer.getTextWidth(fontId, "m", REGULAR);
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!extraParagraphSpacing && wordWidthIndex ==0) {
|
||||||
|
spareSpace -= indentWidth;
|
||||||
|
}
|
||||||
int spacing = spaceWidth;
|
int spacing = spaceWidth;
|
||||||
const bool isLastLine = lineBreak == totalWordCount;
|
const bool isLastLine = lineBreak == totalWordCount;
|
||||||
|
|
||||||
@ -137,8 +137,10 @@ void ParsedText::layoutAndExtractLines(const GfxRenderer& renderer, const int fo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate initial x position
|
// Calculate initial x position
|
||||||
uint16_t xpos = (wordWidthIndex == 0) ? indentWidth : 0;
|
uint16_t xpos = 0;
|
||||||
|
if (!extraParagraphSpacing && wordWidthIndex ==0) {
|
||||||
|
xpos = indentWidth;
|
||||||
|
}
|
||||||
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) {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class ParsedText {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ParsedText(const TextBlock::BLOCK_STYLE style, const bool extraParagraphSpacing)
|
explicit ParsedText(const TextBlock::BLOCK_STYLE style, const bool extraParagraphSpacing)
|
||||||
: style(style), extraParagraphSpacing(extraParagraphSpacing) {}
|
: style(style), extraParagraphSpacing(extraParagraphSpacing) {}
|
||||||
~ParsedText() = default;
|
~ParsedText() = default;
|
||||||
|
|
||||||
void addWord(std::string word, EpdFontStyle fontStyle);
|
void addWord(std::string word, EpdFontStyle fontStyle);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user