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

Set buffer limit on buffer to QLatin1Strings in KoFontRegistery::generateMetrics.

Wolthera van Hövell tot Westerflierfd01eeb9a2a7
diff --git a/libs/flake/text/KoFontGlyphModel.cpp b/libs/flake/text/KoFontGlyphModel.cpp
index 490f805dd9..2867d12c56 100644
--- a/libs/flake/text/KoFontGlyphModel.cpp
+++ b/libs/flake/text/KoFontGlyphModel.cpp
@@ -156,7 +156,7 @@ struct KoFontGlyphModel::Private {
for (auto it = tags.begin(); it != tags.end(); it++) {
char c[4];
hb_tag_to_string(*it, c);
- QLatin1String tagName(c);
+ const QLatin1String tagName(c, 4);
uint featureIndex;
QVector<uint> lookUpsProcessed;
diff --git a/libs/flake/text/KoFontRegistry.cpp b/libs/flake/text/KoFontRegistry.cpp
index 982139f922..72bc9f7f10 100644
--- a/libs/flake/text/KoFontRegistry.cpp
+++ b/libs/flake/text/KoFontRegistry.cpp
@@ -780,7 +780,9 @@ KoSvgText::FontMetrics KoFontRegistry::generateFontMetrics(FT_FaceSP face, bool
const bool useFallback = hb_version_atleast(4, 0, 0);
- QVector<hb_ot_metrics_tag_t> metricTags ({
+ // metrics
+
+ const QVector<hb_ot_metrics_tag_t> metricTags ({
HB_OT_METRICS_TAG_X_HEIGHT,
HB_OT_METRICS_TAG_CAP_HEIGHT,
HB_OT_METRICS_TAG_SUPERSCRIPT_EM_X_OFFSET,
@@ -789,11 +791,10 @@ KoSvgText::FontMetrics KoFontRegistry::generateFontMetrics(FT_FaceSP face, bool
HB_OT_METRICS_TAG_SUBSCRIPT_EM_Y_OFFSET
});
- // metrics
for (auto it = metricTags.begin(); it!= metricTags.end(); it++) {
char c[4];
hb_tag_to_string(*it, c);
- QLatin1String tagName(c);
+ const QLatin1String tagName(c, 4);
hb_position_t origin = 0;
if (useFallback) {
hb_ot_metrics_get_position_with_fallback(font.data(), *it, &origin);
@@ -816,11 +817,10 @@ KoSvgText::FontMetrics KoFontRegistry::generateFontMetrics(FT_FaceSP face, bool
HB_OT_LAYOUT_BASELINE_TAG_MATH
});
-
for (auto it = baselines.begin(); it!= baselines.end(); it++) {
char c[4];
hb_tag_to_string(*it, c);
- QLatin1String tagName(c);
+ const QLatin1String tagName(c, 4);
hb_position_t origin = 0;
if (useFallback) {
hb_ot_layout_get_baseline_with_fallback(font.data(), *it, dir, script, HB_TAG_NONE, &origin);
@@ -830,7 +830,7 @@ KoSvgText::FontMetrics KoFontRegistry::generateFontMetrics(FT_FaceSP face, bool
metrics.setBaselineValueByTag(tagName, origin);
}
- // Ascender line gap, descender.
+ // Ascender, line gap, descender.
hb_position_t ascender = 0;
hb_position_t descender = 0;