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++

Initialize fontmetrics struct values.

Wolthera van Hövell tot Westerflier79b6fe012037
diff --git a/libs/flake/text/KoSvgText.h b/libs/flake/text/KoSvgText.h
index 550b9f5e39..24689606e2 100644
--- a/libs/flake/text/KoSvgText.h
+++ b/libs/flake/text/KoSvgText.h
@@ -326,42 +326,42 @@ Q_ENUM_NS(TextRendering)
*/
struct FontMetrics : public boost::equality_comparable<FontMetrics> {
bool isVertical = false; ///< Different fontMetrics count between vertical and horizontal.
- qint32 fontSize; ///< Currently set size, CSS unit 'em'
- qint32 zeroAdvance; ///< Advance of the character '0', CSS Unit 'ch', defaults to 0.5 em in horizontal and 1.0 em in vertical.
- qint32 spaceAdvance;///< Advance of the character ' ', used by tabs.
- qint32 ideographicAdvance; ///< Advance of the character '水' (U+6C34), CSS Unit ic, defaults to 1 em.
+ qint32 fontSize = 0; ///< Currently set size, CSS unit 'em'
+ qint32 zeroAdvance = 0; ///< Advance of the character '0', CSS Unit 'ch', defaults to 0.5 em in horizontal and 1.0 em in vertical.
+ qint32 spaceAdvance = 0;///< Advance of the character ' ', used by tabs.
+ qint32 ideographicAdvance = 0; ///< Advance of the character '水' (U+6C34), CSS Unit ic, defaults to 1 em.
- qint32 xHeight; ///< height of X, defaults to 0.5 fontsize.
- qint32 capHeight; ///< Height of capital letters, defaults to ascender.
- QPair<qint32, qint32> subScriptOffset; ///< subscript baseline height, defaults to 1/5th em below alphabetic.
- QPair<qint32, qint32> superScriptOffset; ///< superscript baseline height, defaults to 2/3rd above alphabetic.
+ qint32 xHeight = 0; ///< height of X, defaults to 0.5 fontsize.
+ qint32 capHeight = 0; ///< Height of capital letters, defaults to ascender.
+ QPair<qint32, qint32> subScriptOffset = qMakePair(0, 0); ///< subscript baseline height, defaults to 1/5th em below alphabetic.
+ QPair<qint32, qint32> superScriptOffset = qMakePair(0, 0); ///< superscript baseline height, defaults to 2/3rd above alphabetic.
- qint32 ascender; ///< distance from origin to top.
- qint32 descender; ///< distance for origin to bottom.
- qint32 lineGap; ///< additional linegap between consecutive lines.
+ qint32 ascender = 0; ///< distance from origin to top.
+ qint32 descender = 0; ///< distance for origin to bottom.
+ qint32 lineGap = 0; ///< additional linegap between consecutive lines.
- qint32 alphabeticBaseline; ///< location of alphabetic baseline from origin.
- qint32 mathematicalBaseline; ///< location of mathematical baseline from origin.
+ qint32 alphabeticBaseline = 0; ///< location of alphabetic baseline from origin.
+ qint32 mathematicalBaseline = 0; ///< location of mathematical baseline from origin.
- qint32 ideographicUnderBaseline; ///< location of ideographic under baseline from origin, may fall back to descender.
- qint32 ideographicCenterBaseline; ///< location of ideographic center baseline from origin,
+ qint32 ideographicUnderBaseline = 0; ///< location of ideographic under baseline from origin, may fall back to descender.
+ qint32 ideographicCenterBaseline = 0; ///< location of ideographic center baseline from origin,
///< default baseline for vertical, centered between over and under.
- qint32 ideographicOverBaseline; ///< location of ideographic over baseline from origin.
+ qint32 ideographicOverBaseline = 0; ///< location of ideographic over baseline from origin.
- qint32 ideographicFaceUnderBaseline; ///< location of ideographic face under baseline, that is, the bottom of the glyphs.
- qint32 ideographicFaceOverBaseline; ///< location of ideographic face over baseline, that is, the top of the glyphs.
+ qint32 ideographicFaceUnderBaseline = 0; ///< location of ideographic face under baseline, that is, the bottom of the glyphs.
+ qint32 ideographicFaceOverBaseline = 0; ///< location of ideographic face over baseline, that is, the top of the glyphs.
- qint32 hangingBaseline; ///< location of the hanging baseline used in north brahmic scripts.
+ qint32 hangingBaseline = 0; ///< location of the hanging baseline used in north brahmic scripts.
- qint32 underlineOffset; ///< underline offset from alphabetic, positive.
- qint32 underlineThickness; ///< underline thickness from font.
- qint32 lineThroughOffset; ///< offset of strike-through from alphabetic baseline.
- qint32 lineThroughThickness; ///< strikethrough thickness, from font.
+ qint32 underlineOffset = 0; ///< underline offset from alphabetic, positive.
+ qint32 underlineThickness = 0; ///< underline thickness from font.
+ qint32 lineThroughOffset = 0; ///< offset of strike-through from alphabetic baseline.
+ qint32 lineThroughThickness = 0; ///< strikethrough thickness, from font.
/// These are only used to determine the caret slant proportion.
- qint32 caretRun;
- qint32 caretRise;
- qint32 caretOffset;
+ qint32 caretRun = 0;
+ qint32 caretRise = 0;
+ qint32 caretOffset = 0;
FontMetrics () {
diff --git a/libs/flake/text/KoSvgTextShape_p_layout.cpp b/libs/flake/text/KoSvgTextShape_p_layout.cpp
index 719db97fb6..e724ef57b3 100644
--- a/libs/flake/text/KoSvgTextShape_p_layout.cpp
+++ b/libs/flake/text/KoSvgTextShape_p_layout.cpp
@@ -672,7 +672,7 @@ void KoSvgTextShape::Private::relayout()
// Compute baseline alignment.
globalIndex = 0;
- this->computeFontMetrics(textData.childBegin(), KoSvgTextProperties::defaultProperties(), KoSvgText::FontMetrics(), KoSvgText::BaselineAuto, QPointF(), QPointF(), result, globalIndex, resHandler, isHorizontal, disableFontMatching);
+ this->computeFontMetrics(textData.childBegin(), KoSvgTextProperties::defaultProperties(), KoSvgTextProperties::defaultProperties().metrics(false, false), KoSvgText::BaselineAuto, QPointF(), QPointF(), result, globalIndex, resHandler, isHorizontal, disableFontMatching);
// Handle linebreaking.
QPointF startPos = resolvedTransforms.value(0).absolutePos() - result.value(0).dominantBaselineOffset;