Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix calculating the line height in text-in-shape when the first word is alone in its chunk.

Wolthera van Hövell tot Westerflier434ea988640f
diff --git a/libs/flake/text/KoSvgTextShapeLayoutFunc_lines.cpp b/libs/flake/text/KoSvgTextShapeLayoutFunc_lines.cpp
index b1b8d934bc..7ddd171445 100644
--- a/libs/flake/text/KoSvgTextShapeLayoutFunc_lines.cpp
+++ b/libs/flake/text/KoSvgTextShapeLayoutFunc_lines.cpp
@@ -64,7 +64,7 @@ void addWordToLine(QVector<CharacterResult> &result,
Q_FOREACH (const int j, wordIndices) {
CharacterResult cr = result.at(j);
- if (currentChunk.boundingBox.isEmpty() && j == wordIndices.first()) {
+ if (currentLine.isEmpty() && j == wordIndices.first()) {
if (result.at(j).lineStart == LineEdgeBehaviour::Collapse) {
result[j].advance = QPointF();
if (isHorizontal) {
@@ -80,12 +80,9 @@ void addWordToLine(QVector<CharacterResult> &result,
currentPos -= cr.advance;
cr.isHanging = true;
}
-
- // Ensure that the first non-collapsed result will always set the line-top and bottom.
- calculateLineHeight(cr, currentLine.actualLineTop, currentLine.actualLineBottom, isHorizontal, false);
- } else {
- calculateLineHeight(cr, currentLine.actualLineTop, currentLine.actualLineBottom, isHorizontal, true);
}
+ calculateLineHeight(cr, currentLine.actualLineTop, currentLine.actualLineBottom, isHorizontal, !cr.anchored_chunk);
+
cr.cssPosition = currentPos;
currentPos += cr.advance;
lineAdvance = currentPos;
diff --git a/libs/flake/text/KoSvgTextShape_p.h b/libs/flake/text/KoSvgTextShape_p.h
index badb1a4c27..ffd27ee7dc 100644
--- a/libs/flake/text/KoSvgTextShape_p.h
+++ b/libs/flake/text/KoSvgTextShape_p.h
@@ -320,7 +320,10 @@ struct LineBox {
bool isEmpty() {
if (chunks.isEmpty()) return true;
- return chunks.at(currentChunk).chunkIndices.isEmpty();
+ for (int i =0; i < chunks.size(); i++) {
+ if (!chunks.at(i).chunkIndices.isEmpty()) return false;
+ }
+ return true;
}
};