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

leonardo at ghostscript.com leonardo at ghostscript.com
Mon Jan 8 07:04:55 PST 2007


Author: leonardo
Date: 2007-01-08 07:04:53 -0800 (Mon, 08 Jan 2007)
New Revision: 7583

Modified:
   trunk/gs/src/gstype1.c
   trunk/gs/src/gstype2.c
   trunk/gs/src/gxhintn.c
   trunk/gs/src/gxhintn.h
Log:
Type 1 hinter : Implementing a contour sign normalization, part 2.

DETAILS :

This is continuation of the preparation for fixing the bug 688947  
"Ghostscript renders font incorrectly (letter 'o' filled in)".

This change is algorithmically equivalent -
the new stuff works idle.
It define necesary data structures and flows
for storing information about subglyphs.
The implementation itself will be a next step.

EXPECTED DIFFERENCES :

None.


Modified: trunk/gs/src/gstype1.c
===================================================================
--- trunk/gs/src/gstype1.c	2007-01-08 12:50:48 UTC (rev 7582)
+++ trunk/gs/src/gstype1.c	2007-01-08 15:04:53 UTC (rev 7583)
@@ -255,8 +255,12 @@
 		    code = gx_setcurrentpoint_from_path(pcis->pis, pcis->path);
 		    if (code < 0)
 			return code;
-		} else
+		} else {
+		    code = t1_hinter__end_subglyph(h);
+		    if (code < 0)
+			return code;
 		    pcis->seac_flag = true;
+		}
 		code = gs_type1_endchar(pcis);
 		if (code == 1) {
 		    /* do accent of seac */

Modified: trunk/gs/src/gstype2.c
===================================================================
--- trunk/gs/src/gstype2.c	2007-01-08 12:50:48 UTC (rev 7582)
+++ trunk/gs/src/gstype2.c	2007-01-08 15:04:53 UTC (rev 7583)
@@ -334,8 +334,12 @@
 		    code = gx_setcurrentpoint_from_path(pcis->pis, pcis->path);
 		    if (code < 0)
 			return code;
-		} else
+		} else {
 		    t1_hinter__setcurrentpoint(h, pcis->save_adxy.x, pcis->save_adxy.y);
+		    code = t1_hinter__end_subglyph(h);
+		    if (code < 0)
+			return code;
+		}
 		code = gs_type1_endchar(pcis);
 		if (code == 1) {
 		    /*

Modified: trunk/gs/src/gxhintn.c
===================================================================
--- trunk/gs/src/gxhintn.c	2007-01-08 12:50:48 UTC (rev 7582)
+++ trunk/gs/src/gxhintn.c	2007-01-08 15:04:53 UTC (rev 7583)
@@ -136,6 +136,7 @@
 static const char *s_zone_array = "t1_hinter zone array";
 static const char *s_hint_array = "t1_hinter hint array";
 static const char *s_contour_array = "t1_hinter contour array";
+static const char *s_subglyph_array = "t1_hinter subglyph array";
 static const char *s_hint_range_array = "t1_hinter hint_range array";
 static const char *s_hint_applying_array = "t1_hinter hint_applying array";
 static const char *s_stem_snap_array = "t1_hinter stem_snap array";
@@ -474,10 +475,12 @@
     this->pole_count = 0;
     this->hint_count = 0;
     this->contour_count = 0;
+    this->subglyph_count = 0;
     this->hint_range_count = 0;
     this->flex_count = 0;
     this->have_flex = false;
 
+    this->max_subglyph_count = count_of(this->subglyph0);
     this->max_contour_count = count_of(this->contour0);
     this->max_zone_count = count_of(this->zone0);
     this->max_pole_count = count_of(this->pole0);
@@ -492,6 +495,7 @@
     this->hint = this->hint0;
     this->zone = this->zone0;
     this->contour = this->contour0;
+    this->subglyph = this->subglyph0;
     this->hint_range = this->hint_range0;
     this->hint_applying = this->hint_applying0;
     this->stem_snap[0] = this->stem_snap0[0];
@@ -507,6 +511,7 @@
     this->heigt_transform_coef_inv = this->width_transform_coef_inv = 0;
     this->cx = this->cy = 0;
     this->contour[0] = 0;
+    this->subglyph[0] = 0;
     this->keep_stem_width = false;
     this->charpath_flag = false;
     this->grid_fit_x = this->grid_fit_y = true;
@@ -529,6 +534,8 @@
 	gs_free_object(this->memory, this->zone, s_zone_array);
     if (this->contour != this->contour0)
 	gs_free_object(this->memory, this->contour, s_contour_array);
+    if (this->subglyph != this->subglyph0)
+	gs_free_object(this->memory, this->subglyph, s_subglyph_array);
     if (this->hint_range != this->hint_range0)
 	gs_free_object(this->memory, this->hint_range, s_hint_range_array);
     if (this->hint_applying != this->hint_applying0)
@@ -1386,6 +1393,19 @@
     }
 }
 
+int t1_hinter__end_subglyph(t1_hinter * this)
+{
+    if (this->pass_through)
+	return 0;
+    this->subglyph_count++;
+    if (this->subglyph_count >= this->max_subglyph_count)
+	if(t1_hinter__realloc_array(this->memory, (void **)&this->subglyph, this->subglyph0, &this->max_subglyph_count, 
+				    sizeof(this->subglyph0) / count_of(this->subglyph0), T1_MAX_SUBGLYPHS, s_subglyph_array))
+	    return_error(gs_error_VMerror);
+    this->subglyph[this->subglyph_count] = this->contour_count;
+    return 0;
+}
+
 private inline int t1_hinter__can_add_hint(t1_hinter * this, t1_hint **hint)
 {   if (this->hint_count >= this->max_hint_count)
         if(t1_hinter__realloc_array(this->memory, (void **)&this->hint, this->hint0, &this->max_hint_count, 
@@ -2957,11 +2977,35 @@
     return t1_hinter__rmoveto(this, gx - this->cx, gy - this->cy);
 }
 
-private void t1_hinter__fix_contour_signs(t1_hinter * this)
+private void t1_hinter__fix_subglyph_contour_signs(t1_hinter * this, int first_contour, int last_contour)
 {
     /* fixme: todo. */
 }
 
