shithub: neatpost

Download patch

ref: ef335fc798469a6c4a09928fa14384aa8db652fd
parent: ea0c54be10e8583554cde266847588e0d5734039
author: Ali Gholami Rudi <ali@rudi.ir>
date: Fri Mar 30 10:29:55 EDT 2018

pdf: do not include .notdef glyphs in the last sub-font

--- a/pdf.c
+++ b/pdf.c
@@ -143,6 +143,7 @@
 	char *ext = strrchr(ps->path, '.');
 	struct font *fn = dev_fontopen(ps->desc);
 	int map[256] = {0};
+	char gcnt = ps->lastfn == ix ? ps->lastgl : 256;
 	/* finding out the mapping */
 	for (i = 0; i < 256; i++)
 		map[i] = -1;
@@ -154,7 +155,7 @@
 	pdfout("<<\n");
 	pdfout("  /Type /Encoding\n");
 	pdfout("  /Differences [ 0");
-	for (i = 0; i < 256; i++)
+	for (i = 0; i < gcnt; i++)
 		pdfout(" /%s", map[i] >= 0 ? font_glget(fn, map[i])->id : ".notdef");
 	pdfout(" ]\n");
 	pdfout(">>\n");
@@ -167,9 +168,9 @@
 		ext && !strcmp(".ttf", ext) ? "TrueType" : "Type1");
 	pdfout("  /BaseFont /%s\n", ps->name);
 	pdfout("  /FirstChar 0\n");
-	pdfout("  /LastChar 255\n");
+	pdfout("  /LastChar %d\n", gcnt - 1);
 	pdfout("  /Widths [");
-	for (i = 0; i < 256; i++)
+	for (i = 0; i < gcnt; i++)
 		pdfout(" %d", (map[i] >= 0 ? font_glget(fn, map[i])->wid : 0)
 				* dev_res / 72);
 	pdfout(" ]\n");