--- ./lib/gs_ttf.ps.org	2005-08-31 14:59:29.000000000 +0900
+++ ./lib/gs_ttf.ps	2005-09-13 14:48:24.000000000 +0900
@@ -274,6 +274,54 @@
   2 index length 2 index gt { put } { pop pop pop } ifelse
 } bind def
 
+/.biglength { % <str>|<array of str> .biglength <integer>
+  dup type /arraytype eq { 0 exch { length add } forall } { length } ifelse
+} bind def
+
+/concats { % [str ...] concats str
+  () exch dup length 1 sub -1 0 {
+    1 index exch get dup type /stringtype ne { dup length string cvs } if
+    3 -1 roll exch dup length 2 index length add string
+    dup dup 4 2 roll copy length 4 -1 roll putinterval exch
+  } for pop
+} bind def
+
+% <str>|<array of str> <index> <count> .biggetinterval <str>|<array of str>
+/.biggetinterval {
+  3 dict begin
+  2 index type /arraytype eq {
+    /c exch def
+    /i exch def
+    [ exch {
+      dup length /l exch def
+      i c add l gt {
+        i l lt {
+          i l i sub getinterval
+          /c i c add l sub def
+          /i 0 def
+        } {
+          pop
+          /i i l sub def
+        } ifelse
+      } {
+        i c getinterval exit
+      } ifelse
+    } forall
+    ] dup .biglength 65535 le { concats } if
+  } { getinterval } ifelse
+  end
+} bind def
+
+% <str>|<array of str> <index> getu16 <integer>
+/.biggetu16 {
+  2 .biggetinterval 0 getu16
+} bind def
+
+% <str>|<array of str> <index> getu32 <integer>
+/.biggetu32 {
+  4 .biggetinterval 0 getu32
+} bind def
+
 % Each procedure in this dictionary is called as follows:
 %       <encodingtable> proc <glypharray>
 /cmapformats mark
@@ -432,14 +480,14 @@
   } bind
   4 {		% Microsoft/Adobe segmented mapping.
     /etab exch def
-    /nseg2 etab 6 getu16 def
-    14 /endc etab 2 index nseg2 getinterval def
+    /nseg2 etab 6 .biggetu16 def
+    14 /endc etab 2 index nseg2 .biggetinterval def
 		% The Apple TrueType documentation omits the 2-byte
 		% 'reserved pad' that follows the endCount vector!
     2 add
-    nseg2 add /startc etab 2 index nseg2 getinterval def
-    nseg2 add /iddelta etab 2 index nseg2 getinterval def
-    nseg2 add /idroff etab 2 index nseg2 getinterval def
+    nseg2 add /startc etab 2 index nseg2 .biggetinterval def
+    nseg2 add /iddelta etab 2 index nseg2 .biggetinterval def
+    nseg2 add /idroff etab 2 index nseg2 .biggetinterval def
 		% The following hack allows us to properly handle
 		% idiosyncratic fonts that start at 0xf000:
     pop
@@ -465,8 +513,8 @@
     /numcodes 0 def /code 0 def
     0 2 nseg2 3 sub {
       /i2 exch def
-      /scode startc i2 getu16 def
-      /ecode endc i2 getu16 def
+      /scode startc i2 .biggetu16 def
+      /ecode endc i2 .biggetu16 def
       numcodes scode firstcode sub
 		% Hack for fonts that have only 0x0000 and 0xf000 ranges
       %dup 16#e000 ge { 255 and } if
@@ -478,15 +526,15 @@
 	(scode=) print scode =only
 	( ecode=) print ecode =only
 	( delta=) print delta =only
-	( droff=) print idroff i2 getu16 =
+	( droff=) print idroff i2 .biggetu16 =
       } if
-      idroff i2 getu16 dup 0 eq {
+      idroff i2 .biggetu16 dup 0 eq {
 	pop scode delta add 65535 and 1 ecode delta add 65535 and
 	{ putglyph } for
       } {	% The +2 is for the 'reserved pad'.
         /gloff exch 14 nseg2 3 mul add 2 add i2 add add def
         0 1 ecode scode sub {
-	  2 mul gloff add etab exch getu16
+	  2 mul gloff add etab exch .biggetu16
 	  dup 0 ne { delta add 65535 and } if putglyph
 	} for
       } ifelse
@@ -509,14 +557,14 @@
 
 % <cmaptab> cmaparray <glypharray>
 /cmaparray {
-  dup 0 getu16
+  dup 0 .biggetu16
 
   cmapformats exch .knownget {
     DEBUG {
-      (cmap: format ) print 1 index 0 getu16 = flush
+      (cmap: format ) print 1 index 0 .biggetu16 = flush
     } if exec
   } {
-    (Can't handle format ) print 0 getu16 = flush
+    (Can't handle format ) print 0 .biggetu16 = flush
     0 1 255 { } for 256 packedarray
   } ifelse
   DEBUG {
@@ -569,24 +617,24 @@
 % Adobe requirement that each sfnts entry have even length.
 /readtables mark
 	% Ordinary tables
-  (cmap) { .readtable }
-  (head) 1 index
-  (hhea) 1 index
-  (maxp) 1 index
-  (name) 1 index
-  (OS/2) 1 index
+  (cmap) { .readbigtable }
+  (head) { .readtable }
+  (hhea) { .readtable }
+  (maxp) { .readtable }
+  (name) { .readtable }
+  (OS/2) { .readtable }
   (post) { .readbigtable }
-  (vhea) 1 index
+  (vhea) { .readbigtable }
 	% Big tables
   (glyf) { .readbigtable }
-  (loca) 1 index
-  (hmtx) 1 index
-  (vmtx) 1 index
+  (loca) { .readbigtable }
+  (hmtx) { .readbigtable }
+  (vmtx) { .readbigtable }
 	% Tables only needed for embedding in PDF files
   (cvt ) { .readtable }
-  (fpgm) 1 index
-  (prep) 1 index
-  (GSUB) 1 index
+  (fpgm) { .readtable }
+  (prep) { .readtable }
+  (GSUB) { .readtable }
 .dicttomark
 % Normally there would be a 'readonly' here, but the ttf2pf utility wants
 % to include the 'kern' table as well, so we leave the readtables dictionary
@@ -949,11 +997,11 @@
 		% The Apple cmap format is no help in determining the encoding.
 		% Look for a Microsoft table.  If we can't find one,
 		% just use the first table, whatever it is.
-  dup 4 8 getinterval exch             % the default
-  0 1 2 index 2 getu16 1 sub {
-    8 mul 4 add 1 index exch 8 getinterval
-    dup 0 getu16 /cmap_platform exch def
-    dup 2 getu16 /cmap_encoding exch def
+  dup 4 8 .biggetinterval exch             % the default
+  0 1 2 index 2 .biggetu16 1 sub {
+    8 mul 4 add 1 index exch 8 .biggetinterval
+    dup 0 .biggetu16 /cmap_platform exch def
+    dup 2 .biggetu16 /cmap_encoding exch def
     DEBUG {
       (cmap: platform ) print cmap_platform =only
       ( encoding ) print cmap_encoding = flush
@@ -962,7 +1010,7 @@
   } for
 		% Stack: subentry table
   /cmapsub 2 index def
-  exch 4 getu32 1 index length 1 index sub getinterval
+  exch 4 .biggetu32 1 index .biglength 1 index sub .biggetinterval
   /cmaptab exch def
 } bind def
 