+private void t1_hinter__fix_contour_signs(t1_hinter * this)
+{
+    int i;
+
+    if (this->subglyph_count >= 3) {
+	/* 3 or more subglyphs.
+	   We didn't meet so complex characters with wrong contours signs. 
+	   Skip it for saving the CPU time. */
+	return;
+    }
+    for (i = 1; i < this->subglyph_count; i++) {
+	int first_contour = this->subglyph[i - 1];
+	int last_contour  = this->subglyph[i] - 1;
+
+	if (last_contour - last_contour >= 3) { 
+	    /* 4 or more contours.
+	       We didn't meet so complex characters with wrong contours signs. 
+	       Skip it for saving the CPU time. */
+	    continue;
+	}
+	t1_hinter__fix_subglyph_contour_signs(this, first_contour, last_contour);
+    }
+}
+
 int t1_hinter__endglyph(t1_hinter * this)
 {   int code = 0;
 
@@ -2978,6 +3022,9 @@
     code = t1_hinter__add_trailing_moveto(this);
     if (code < 0)
 	goto exit;
+    code = t1_hinter__end_subglyph(this);
+    if (code < 0)
+	goto exit;
     t1_hinter__paint_glyph(this, false);
     t1_hinter__adjust_matrix_precision(this, this->orig_gx, this->orig_gy);
     t1_hinter__compute_y_span(this);

Modified: trunk/gs/src/gxhintn.h
===================================================================
--- trunk/gs/src/gxhintn.h	2007-01-08 12:50:48 UTC (rev 7582)
+++ trunk/gs/src/gxhintn.h	2007-01-08 15:04:53 UTC (rev 7583)
@@ -37,6 +37,7 @@
 #define T1_MAX_STEM_SNAPS 12
 #define T1_MAX_ALIGNMENT_ZONES 6
 #define T1_MAX_CONTOURS 10
+#define T1_MAX_SUBGLYPHS 3
 #define T1_MAX_POLES (100 + T1_MAX_CONTOURS) /* Must be grater than 8 for 'flex'. */
 #define T1_MAX_HINTS 30
 
@@ -140,6 +141,7 @@
     t1_hint hint0[T1_MAX_HINTS], *hint;
     t1_zone zone0[T1_MAX_ALIGNMENT_ZONES], *zone;
     int contour0[T1_MAX_CONTOURS], *contour;
+    int subglyph0[T1_MAX_CONTOURS], *subglyph;
     t1_glyph_space_coord stem_snap0[2][T1_MAX_STEM_SNAPS + 1]; /* StdWH + StemSnapH, StdWV + StemSnapV */
     t1_glyph_space_coord *stem_snap[2];
     int stem_snap_vote0[T1_MAX_STEM_SNAPS + 1];
@@ -148,6 +150,7 @@
     t1_hint_applying hint_applying0[T1_MAX_HINTS * 4], *hint_applying;
     int stem_snap_count[2], max_stem_snap_count[2]; /* H, V */
     int stem_snap_vote_count, max_stem_snap_vote_count;
+    int subglyph_count, max_subglyph_count;
     int contour_count, max_contour_count;
     int zone_count, max_zone_count;
     int pole_count, max_pole_count;
@@ -197,6 +200,7 @@
 int  t1_hinter__rcurveto(t1_hinter * this, fixed xx0, fixed yy0, fixed xx1, fixed yy1, fixed xx2, fixed yy2);
 void t1_hinter__setcurrentpoint(t1_hinter * this, fixed xx, fixed yy);
 int  t1_hinter__closepath(t1_hinter * this);
+int  t1_hinter__end_subglyph(t1_hinter * this);
 
 int  t1_hinter__flex_beg(t1_hinter * this);
 int  t1_hinter__flex_end(t1_hinter * this, fixed flex_height);



More information about the gs-cvs mailing list