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++
Try to load glyph-specific metrics better so tabsize works.
Wolthera van Hövell tot Westerflierf9b09a9ba7e7
diff --git a/libs/flake/text/KoFontRegistry.cpp b/libs/flake/text/KoFontRegistry.cppindex b9122d1400..5239c73775 100644--- a/libs/flake/text/KoFontRegistry.cpp+++ b/libs/flake/text/KoFontRegistry.cpp@@ -785,7 +785,8 @@ KoSvgText::FontMetrics KoFontRegistry::generateFontMetrics(FT_FaceSP face, bool// Fontsize and advances.metrics.fontSize = isHorizontal? face.data()->size->metrics.y_ppem*64.0: face.data()->size->metrics.x_ppem*64.0;- if(uint charIndex = FT_Get_Char_Index(face.data(), 0x20) > 0) {+ uint charIndex = FT_Get_Char_Index(face.data(), 0x20);+ if(charIndex > 0) {if (FT_Load_Glyph(face.data(), charIndex, faceLoadFlags) == FT_Err_Ok) {metrics.spaceAdvance = isHorizontal? face.data()->glyph->advance.x: face.data()->glyph->advance.y;} else {@@ -795,7 +796,8 @@ KoSvgText::FontMetrics KoFontRegistry::generateFontMetrics(FT_FaceSP face, boolmetrics.spaceAdvance = isHorizontal? metrics.fontSize/2: metrics.fontSize;}- if(uint charIndex = FT_Get_Char_Index(face.data(), '0') > 0) {+ charIndex = FT_Get_Char_Index(face.data(), '0');+ if(charIndex > 0) {if(FT_Load_Glyph(face.data(), charIndex, faceLoadFlags) == FT_Err_Ok) {metrics.zeroAdvance = isHorizontal? face.data()->glyph->advance.x: face.data()->glyph->advance.y;} else {@@ -806,7 +808,8 @@ KoSvgText::FontMetrics KoFontRegistry::generateFontMetrics(FT_FaceSP face, bool}bool isIdeographic = false;- if(uint charIndex = FT_Get_Char_Index(face.data(), 0x6C34) > 0) {+ charIndex = FT_Get_Char_Index(face.data(), 0x6C34);+ if(charIndex > 0) {if (FT_Load_Glyph(face.data(), charIndex, faceLoadFlags) == FT_Err_Ok) {metrics.ideographicAdvance = isHorizontal? face.data()->glyph->advance.x: face.data()->glyph->advance.y;} else {diff --git a/libs/flake/text/KoSvgTextShape_p_layout.cpp b/libs/flake/text/KoSvgTextShape_p_layout.cppindex dd64d9fa05..bec1b9f403 100644--- a/libs/flake/text/KoSvgTextShape_p_layout.cpp+++ b/libs/flake/text/KoSvgTextShape_p_layout.cpp@@ -501,8 +501,13 @@ void KoSvgTextShape::Private::relayout()if (text.at(j) == QChar::Tabulation) {qreal tabSize = 0;if (tabInfo.isNumber) {- tabSize = (result[j].metrics.spaceAdvance + (tabInfo.extraSpacing*ftFontUnit)) * tabInfo.value;+ // Try to avoid Nan situations.+ if (result[j].metrics.spaceAdvance > 0) {+ tabSize = (result[j].metrics.spaceAdvance + (tabInfo.extraSpacing*ftFontUnit)) * tabInfo.value;} else {+ tabSize = ((result[j].metrics.fontSize/2) + (tabInfo.extraSpacing*ftFontUnit)) * tabInfo.value;+ }+ } else {tabSize = tabInfo.length.value * ftFontUnit;}result[j].tabSize = tabSize;