shithub: riscv

Download patch

ref: 503862f9000943b5cd72c1511828bae0c2050adc
parent: 122cc66c1b10dea2b681ab4c924e598f669370ef
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Tue Mar 28 12:13:19 EDT 2023

truetypefs: fall back instead of crashing when could not get a glyph

--- a/sys/src/cmd/truetypefs.c
+++ b/sys/src/cmd/truetypefs.c
@@ -166,8 +166,10 @@
 			g = 0;
 		else
 			g = ttffindchar(t, s->start + i);
-		gs[i] = ttfgetglyph(t, g, 1);
-		w += gs[i]->width;
+		if((gs[i] = ttfgetglyph(t, g, 1)) == nil && g != 0)
+			gs[i] = ttfgetglyph(t, 0, 1);
+		assert(gs[i] != nil);
+	   w += gs[i]->width;
 	}
 	sz = 5 * 12 + (w+7>>3) * h + 3 * 12 + (n + 1) * 6;
 	d = emalloc(sz);