Newer
Older
Import / applications / MakePDF / 3rdParty / libharu / pr-patches / 0001-Try-reducing-the-size-of-the-CIDToGIDMap.patch
From 3026ab8dcba6539ef4449a6a56d2ca3406e60ff3 Mon Sep 17 00:00:00 2001
From: Adalbert Michelic <am@timeanddate.com>
Date: Wed, 20 Dec 2017 10:24:24 +0100
Subject: [PATCH] Try reducing the size of the /CIDToGIDMap.

Only care about actually used glyphs, so that
a) the length of the array can be reduced,
b) unused entries can be easily compressed as they are
   zeroed out.
---
 src/hpdf_font_cid.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/hpdf_font_cid.c b/src/hpdf_font_cid.c
index 06e3a8b..5ab3b28 100644
--- a/src/hpdf_font_cid.c
+++ b/src/hpdf_font_cid.c
@@ -442,17 +442,21 @@ CIDFontType2_BeforeWrite_Func  (HPDF_Dict obj)
 		    HPDF_UNICODE unicode = encoder_attr->unicode_map[i][j];
 		    HPDF_UINT16 gid = HPDF_TTFontDef_GetGlyphid (def,
 								 unicode);
-		    tmp_map[cid] = gid;
-		    if (max < cid)
-			max = cid;
+		    if (def_attr->glyph_tbl.flgs[gid]) {
+			tmp_map[cid] = gid;
+			if (max < cid)
+			    max = cid;
+		    }
 		}
 	    } else {
 		HPDF_UNICODE unicode = (i << 8) | j;
 		HPDF_UINT16 gid = HPDF_TTFontDef_GetGlyphid (def,
 							     unicode);
-		tmp_map[unicode] = gid;
-		if (max < unicode)
-		    max = unicode;
+		if (def_attr->glyph_tbl.flgs[gid]) {
+		    tmp_map[unicode] = gid;
+		    if (max < unicode)
+			max = unicode;
+		}
 	    }
 	}
     }
-- 
2.21.1 (Apple Git-122.3)