[gs-cvs] rev 7879 - trunk/gs/src

leonardo at ghostscript.com leonardo at ghostscript.com
Mon Apr 23 17:16:15 PDT 2007


Author: leonardo
Date: 2007-04-23 17:16:14 -0700 (Mon, 23 Apr 2007)
New Revision: 7879

Modified:
   trunk/gs/src/gstype42.c
Log:
Fix (TT fonts) : Do not consider overlapped glyps while computing glyph length.

DETAILS : 

This is a partial fix for bug 688971 
"huge performace problem (with large TT font?)".
Thanks to SaGS for idea to drop an old hewristic
after a *stable* sorting is applied.
See comment in code.

EXPECTED DIFFERENCES :

None.


Modified: trunk/gs/src/gstype42.c
===================================================================
--- trunk/gs/src/gstype42.c	2007-04-23 23:59:01 UTC (rev 7878)
+++ trunk/gs/src/gstype42.c	2007-04-24 00:16:14 UTC (rev 7879)
@@ -267,12 +267,11 @@
     if (i < loca_size) {
         /*
          * loca was out of order, build the len_glyphs the hard way.      
-	 * For each glyph, we use the next higher (but not 
-	 * equal) starting offset to compute the glyph length.
-	 * It implies that only the last glyph may be empty.
-	 * Other glyphs, if they have same offsets, are considered as duplicates.
+	 * For each glyph, we use the next higher or equal
+	 * glyph offset to compute the glyph length.
+	 * It assumes no overlapping and no duplicate glyphs.
 	 */
-	ulong last_glyph_length = 0, last_glyph_offset = glyph_size;
+	ulong last_glyph_offset = glyph_size;
 	gs_type42_font_init_sort_t *psort;
 	gs_type42_font_init_sort_t *psortary = 
 	    (gs_type42_font_init_sort_t *)gs_alloc_byte_array(pfont->memory, 
@@ -285,17 +284,11 @@
 	    psort->glyph_offset = get_glyph_offset(pfont, i);
 	    }
 	qsort(psortary, loca_size, sizeof(gs_type42_font_init_sort_t), gs_type42_font_init_compare);
-	last_glyph_length = 0;
 	if (psortary[loca_size - 1].glyph_offset > glyph_size)
 	    return_error(gs_error_invalidfont);
 	for (i = loca_size; i--;) {
 	    psort = psortary + i;
-	    glyph_length = last_glyph_offset - psort->glyph_offset;
-	    if (glyph_length == 0)
-		glyph_length = last_glyph_length;
-	    else
-		last_glyph_length = glyph_length;
-	    pfont->data.len_glyphs[psort->glyph_num] = glyph_length;
+	    pfont->data.len_glyphs[psort->glyph_num] = last_glyph_offset - psort->glyph_offset;
 	    last_glyph_offset = psort->glyph_offset;
 	}
 	/* Well the last element of len_glyphs is never used.



More information about the gs-cvs mailing list