Fixing bug 674418, 093-01.ps : Wrong text

Alex Cherepanov <[email protected]> Sun, 03 Oct 2004 01:35:31 -0400
Newsgroups gmane.comp.printing.ghostscript.patches
Organization Coscript Software
Message-ID <[email protected]>
Reviewers,

This is a preliminary patch that is not yet ready for production
use.

The differences between rendering 093-01.ps in cached and non-cached
modes are in part caused by different fonts with the same UniqueID.
The proposed patch clears UniqueID when there's a different font with
the same UniqueID . Detection whether the font is different is not
yet implemented and all fonts are considered different.

There are several issues I'd like to discuss before proceeding with
the implementation.

1. What's the right way to enumerate all fonts known to the font
    cache ?

2. Matching of UniqueID and XUID in PostScript is slow and ugly.
    Matching of the font contents is even slower. Should this code
    be rewritten in C ?

3. An alternative approach is to extend the internal ID with a
    hash value of the font. What's better?

4. What to do with different subsets of the same font?

5. Should we reopen bug 651644 , a case on non-unique UniqueID ?

Regards,
Alex

_______________________________________________
gs-code-review mailing list
[email protected]
http://www.ghostscript.com/mailman/listinfo/gs-code-review
674418.diff (text/plain, 3.4 KB)
Index: gs/lib/gs_fonts.ps
===================================================================
RCS file: /cvs/ghostscript/gs/lib/gs_fonts.ps,v
retrieving revision 1.47
diff -b -u -r1.47 gs_fonts.ps
--- gs/lib/gs_fonts.ps	2 Aug 2004 03:33:45 -0000	1.47
+++ gs/lib/gs_fonts.ps	3 Oct 2004 04:55:17 -0000
@@ -420,6 +420,55 @@
     }
    ifelse
  } bind def 
+
+/.known_get_id_xuid { % <dict> .known_get_id_xuid <id> true | false
+  dup /XUID .knownget 
+    { exch pop //true
+    }
+    { /UniqueID .knownget
+    }
+  ifelse
+} bind def
+
+% Find a font with the same XUID or UniqueID
+/.find_eq_id_xuid   % <id> <dict> .find_eq_id_xuid <id> <font> true | <id> false
+{ //false exch                                     % id false dict
+    { exch pop                                     % id false font
+      dup .known_get_id_xuid
+        {                                          % id false font id'
+          3 index                                  % id false font id' id
+          dup type /integertype eq
+            { eq                                   % id false font bool
+            }
+            { 1 index type /integertype eq
+                { eq                               % id false font false
+                }                                  
+                { dup length 1 index length eq
+                    { dup length 1 sub -1 0 { 1 index exch get 3 1 roll } for
+                      pop //true exch              % id false font ... true id'
+                      { 3 -1 roll eq and } forall  % id false font bool
+                    }
+                    { eq                           % id false font false
+                    }
+                  ifelse
+                }
+              ifelse
+            }
+          ifelse
+            {                                      % id false font
+              exch not exit                        % id font true
+            }
+            { pop                                  % id false
+            }
+          ifelse
+        }
+        { pop                                      % id false
+        }
+      ifelse
+    }
+  forall
+} bind def
+
 /.completefont {
   {             % Check for disabled platform fonts.
       NOPLATFONTS
@@ -445,7 +494,41 @@
       dup /.OrigFont known not {
         dup dup /.OrigFont exch .growput
       } if
-      true exch
+
+      dup /XUID .knownget
+        { 1 index /UniqueID undef
+          //true
+        }
+        { dup /UniqueID .knownget 
+        }
+      ifelse
+        {        % Stack: <<font>> UniqueID
+          { /LocalFontDirectory % /GlobalFontDirectory
+          }
+            {
+              //systemdict exch .knownget               
+                {                                   % font id <<>>
+                  .find_eq_id_xuid
+                    {                               % font id font'
+                      pop exch
+                      dup wcheck not
+                        { dup dict length copy
+                        }
+                      if
+                      dup /XUID undef
+                      dup /UniqueID undef
+                      exch exit
+                    }
+                  if
+                }
+              if
+            }
+          forall
+          pop
+        }
+      if
+
+      //true exch
                 % If this is a CIDFont, CIDFontType takes precedence
                 % over FontType.
       dup /CIDFontType known {