[gs-cvs] rev 8791 - in trunk/gs: lib src
alexcher at ghostscript.com
alexcher at ghostscript.com
Mon Jun 9 06:46:09 PDT 2008
Author: alexcher
Date: 2008-06-09 06:46:08 -0700 (Mon, 09 Jun 2008)
New Revision: 8791
Modified:
trunk/gs/lib/gs_ttf.ps
trunk/gs/src/icid.h
trunk/gs/src/zcid.c
trunk/gs/src/zfcid1.c
Log:
Use a dictionary (instead of an array) to represent cmap table in
a TrueType font because the array cannot accept fonts that have both
0x0 and 0xFFFF codes. Bug 689136, customer 870.
DIFFERENCES:
None
Modified: trunk/gs/lib/gs_ttf.ps
===================================================================
--- trunk/gs/lib/gs_ttf.ps 2008-06-09 07:33:57 UTC (rev 8790)
+++ trunk/gs/lib/gs_ttf.ps 2008-06-09 13:46:08 UTC (rev 8791)
@@ -356,7 +356,10 @@
% <encodingtable> proc <glypharray>
/cmapformats mark
0 { % Apple standard 1-to-1 mapping.
- 6 256 getinterval_from_stringarray { } forall 256 packedarray
+ 6 256 getinterval_from_stringarray
+ mark 0 3 -1 roll
+ { 1 index 1 add } forall pop
+ .dicttomark
} bind
2 { % Apple 16bit CJK (ShiftJIS etc)
@@ -389,7 +392,7 @@
cmapf2_tblen 1 index sub getinterval_from_stringarray
/sH_gIA exch def
- /cmapf2_glyph_array 65535 array def
+ /cmapf2_glyph_array 0 dict def
/.cmapf2_putGID {
/cmapf2_ch cmapf2_ch_hi 8 bitshift cmapf2_ch_lo add def
@@ -434,10 +437,6 @@
} ifelse
} for
pop
- 0 1 cmapf2_glyph_array length 1 sub { % rewrite null -> 0.
- dup cmapf2_glyph_array exch get
- null eq { cmapf2_glyph_array exch 0 put } {pop} ifelse
- } for
cmapf2_glyph_array
} bind
4 { % Microsoft/Adobe segmented mapping.
@@ -458,7 +457,9 @@
glyphs code 3 -1 roll put /code code 1 add def
} bind def
% Do a first pass to compute the size of the glyphs array.
- /numcodes 0 def /glyphs 0 0 2 nseg2 3 sub {
+ /numcodes 0 def
+ /glyphs 0 dict def
+ 0 0 2 nseg2 3 sub {
% Stack: /glyphs numglyphs i2
/i2 exch def
/scode startc i2 getu16 def
@@ -470,15 +471,8 @@
exch sub 0 .max ecode scode sub 1 add add
exch 1 index add exch
numcodes add /numcodes exch def
- } for array def
- % prefill the array with 0's faster than a { 0 putglyph } repeat
- glyphs length 1024 ge {
- .array1024z 0 1024 glyphs length 1023 sub { glyphs exch 2 index putinterval } for
- glyphs dup length 1024 sub 3 -1 roll
- putinterval
- } {
- 0 1 glyphs length 1 sub { glyphs exch 0 put } for
- } ifelse
+ } for pop
+
% Now fill in the array.
/numcodes 0 def /code 0 def
0 2 nseg2 3 sub {
@@ -513,15 +507,16 @@
6 { % Single interval lookup.
dup 6 getu16a /firstcode exch def
dup 8 getu16a /ng exch def
- firstcode ng add array
+ firstcode ng add dict
% Stack: tab array
% Fill elements 0 .. firstcode-1 with 0
0 1 firstcode 1 sub { 2 copy 0 put pop } for
- dup firstcode ng getinterval
- % Stack: tab array subarray
+ dup
+ % Stack: tab dict dict
% Fill elements firstcode .. firstcode+nvalue-1 with glyph values
0 1 ng 1 sub {
- dup 2 mul 10 add 4 index exch getu16a 3 copy put pop pop
+ dup firstcode add exch
+ 2 mul 10 add 4 index exch getu16a 3 copy put pop pop
} for pop exch pop
} bind
.dicttomark readonly def % cmapformats
@@ -534,10 +529,10 @@
} if exec
} {
(Can't handle format ) print 0 getu16a = flush
- 0 1 255 { } for 256 packedarray
+ mark 0 1 255 { dup } for .dicttomark
} ifelse
TTFDEBUG {
- (cmap: length=) print dup length = dup ==
+ (cmap: length=) print dup length = dup ===
} if
} bind def
@@ -1463,12 +1458,11 @@
% Stack: glyphencoding dict index
2 index 1 index get
have_post not {
- exch dup cmapa length lt {
- cmapa exch get
- } {
- pop 0 % a stub for a while. Must skip the entry.
- } ifelse
exch
+ cmapa exch .knownget not {
+ 0 % a stub for a while. Must skip the entry.
+ } if
+ exch
} if
2 index 1 index known
{ % The same name maps to more than one glyph. Change the name.
@@ -1501,19 +1495,20 @@
readonly
/Encoding [
have_post {
- cmapa dup length 256 gt { 0 256 getinterval } if
- { glyphencoding dup length
+ 0 1 255 {
+ cmapa exch .knownget not { 0 } if
+ glyphencoding dup length
2 index le {
pop pop /.notdef
} {
exch get
} ifelse
- } forall
+ } for
} {
glyphencoding dup length 256 gt { 0 256 getinterval } if
aload pop
+ counttomark 256 exch sub { /.notdef } repeat
} ifelse
- counttomark 256 exch sub { /.notdef } repeat
]
TTFDEBUG { (Encoding: ) print dup === flush } if
} bind def
@@ -1705,9 +1700,10 @@
dup 5 1 getinterval .hexdigits exch search pop length exch pop exch pop 4 bitshift exch
dup 6 1 getinterval .hexdigits exch search pop length exch pop exch pop exch pop
add add add
- dup cmapencoding length ge //.popfex if
- cmapencoding exch get
+
+ cmapencoding exch .knownget not { 0 } if
dup 0 eq //.popfex if
+
TTFDEBUG { ( index=) print dup =string cvs print } if
exch pop
put //true exit
@@ -1717,8 +1713,9 @@
pop //false
} ifelse
not { % d n g
- { dup cmapencoding length ge //.pop3ex if
- cmapencoding exch get dup 0 eq //.pop3ex if
+ {
+ cmapencoding exch .knownget not { 0 } if
+ dup 0 eq //.pop3ex if
3 copy pop known //.pop3ex if
put exit
} loop
Modified: trunk/gs/src/icid.h
===================================================================
--- trunk/gs/src/icid.h 2008-06-09 07:33:57 UTC (rev 8790)
+++ trunk/gs/src/icid.h 2008-06-09 13:46:08 UTC (rev 8791)
@@ -32,7 +32,7 @@
const ref *SubstNWP,
uint nCID, uint *c, ref *src_type, ref *dst_type);
-/* Create a CIDMap from a True Type cmap array, Decoding and SubstNWP. */
+/* Create a CIDMap from a True Type cmap, Decoding and SubstNWP. */
int cid_fill_CIDMap(const gs_memory_t *mem, const ref *Decoding, const ref *TT_cmap, const ref *SubstNWP,
int GDBytes, ref *CIDMap);
Modified: trunk/gs/src/zcid.c
===================================================================
--- trunk/gs/src/zcid.c 2008-06-09 07:33:57 UTC (rev 8790)
+++ trunk/gs/src/zcid.c 2008-06-09 13:46:08 UTC (rev 8791)
@@ -51,7 +51,7 @@
static bool
TT_char_code_from_CID_no_subst(const gs_memory_t *mem,
const ref *Decoding, const ref *TT_cmap, uint nCID, uint *c)
-{ ref *DecodingArray, char_code, char_code1, ih, glyph_index;
+{ ref *DecodingArray, char_code, char_code1, ih, *glyph_index;
bool found = false;
int i = nCID % 256, n;
@@ -72,9 +72,9 @@
if (array_get(mem, DecodingArray, i, &char_code1) < 0 ||
!r_has_type(&char_code1, t_integer))
return false; /* Must not happen. */
- if (array_get(mem, TT_cmap, char_code1.value.intval, &glyph_index) >= 0 &&
- r_has_type(&glyph_index, t_integer)) {
- *c = glyph_index.value.intval;
+ if (dict_find(TT_cmap, &char_code1, &glyph_index) >= 0 &&
+ r_has_type(glyph_index, t_integer)) {
+ *c = glyph_index->value.intval;
found = true;
if (*c != 0)
return true;
Modified: trunk/gs/src/zfcid1.c
===================================================================
--- trunk/gs/src/zfcid1.c 2008-06-09 07:33:57 UTC (rev 8790)
+++ trunk/gs/src/zfcid1.c 2008-06-09 13:46:08 UTC (rev 8791)
@@ -418,7 +418,7 @@
int code;
check_type(*Decoding, t_dictionary);
- check_type(*TT_cmap, t_array);
+ check_type(*TT_cmap, t_dictionary);
check_type(*SubstNWP, t_array);
check_type(*GDBytes, t_integer);
check_type(*CIDMap, t_array);
More information about the gs-cvs
mailing list