From ee96b6fa68322fa2e809c855a8394614ffb19b20 Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Sat, 11 Feb 2023 15:55:49 -0400 Subject: [PATCH] Fix a crash when printing an empty string. --- src/modules/font/freetype/HarfbuzzShaper.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/font/freetype/HarfbuzzShaper.cpp b/src/modules/font/freetype/HarfbuzzShaper.cpp index 8b6ad01c5..dbc644e1a 100644 --- a/src/modules/font/freetype/HarfbuzzShaper.cpp +++ b/src/modules/font/freetype/HarfbuzzShaper.cpp @@ -118,6 +118,9 @@ void HarfbuzzShaper::computeBufferRanges(const ColoredCodepoints &codepoints, Ra { bufferranges.clear(); + if (codepoints.cps.size() == 0) + return; + // Less computation for the typical case (no fallback fonts). if (rasterizers.size() == 1) { @@ -195,7 +198,7 @@ void HarfbuzzShaper::computeBufferRanges(const ColoredCodepoints &codepoints, Ra void HarfbuzzShaper::computeGlyphPositions(const ColoredCodepoints &codepoints, Range range, Vector2 offset, float extraspacing, std::vector *positions, std::vector *colors, TextInfo *info) { - if (!range.isValid()) + if (!range.isValid() && !codepoints.cps.empty()) range = Range(0, codepoints.cps.size()); offset.y += getBaseline();