Browse Source

Fix a crash when printing an empty string.

Sasha Szpakowski 2 years ago
parent
commit
ee96b6fa68
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/modules/font/freetype/HarfbuzzShaper.cpp

+ 4 - 1
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<GlyphPosition> *positions, std::vector<IndexedColor> *colors, TextInfo *info)
 {
-	if (!range.isValid())
+	if (!range.isValid() && !codepoints.cps.empty())
 		range = Range(0, codepoints.cps.size());
 
 	offset.y += getBaseline();