[jbig2-cvs] rev 285 - trunk

giles at ghostscript.com giles at ghostscript.com
Thu Nov 6 15:01:06 PST 2003


Author: giles
Date: 2003-11-06 10:08:48 -0800 (Thu, 06 Nov 2003)
New Revision: 285

Modified:
   trunk/jbig2_text.c
Log:
Fix a bug with text region rendering in the Patent.pdf example file from 
the adobe's encoder.

The problem was that we weren't handling the export/import of symbols 
from dictionaries referred to by the symbol dictionaries referred to by 
the text region segment.

This patch is just a quick fix: we recurse when building the list of 
referred to symbol dictionaries at text region decode time, which 
allows us to get at all the symbols. This works because the adobe 
encoder (at least in this file) always exports all the symbols, imported 
and encoded, in each dictionary. If it did not, we would have offset 
errors in the symbol lookup.

A proper fix requires decoding the exported symbol flags and building an 
export version of SBSYMS to store in the segment result that includes 
the symbols imported from any other dictionaries. All while 
intelligently sharing the decoded glyph data, of course.



Modified: trunk/jbig2_text.c
===================================================================
--- trunk/jbig2_text.c	2003-11-03 16:39:41 UTC (rev 284)
+++ trunk/jbig2_text.c	2003-11-06 18:08:48 UTC (rev 285)
@@ -289,8 +289,10 @@
 
     for (index = 0; index < segment->referred_to_segment_count; index++) {
         rsegment = jbig2_find_segment(ctx, segment->referred_to_segments[index]);
-        if (rsegment && ((rsegment->flags & 63) == 0))
+        if (rsegment && ((rsegment->flags & 63) == 0)) {
             n_dicts++;
+            n_dicts+= count_referred_dicts(ctx, rsegment);
+        }
     }
     
     return (n_dicts);
@@ -302,17 +304,34 @@
 {
     int index;
     Jbig2Segment *rsegment;
-    Jbig2SymbolDict **dicts;
+    Jbig2SymbolDict **dicts, **rdicts;
     int n_dicts = count_referred_dicts(ctx, segment);
     int dindex = 0;
     
     dicts = jbig2_alloc(ctx->allocator, sizeof(Jbig2SymbolDict *) * n_dicts);
     for (index = 0; index < segment->referred_to_segment_count; index++) {
         rsegment = jbig2_find_segment(ctx, segment->referred_to_segments[index]);
-        if (rsegment && ((rsegment->flags & 63) == 0))
+        if (rsegment && ((rsegment->flags & 63) == 0)) {
+            /* recurse for imported symbols */
+            int j, n_rdicts = count_referred_dicts(ctx, rsegment);
+            if (n_rdicts > 0) {
+                rdicts = list_referred_dicts(ctx, rsegment);
+                for (j = 0; j < n_rdicts; j++)
+                    dicts[dindex++] = rdicts[j];
+                jbig2_free(ctx->allocator, rdicts);
+            }
+            /* add this referred to symbol dictionary */
             dicts[dindex++] = (Jbig2SymbolDict *)rsegment->result;
+        }
     }
     
+    if (dindex != n_dicts) {
+        /* should never happen */
+        jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
+    	    "counted %d symbol dictionaries but build a list with %d.\n",
+    	    n_dicts, dindex);
+    }
+    
     return (dicts);
 }
 



More information about the jbig2-cvs mailing list