[gs-cvs] gs/src
L. Peter Deutsch
lpd at casper.ghostscript.com
Sun Jun 9 16:08:25 PDT 2002
Update of /cvs/ghostscript/gs/src
In directory casper:/tmp/cvs-serv18429/src
Modified Files:
gdevmacxf.c gdevmsxf.c gdevpdff.c gdevpdfs.c gdevpdfw.c
gdevpsf1.c gdevpsf2.c gdevpsft.c gdevxxf.c gsccode.h gscencs.c
gscencs.h gsfont.c gxccache.c gxchar.c gxchar.h gxfont.h
gxxfont.h iccfont.c ifont.h int.mak lib.mak zbfont.c zchar1.c
Log Message:
Cleans up a number of design problems in the font callback procedures:
1) Eliminates the gx_xfont_callbacks structure entirely. The known_encode
procedure is no longer needed: the new facilities in gscencs.[hc] make it
unnecessary, and none of the three implementors of the xfont interface
use it. See below regarding glyph_name. This is a NON-BACKWARD-
COMPATIBLE change for all clients of the glyph_name and known_encode
procedures (of which there are, respectively, 11 and 0 in the current
code base), and for all places that define gs_font_procs structures
statically or initialize the callbacks dynamically (of which there are
currently only two, one in gsfont.c and one in zbfont.c). There are also
3 identical places in the GhostPCL code (in plfont.c, plffont.c, and
plufont.c) that will require very minor changes, with a small net
reduction in code.
2) Deletes the char_xglyph2 procedure from gx_xfont_procs. It is optional,
and none of the three current xfont implementations implements it.
3) Changes the char_xglyph procedure in gx_xfont_procs so that instead of a
glyph_name callback procedure, it takes a const gs_string * argument that
is the actual glyph name (if the glyph is not gs_no_glyph and is not a
CID). This is a NON-BACKWARD-COMPATIBLE change for both clients and
implementors of xfonts. (At present, there are 3 implementors, none of
which use the glyph_name callback, and a single client call in
gxccache.c.)
4) Moves the glyph_name procedure, which is still required for other
purposes, to gs_font_procs, changing its declaration to
int (*glyph_name)(gs_font *font, gs_glyph glyph,
gs_const_string *pstr);
This is a NON-BACKWARD-COMPATIBLE change for clients, but they must
already change because of item (1) above.
5) Eliminates the registered_Encodings array in the PostScript interpreter,
substituting the C representation of the known Encodings.
Index: gdevmacxf.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevmacxf.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- gdevmacxf.c 21 Feb 2002 22:24:51 -0000 1.5
+++ gdevmacxf.c 9 Jun 2002 23:08:22 -0000 1.6
@@ -211,9 +211,9 @@
private gx_xglyph
mac_char_xglyph(gx_xfont *xf, gs_char chr, int encoding_index,
- gs_glyph glyph, gs_proc_glyph_name_t glyph_name_proc)
+ gs_glyph glyph, const gs_const_string *glyph_name)
{
-#pragma unused(glyph_name_proc,glyph)
+#pragma unused(glyph_name,glyph)
mac_xfont * macxf = (mac_xfont*) xf;
/* can't look up names yet */
Index: gdevmsxf.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevmsxf.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- gdevmsxf.c 21 Feb 2002 22:24:51 -0000 1.4
+++ gdevmsxf.c 9 Jun 2002 23:08:22 -0000 1.5
@@ -232,7 +232,7 @@
/* Convert a character name or index to an xglyph code. */
gx_xglyph
win_char_xglyph(gx_xfont * xf, gs_char chr, int encoding_index,
- gs_glyph glyph, gs_proc_glyph_name_t glyph_name_proc)
+ gs_glyph glyph, const gs_const_string *glyph_name)
{
if (chr == gs_no_char)
return gx_no_xglyph; /* can't look up names yet */
Index: gdevpdff.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevpdff.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- gdevpdff.c 20 May 2002 07:07:15 -0000 1.29
+++ gdevpdff.c 9 Jun 2002 23:08:22 -0000 1.30
@@ -1032,9 +1032,13 @@
*/
pdf_glyph_widths_t widths;
int code = pdf_glyph_widths(ppf, glyph, (gs_font *)bfont, &widths);
+ gs_const_string gstr;
if (code < 0)
return code;
+ code = bfont->procs.glyph_name((gs_font *)bfont, glyph, &gstr);
+ if (code < 0)
+ return code;
if (pdiff == 0) {
pdiff = gs_alloc_struct_array(pdev->pdf_memory, 256,
pdf_encoding_element_t,
@@ -1046,8 +1050,7 @@
ppf->Differences = pdiff;
}
pdiff[chr].glyph = glyph;
- pdiff[chr].str.data = (const byte *)
- bfont->procs.callbacks.glyph_name(glyph, &pdiff[chr].str.size);
+ pdiff[chr].str = gstr;
ppf->Widths[chr] = widths.Width;
ppf->real_widths[chr] = widths.real_width;
if (code == 0)
Index: gdevpdfs.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevpdfs.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- gdevpdfs.c 20 May 2002 07:07:15 -0000 1.19
+++ gdevpdfs.c 9 Jun 2002 23:08:22 -0000 1.20
@@ -1165,23 +1165,22 @@
* independently be in either the normal glyph space or the C encoding
* glyph space.
*/
- const char *str1;
- const char *str2;
- uint len1, len2;
+ gs_const_string str1, str2;
+ int code1, code2;
if (g1 < gs_c_min_std_encoding_glyph) {
if (g2 < gs_c_min_std_encoding_glyph)
return g1 == g2;
- str1 = font->procs.callbacks.glyph_name(g1, &len1);
- str2 = gs_c_glyph_name(g2, &len2);
+ code1 = font->procs.glyph_name(font, g1, &str1);
+ code2 = gs_c_glyph_name(g2, &str2);
} else {
if (g2 >= gs_c_min_std_encoding_glyph)
return g1 == g2;
- str1 = gs_c_glyph_name(g1, &len1);
- str2 = font->procs.callbacks.glyph_name(g2, &len2);
+ code1 = gs_c_glyph_name(g1, &str1);
+ code2 = font->procs.glyph_name(font, g2, &str2);
}
- return (str1 != 0 && str2 != 0 && len1 == len2 &&
- !memcmp(str1, str2, len1));
+ return (code1 >= 0 && code2 >= 0 && str1.size == str2.size &&
+ !memcmp(str1.data, str2.data, str1.size));
}
private int
@@ -1412,10 +1411,11 @@
if (font_glyph == gs_no_glyph)
break;
else if (font_glyph >= gs_c_min_std_encoding_glyph) {
- uint len;
- const char *str = gs_c_glyph_name(font_glyph, &len);
+ gs_const_string str;
- if (len == 7 && !memcmp(str, ".notdef", 7))
+ if (gs_c_glyph_name(font_glyph, &str) >= 0 &&
+ str.size == 7 && !memcmp(str.data, ".notdef", 7)
+ )
break;
} else if (gs_font_glyph_is_notdef(bfont, font_glyph))
break;
@@ -1669,12 +1669,12 @@
if (font_glyph >= gs_c_min_std_encoding_glyph)
find_glyph = font_glyph;
else {
- uint len;
- const char *str = bfont->procs.callbacks.glyph_name(font_glyph, &len);
+ gs_const_string str;
+ int code = bfont->procs.glyph_name((gs_font *)bfont, font_glyph, &str);
- if (str == 0)
+ if (code < 0)
return -1;
- find_glyph = gs_c_name_glyph(str, len);
+ find_glyph = gs_c_name_glyph(str.data, str.size);
if (find_glyph == gs_no_glyph)
return -1;
}
Index: gdevpdfw.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevpdfw.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- gdevpdfw.c 20 May 2002 07:07:15 -0000 1.18
+++ gdevpdfw.c 9 Jun 2002 23:08:22 -0000 1.19
@@ -234,14 +234,16 @@
stream_puts(s, "/CharSet(");
for (i = 0; i < subset_size; ++i) {
- uint len;
- const char *str = font->procs.callbacks.glyph_name
- (subset_glyphs[i], &len);
+ gs_const_string str;
+ int code =
+ font->procs.glyph_name(font, subset_glyphs[i], &str);
/* Don't include .notdef. */
- if (bytes_compare((const byte *)str, len,
- (const byte *)".notdef", 7))
- pdf_put_name(pdev, (const byte *)str, len);
+ if (code >= 0 &&
+ bytes_compare(str.data, str.size,
+ (const byte *)".notdef", 7)
+ )
+ pdf_put_name(pdev, str.data, str.size);
}
stream_puts(s, ")\n");
}
Index: gdevpsf1.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevpsf1.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- gdevpsf1.c 21 Feb 2002 22:24:52 -0000 1.12
+++ gdevpsf1.c 9 Jun 2002 23:08:22 -0000 1.13
@@ -17,6 +17,7 @@
/* $Id$ */
/* Write an embedded Type 1 font */
#include "memory_.h"
+#include <assert.h>
#include "gx.h"
#include "gserrors.h"
#include "gsccode.h"
@@ -126,8 +127,7 @@
gs_glyph glyph =
(*pfont->procs.encode_char)
((gs_font *)pfont, (gs_char)i, GLYPH_SPACE_NAME);
- const char *namestr;
- uint namelen;
+ gs_const_string namestr;
if (subset_glyphs && subset_size) {
/*
@@ -140,11 +140,11 @@
continue;
}
if (glyph != gs_no_glyph && glyph != notdef &&
- (namestr = (*pfont->procs.callbacks.glyph_name)
- (glyph, &namelen)) != 0
+ pfont->procs.glyph_name((gs_font *)pfont, glyph,
+ &namestr) >= 0
) {
pprintd1(s, "dup %d /", (int)i);
- stream_write(s, namestr, namelen);
+ stream_write(s, namestr.data, namestr.size);
stream_puts(s, " put\n");
}
}
@@ -297,12 +297,13 @@
if (code == 0 &&
(code = pdata->procs.glyph_data(pfont, glyph, &gdata)) >= 0
) {
- uint gssize;
- const char *gstr =
- (*pfont->procs.callbacks.glyph_name)(glyph, &gssize);
+ gs_const_string gstr;
+ int code;
+ code = pfont->procs.glyph_name((gs_font *)pfont, glyph, &gstr);
+ assert(code >= 0);
stream_puts(s, "/");
- stream_write(s, gstr, gssize);
+ stream_write(s, gstr.data, gstr.size);
pprintd1(s, " %d -| ", gdata.bits.size);
write_CharString(s, gdata.bits.data, gdata.bits.size);
stream_puts(s, " |-\n");
Index: gdevpsf2.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevpsf2.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- gdevpsf2.c 12 May 2002 22:38:08 -0000 1.19
+++ gdevpsf2.c 9 Jun 2002 23:08:22 -0000 1.20
@@ -156,13 +156,13 @@
private int
cff_glyph_sid(cff_writer_t *pcw, gs_glyph glyph)
{
- uint len;
- const byte *chars = (const byte *)
- pcw->pfont->procs.callbacks.glyph_name(glyph, &len);
+ gs_const_string str;
+ int code =
+ pcw->pfont->procs.glyph_name((gs_font *)pcw->pfont, glyph, &str);
- if (chars == 0)
- return_error(gs_error_rangecheck);
- return cff_string_sid(pcw, chars, len);
+ if (code < 0)
+ return code;
+ return cff_string_sid(pcw, str.data, str.size);
}
/* ------ Low level ------ */
@@ -1234,11 +1234,12 @@
for (j = 0; (glyph = gs_c_known_encode((gs_char)j,
ENCODING_INDEX_CFFSTRINGS)) != gs_no_glyph;
++j) {
- uint size;
- const byte *str = (const byte *)gs_c_glyph_name(glyph, &size);
+ gs_const_string str;
int ignore;
- cff_string_index(&writer.std_strings, str, size, true, &ignore);
+ gs_c_glyph_name(glyph, &str);
+ cff_string_index(&writer.std_strings, str.data, str.size, true,
+ &ignore);
}
cff_string_table_init(&writer.strings, string_items,
countof(string_items));
Index: gdevpsft.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevpsft.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- gdevpsft.c 4 Jun 2002 14:51:00 -0000 1.14
+++ gdevpsft.c 9 Jun 2002 23:08:22 -0000 1.15
@@ -17,6 +17,7 @@
/* $Id$ */
/* Write an embedded TrueType font */
#include "memory_.h"
+#include <assert.h>
#include <stdlib.h> /* for qsort */
#include "gx.h"
#include "gscencs.h"
@@ -169,11 +170,12 @@
{
gs_glyph glyph = font->procs.encode_char(font, (gs_char)ch,
GLYPH_SPACE_NAME);
+ int code;
if (glyph == gs_no_glyph)
return 0; /* .notdef */
- pstr->data = (const byte *)
- font->procs.callbacks.glyph_name(glyph, &pstr->size);
+ code = font->procs.glyph_name(font, glyph, pstr);
+ assert(code >= 0);
if (glyph < gs_min_cid_glyph) {
gs_char mac_char;
gs_glyph mac_glyph;
@@ -189,7 +191,8 @@
mac_glyph = gs_c_known_encode(mac_char, ENCODING_INDEX_MACGLYPH);
if (mac_glyph == gs_no_glyph)
return -1;
- mstr.data = (const byte *)gs_c_glyph_name(mac_glyph, &mstr.size);
+ code = gs_c_glyph_name(mac_glyph, &mstr);
+ assert(code >= 0);
if (!bytes_compare(pstr->data, pstr->size, mstr.data, mstr.size))
return (int)mac_char;
}
@@ -799,12 +802,15 @@
{
byte *tab = &tables[numTables * 16];
- offset = put_table(tab, "glyf", glyf_checksum, offset, glyf_length);
- tab += 16;
+ if (!writing_stripped) {
+ offset = put_table(tab, "glyf", glyf_checksum,
+ offset, glyf_length);
+ tab += 16;
- offset = put_table(tab, "loca", loca_checksum[indexToLocFormat],
- offset, loca_length);
- tab += 16;
+ offset = put_table(tab, "loca", loca_checksum[indexToLocFormat],
+ offset, loca_length);
+ tab += 16;
+ }
if (!have_cmap) {
cmap_length = size_cmap(font, TT_BIAS, 256,
Index: gdevxxf.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevxxf.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- gdevxxf.c 21 Feb 2002 22:24:52 -0000 1.7
+++ gdevxxf.c 9 Jun 2002 23:08:23 -0000 1.8
@@ -261,7 +261,7 @@
/* Convert a character name or index to an xglyph code. */
private gx_xglyph
x_char_xglyph(gx_xfont * xf, gs_char chr, int encoding_index,
- gs_glyph glyph, gs_proc_glyph_name_t glyph_name_proc)
+ gs_glyph glyph, const gs_const_string *glyph_name)
{
const x_xfont *xxf = (x_xfont *) xf;
Index: gsccode.h
===================================================================
RCS file: /cvs/ghostscript/gs/src/gsccode.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- gsccode.h 3 Jun 2002 16:54:27 -0000 1.7
+++ gsccode.h 9 Jun 2002 23:08:23 -0000 1.8
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 2000 Aladdin Enterprises. All rights reserved.
+/* Copyright (C) 1993, 2000, 2002 Aladdin Enterprises. All rights reserved.
This software is provided AS-IS with no warranty, either express or
implied.
@@ -54,23 +54,6 @@
/* Define a procedure for marking a gs_glyph during garbage collection. */
typedef bool (*gs_glyph_mark_proc_t)(gs_glyph glyph, void *proc_data);
-/* Define a procedure for mapping a gs_glyph to its (string) name. */
-/*
- * NOTE: As of release 6.21, his procedure is obsolete and deprecated,
- * but it must be supported for backward compatibility for the xfont
- * interface.
- */
-#define gs_proc_glyph_name(proc)\
- const char *proc(P2(gs_glyph, uint *))
-typedef gs_proc_glyph_name((*gs_proc_glyph_name_t));
-/*
- * This is the updated procedure, which accepts closure data and also can
- * return an error code.
- */
-#define gs_glyph_name_proc(proc)\
- int proc(P3(gs_glyph glyph, gs_const_string *pstr, void *proc_data))
-typedef gs_glyph_name_proc((*gs_glyph_name_proc_t));
-
/* Define the indices for known encodings. */
typedef enum {
ENCODING_INDEX_UNKNOWN = -1,
@@ -108,18 +91,11 @@
} gs_glyph_space_t;
/*
- * Define a procedure for accessing the known encodings. Note that if
- * there is a choice, this procedure always returns a glyph name, not a
- * glyph index.
+ * Define a procedure for mapping a glyph to its (string) name. This is
+ * currently used only for CMaps: it is *not* the same as the glyph_name
+ * procedure in fonts.
*/
-#define gs_proc_known_encode(proc)\
- gs_glyph proc(P2(gs_char, int))
-typedef gs_proc_known_encode((*gs_proc_known_encode_t));
-
-/* Define the callback procedure vector for character to xglyph mapping. */
-typedef struct gx_xfont_callbacks_s {
- gs_proc_glyph_name((*glyph_name));
- gs_proc_known_encode((*known_encode));
-} gx_xfont_callbacks;
+typedef int (*gs_glyph_name_proc_t)(gs_glyph glyph, gs_const_string *pstr,
+ void *proc_data);
#endif /* gsccode_INCLUDED */
Index: gscencs.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gscencs.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- gscencs.c 24 May 2002 19:15:20 -0000 1.4
+++ gscencs.c 9 Jun 2002 23:08:23 -0000 1.5
@@ -65,30 +65,25 @@
/*
* Convert a glyph number returned by gs_c_known_encode to a string.
*/
-const char *
-gs_c_glyph_name(gs_glyph g, uint *plen)
+int
+gs_c_glyph_name(gs_glyph glyph, gs_const_string *pstr)
{
- uint n = (uint)(g - gs_c_min_std_encoding_glyph);
+ uint n = (uint)(glyph - gs_c_min_std_encoding_glyph);
uint len = N_LEN(n);
uint off = N_OFFSET(n);
+#ifdef DEBUG
if (len == 0 || len > gs_c_known_encoding_max_length ||
off >= gs_c_known_encoding_offsets[len + 1] -
gs_c_known_encoding_offsets[len] ||
off % len != 0
)
- return 0;
- *plen = len;
- return &gs_c_known_encoding_chars[gs_c_known_encoding_offsets[len] + off];
-}
-int
-gs_c_glyph_name2(gs_glyph g, gs_const_string *pstr, void *proc_data)
-{
- pstr->data = (const byte *)gs_c_glyph_name(g, &pstr->size);
- if (pstr->data != 0)
- return 0;
- else
return_error(gs_error_rangecheck);
+#endif
+ pstr->data = (const byte *)
+ &gs_c_known_encoding_chars[gs_c_known_encoding_offsets[len] + off];
+ pstr->size = len;
+ return 0;
}
/*
@@ -96,7 +91,7 @@
* gs_c_glyph_name), or gs_no_glyph if the glyph name is not known.
*/
gs_glyph
-gs_c_name_glyph(const char *str, uint len)
+gs_c_name_glyph(const byte *str, uint len)
{
if (len == 0 || len > gs_c_known_encoding_max_length)
return gs_no_glyph;
@@ -140,33 +135,32 @@
main()
{
gs_glyph g;
- const char *s;
- uint len;
+ gs_const_string str;
/* Test with a short name. */
g = gs_c_known_encode((gs_char)0237, 1); /* caron */
printf("caron is %u, should be %u\n",
g - gs_c_min_std_encoding_glyph, I_caron);
- s = gs_c_glyph_name(g, &len);
- fwrite(s, 1, len, stdout);
+ gs_c_glyph_name(g, &str);
+ fwrite(str.data, 1, str.size, stdout);
printf(" should be caron\n");
/* Test with a long name. */
g = gs_c_known_encode((gs_char)0277, 2); /* carriagereturn */
printf("carriagereturn is %u, should be %u\n",
g - gs_c_min_std_encoding_glyph, I_carriagereturn);
- s = gs_c_glyph_name(g, &len);
- fwrite(s, 1, len, stdout);
+ gs_c_glyph_name(g, &str);
+ fwrite(str.data, 1, str.size, stdout);
printf(" should be carriagereturn\n");
/* Test lookup with 3 kinds of names. */
- g = gs_c_name_glyph("circlemultiply", 14);
+ g = gs_c_name_glyph((const byte *)"circlemultiply", 14);
printf("circlemultiply is %u, should be %u\n",
g - gs_c_min_std_encoding_glyph, I_circlemultiply);
- g = gs_c_name_glyph("numbersign", 10);
+ g = gs_c_name_glyph((const byte *)"numbersign", 10);
printf("numbersign is %u, should be %u\n",
g - gs_c_min_std_encoding_glyph, I_numbersign);
- g = gs_c_name_glyph("copyright", 9);
+ g = gs_c_name_glyph((const byte *)"copyright", 9);
printf("copyright is %u, should be %u\n",
g - gs_c_min_std_encoding_glyph, I_copyright);
Index: gscencs.h
===================================================================
RCS file: /cvs/ghostscript/gs/src/gscencs.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gscencs.h 12 May 2002 22:38:08 -0000 1.1
+++ gscencs.h 9 Jun 2002 23:08:23 -0000 1.2
@@ -48,18 +48,17 @@
* Encode a character in a known encoding. The only use for glyph numbers
* returned by this procedure is to pass them to gs_c_glyph_name.
*/
-gs_proc_known_encode(gs_c_known_encode);
+gs_glyph gs_c_known_encode(gs_char chr, int encoding_index);
/*
* Convert a glyph number returned by gs_c_known_encode to a string.
*/
-gs_proc_glyph_name(gs_c_glyph_name); /* old procedure */
-gs_glyph_name_proc(gs_c_glyph_name2); /* new procedure */
+int gs_c_glyph_name(gs_glyph glyph, gs_const_string *pstr);
/*
* Return the glyph number corresponding to a string (the inverse of
* gs_c_glyph_name), or gs_no_glyph if the glyph name is not known.
*/
-gs_glyph gs_c_name_glyph(const char *str, uint len);
+gs_glyph gs_c_name_glyph(const byte *str, uint len);
#endif /* gscencs_INCLUDED */
Index: gsfont.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gsfont.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- gsfont.c 30 May 2002 07:11:51 -0000 1.9
+++ gsfont.c 9 Jun 2002 23:08:23 -0000 1.10
@@ -53,13 +53,10 @@
gs_no_enumerate_glyph,
gs_default_glyph_info,
gs_no_glyph_outline,
+ gs_no_glyph_name,
gs_default_init_fstack,
gs_default_next_char_glyph,
- gs_no_build_char,
- {
- 0, /* glyph_name */
- 0 /* known_encode */
- } /* callbacks */
+ gs_no_build_char
};
private_st_font_dir();
@@ -816,9 +813,8 @@
return false;
if (glyph >= gs_min_cid_glyph)
return (glyph == gs_min_cid_glyph);
- gnstr.data = (const byte *)
- bfont->procs.callbacks.glyph_name(glyph, &gnstr.size);
- return (gnstr.size == 7 && !memcmp(gnstr.data, ".notdef", 7));
+ return (bfont->procs.glyph_name((gs_font *)bfont, glyph, &gnstr) >= 0 &&
+ gnstr.size == 7 && !memcmp(gnstr.data, ".notdef", 7));
}
/* Dummy character encoding procedure */
@@ -895,6 +891,13 @@
int
gs_no_glyph_outline(gs_font *font, gs_glyph glyph, const gs_matrix *pmat,
gx_path *ppath)
+{
+ return_error(gs_error_undefined);
+}
+
+/* Dummy glyph name procedure */
+int
+gs_no_glyph_name(gs_font *font, gs_glyph glyph, gs_const_string *pstr)
{
return_error(gs_error_undefined);
}
Index: gxccache.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gxccache.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- gxccache.c 21 Feb 2002 22:24:53 -0000 1.7
+++ gxccache.c 9 Jun 2002 23:08:23 -0000 1.8
@@ -16,10 +16,12 @@
/* $Id$ */
/* Fast case character cache routines for Ghostscript library */
+#include "memory_.h"
#include "gx.h"
#include "gpcheck.h"
#include "gserrors.h"
#include "gsstruct.h"
+#include "gscencs.h"
#include "gxfixed.h"
#include "gxmatrix.h"
#include "gzstate.h"
@@ -126,7 +128,7 @@
/* Return the cached_char or 0. */
cached_char *
gx_lookup_xfont_char(const gs_state * pgs, cached_fm_pair * pair,
-gs_char chr, gs_glyph glyph, const gx_xfont_callbacks * callbacks, int wmode)
+ gs_char chr, gs_glyph glyph, int wmode)
{
gs_font *font = pair->font;
int enc_index;
@@ -151,20 +153,25 @@
return NULL;
{
const gx_xfont_procs *procs = xf->common.procs;
+ gs_const_string gstr;
+ int code = font->procs.glyph_name(font, glyph, &gstr);
- if (procs->char_xglyph2 == 0) { /* The xfont can't recognize reencoded fonts. */
- /* Use the registered encoding only if this glyph */
- /* is the same as the one in the registered encoding. */
- if (enc_index >= 0 &&
- (*callbacks->known_encode) (chr, enc_index) != glyph
+ if (code < 0)
+ return NULL;
+ if (enc_index >= 0 && ((gs_font_base *)font)->encoding_index < 0) {
+ /*
+ * Use the registered encoding only if this glyph
+ * is the same as the one in the registered encoding.
+ */
+ gs_const_string kstr;
+
+ if (gs_c_glyph_name(gs_c_known_encode(chr, enc_index), &kstr) < 0 ||
+ kstr.size != gstr.size ||
+ memcmp(kstr.data, gstr.data, kstr.size)
)
enc_index = -1;
- xg = (*procs->char_xglyph) (xf, chr, enc_index, glyph,
- callbacks->glyph_name);
- } else { /* The xfont can recognize reencoded fonts. */
- xg = (*procs->char_xglyph2) (xf, chr, enc_index, glyph,
- callbacks);
}
+ xg = procs->char_xglyph(xf, chr, enc_index, glyph, &gstr);
if (xg == gx_no_xglyph)
return NULL;
if ((*procs->char_metrics) (xf, xg, wmode, &wxy, &bbox) < 0)
Index: gxchar.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gxchar.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- gxchar.c 2 Jun 2002 12:01:31 -0000 1.13
+++ gxchar.c 9 Jun 2002 23:08:23 -0000 1.14
@@ -839,7 +839,7 @@
goto no_cache;
if (pfont->BitmapWidths) {
cc = gx_lookup_xfont_char(pgs, pair, chr,
- glyph, &pfont->procs.callbacks, wmode);
+ glyph, wmode);
if (cc == 0)
goto no_cache;
} else {
@@ -851,7 +851,7 @@
/* We might have an xfont, but we still */
/* want the scalable widths. */
cc = gx_lookup_xfont_char(pgs, pair, chr,
- glyph, &pfont->procs.callbacks, wmode);
+ glyph, wmode);
/* Render up to the point of */
/* setcharwidth or setcachedevice, */
/* just as for stringwidth. */
Index: gxchar.h
===================================================================
RCS file: /cvs/ghostscript/gs/src/gxchar.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- gxchar.h 2 Jun 2002 11:59:20 -0000 1.7
+++ gxchar.h 9 Jun 2002 23:08:23 -0000 1.8
@@ -120,7 +120,7 @@
cached_char *
gx_lookup_cached_char(P5(const gs_font *, const cached_fm_pair *, gs_glyph, int, int));
cached_char *
- gx_lookup_xfont_char(P6(const gs_state *, cached_fm_pair *, gs_char, gs_glyph, const gx_xfont_callbacks *, int));
+ gx_lookup_xfont_char(P5(const gs_state *, cached_fm_pair *, gs_char, gs_glyph, int));
int gx_image_cached_char(P2(gs_show_enum *, cached_char *));
void gx_compute_text_oversampling(P4(const gs_show_enum * penum, const gs_font *pfont,
int alpha_bits, gs_log2_scale_point *p_log2_scale));
Index: gxfont.h
===================================================================
RCS file: /cvs/ghostscript/gs/src/gxfont.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- gxfont.h 30 May 2002 07:11:51 -0000 1.12
+++ gxfont.h 9 Jun 2002 23:08:23 -0000 1.13
@@ -259,6 +259,14 @@
gx_path *ppath))
font_proc_glyph_outline((*glyph_outline));
+ /*
+ * Return the (string) name of a glyph.
+ */
+
+#define font_proc_glyph_name(proc)\
+ int proc(P3(gs_font *font, gs_glyph glyph, gs_const_string *pstr))
+ font_proc_glyph_name((*glyph_name));
+
/* ------ Glyph rendering procedures ------ */
/*
@@ -297,11 +305,6 @@
int proc(P5(gs_text_enum_t *, gs_state *, gs_font *, gs_char, gs_glyph))
font_proc_build_char((*build_char));
- /* Callback procedures for external font rasterizers */
- /* (see gsccode.h for details.) */
-
- gx_xfont_callbacks callbacks;
-
} gs_font_procs;
/* Default font-level font procedures in gsfont.c */
@@ -316,6 +319,7 @@
font_proc_enumerate_glyph(gs_no_enumerate_glyph);
font_proc_glyph_info(gs_default_glyph_info);
font_proc_glyph_outline(gs_no_glyph_outline);
+font_proc_glyph_name(gs_no_glyph_name);
/* Default glyph rendering procedures in gstext.c */
font_proc_init_fstack(gs_default_init_fstack);
font_proc_next_char_glyph(gs_default_next_char_glyph);
Index: gxxfont.h
===================================================================
RCS file: /cvs/ghostscript/gs/src/gxxfont.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- gxxfont.h 21 Feb 2002 22:24:53 -0000 1.4
+++ gxxfont.h 9 Jun 2002 23:08:23 -0000 1.5
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1993, 1994, 1996 Aladdin Enterprises. All rights reserved.
+/* Copyright (C) 1992, 1993, 1994, 1996, 2002 Aladdin Enterprises. All rights reserved.
This software is provided AS-IS with no warranty, either express or
implied.
@@ -100,13 +100,18 @@
/*
* Convert a character name to an xglyph code. encoding_index is
* actually a gs_encoding_index_t. Either chr or glyph may be absent
- * (gs_no_char/glyph), but not both.
+ * (gs_no_char/glyph), but not both. glyph_name is the glyph's
+ * (string) name if the glyph is not GS_NO_GLYPH and is not a CID.
+ */
+ /*
+ * This procedure was deprecated as of release 3.43, but still
+ * supported. In release 7.21, the argument list was changed, and the
+ * procedure is no longer deprecated.
*/
- /* OBSOLETE as of release 3.43, but still supported. */
#define xfont_proc_char_xglyph(proc)\
gx_xglyph proc(P5(gx_xfont *xf, gs_char chr, int encoding_index,\
- gs_glyph glyph, gs_proc_glyph_name((*glyph_name))))
+ gs_glyph glyph, const gs_const_string *glyph_name))
xfont_proc_char_xglyph((*char_xglyph));
/* Get the metrics for a character. */
@@ -134,15 +139,8 @@
int proc(P2(gx_xfont *xf, gs_memory_t *mem))
xfont_proc_release((*release));
- /* Convert a character name to an xglyph code. */
- /* This is the same as char_xglyph, except that */
- /* it takes a vector of callback procedures. */
- /* (New in release 3.43.) */
-
-#define xfont_proc_char_xglyph2(proc)\
- gx_xglyph proc(P5(gx_xfont *xf, gs_char chr, int encoding_index,\
- gs_glyph glyph, const gx_xfont_callbacks *callbacks))
- xfont_proc_char_xglyph2((*char_xglyph2));
+ /* (There was a char_xglyph2 procedure here, added in release 3.43, */
+ /* removed in 7.21.) */
};
Index: iccfont.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/iccfont.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- iccfont.c 21 Feb 2002 22:24:53 -0000 1.5
+++ iccfont.c 9 Jun 2002 23:08:23 -0000 1.6
@@ -20,6 +20,7 @@
#include "string_.h"
#include "ghost.h"
#include "gsstruct.h" /* for iscan.h */
+#include "gscencs.h"
#include "gsmatrix.h"
#include "gxfont.h" /* for ifont.h */
#include "ccfont.h"
@@ -124,9 +125,13 @@
}
if (kp->num_enc_keys) {
const charindex *skp = kp->enc_keys++;
+ gs_glyph glyph = gs_c_known_encode((gs_char)skp->charx, skp->encx);
+ gs_const_string gstr;
- code = array_get(®istered_Encoding(skp->encx), (long)(skp->charx),
- &kname);
+ if (glyph == GS_NO_GLYPH)
+ code = gs_note_error(e_undefined);
+ else if ((code = gs_c_glyph_name(glyph, &gstr)) >= 0)
+ code = name_ref(gstr.data, gstr.size, &kname, 0);
kp->num_enc_keys--;
} else { /* must have kp->num_str_keys != 0 */
code = cfont_next_string(&kep->strings);
Index: ifont.h
===================================================================
RCS file: /cvs/ghostscript/gs/src/ifont.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ifont.h 21 Feb 2002 22:24:53 -0000 1.8
+++ ifont.h 9 Jun 2002 23:08:23 -0000 1.9
@@ -69,15 +69,6 @@
#define pfont_data(pfont) ((font_data *)((pfont)->client_data))
#define pfont_dict(pfont) (&pfont_data(pfont)->dict)
-/* Registered encodings, for the benefit of platform fonts, `seac', */
-/* and compiled font initialization. */
-/* This is a t_array ref that points to the encodings. */
-#define registered_Encodings_countof NUM_KNOWN_ENCODINGS
-extern ref registered_Encodings;
-
-#define registered_Encoding(i) (registered_Encodings.value.refs[i])
-#define StandardEncoding registered_Encoding(0)
-
/* ================Internal procedures shared across files ================ */
/* ---------------- Exported by zchar.c ---------------- */
Index: int.mak
===================================================================
RCS file: /cvs/ghostscript/gs/src/int.mak,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- int.mak 26 Apr 2002 20:51:24 -0000 1.74
+++ int.mak 9 Jun 2002 23:08:23 -0000 1.75
@@ -410,7 +410,7 @@
### Graphics operators
$(PSOBJ)zbfont.$(OBJ) : $(PSSRC)zbfont.c $(OP) $(memory__h) $(string__h)\
- $(gsmatrix_h) $(gxdevice_h) $(gxfixed_h) $(gxfont_h)\
+ $(gscencs_h) $(gsmatrix_h) $(gxdevice_h) $(gxfixed_h) $(gxfont_h)\
$(bfont_h) $(ialloc_h) $(idict_h) $(idparam_h) $(ilevel_h)\
$(iname_h) $(interp_h) $(istruct_h) $(ipacked_h) $(store_h)
$(PSCC) $(PSO_)zbfont.$(OBJ) $(C_) $(PSSRC)zbfont.c
@@ -721,7 +721,7 @@
$(ADDMOD) $(PSD)psf1read -ps gs_type1
$(PSOBJ)zchar1.$(OBJ) : $(PSSRC)zchar1.c $(OP) $(memory__h)\
- $(gspaint_h) $(gspath_h) $(gsrect_h) $(gsstruct_h)\
+ $(gscencs_h) $(gspaint_h) $(gspath_h) $(gsrect_h) $(gsstruct_h)\
$(gxdevice_h) $(gxfixed_h) $(gxmatrix_h)\
$(gxfont_h) $(gxfont1_h) $(gxtype1_h) $(gzstate_h)\
$(estack_h) $(ialloc_h) $(ichar_h) $(ichar1_h) $(icharout_h)\
@@ -952,7 +952,7 @@
$(ADDMOD) $(PSD)ccfonts -ps $(ccfonts_ps)
$(PSOBJ)iccfont.$(OBJ) : $(PSSRC)iccfont.c $(GH) $(string__h)\
- $(gsmatrix_h) $(gsstruct_h) $(gxfont_h)\
+ $(gscencs_h) $(gsmatrix_h) $(gsstruct_h) $(gxfont_h)\
$(ccfont_h) $(errors_h)\
$(ialloc_h) $(idict_h) $(ifont_h) $(iname_h) $(isave_h) $(iutil_h)\
$(oper_h) $(ostack_h) $(store_h) $(stream_h) $(strimpl_h) $(sfilter_h) $(iscan_h)
Index: lib.mak
===================================================================
RCS file: /cvs/ghostscript/gs/src/lib.mak,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -d -r1.83 -r1.84
--- lib.mak 2 Jun 2002 11:56:23 -0000 1.83
+++ lib.mak 9 Jun 2002 23:08:23 -0000 1.84
@@ -283,6 +283,9 @@
gsalpha_h=$(GLSRC)gsalpha.h
gsccode_h=$(GLSRC)gsccode.h
gsccolor_h=$(GLSRC)gsccolor.h $(gsstype_h)
+# gscedata.[ch] are generated automatically by lib/encs2c.ps.
+gscedata_h=$(GLSRC)gscedata.h
+gscencs_h=$(GLSRC)gscencs.h $(stdpre_h) $(gstypes_h) $(gsccode_h)
gsclipsr_h=$(GLSRC)gsclipsr.h
gscsel_h=$(GLSRC)gscsel.h
gscolor1_h=$(GLSRC)gscolor1.h
@@ -500,7 +503,7 @@
$(GLCC) $(GLO_)gxbcache.$(OBJ) $(C_) $(GLSRC)gxbcache.c
$(GLOBJ)gxccache.$(OBJ) : $(GLSRC)gxccache.c $(GXERR) $(gpcheck_h)\
- $(gscspace_h) $(gsimage_h) $(gsstruct_h)\
+ $(gscencs_h) $(gscspace_h) $(gsimage_h) $(gsstruct_h)\
$(gxchar_h) $(gxdevice_h) $(gxdevmem_h) $(gxfcache_h)\
$(gxfixed_h) $(gxfont_h) $(gxhttile_h) $(gxmatrix_h) $(gxxfont_h)\
$(gzstate_h) $(gzpath_h) $(gzcpath_h)
@@ -658,6 +661,15 @@
$(gsalpha_h) $(gxdcolor_h) $(gzstate_h)
$(GLCC) $(GLO_)gsalpha.$(OBJ) $(C_) $(GLSRC)gsalpha.c
+# gscedata.[ch] are generated automatically by lib/encs2c.ps.
+$(GLOBJ)gscedata.$(OBJ) : $(GLSRC)gscedata.c\
+ $(stdpre_h) $(gstypes_h) $(gscedata_h)
+ $(GLCC) $(GLO_)gscedata.$(OBJ) $(C_) $(GLSRC)gscedata.c
+
+$(GLOBJ)gscencs.$(OBJ) : $(GLSRC)gscencs.c\
+ $(memory__h) $(gscedata_h) $(gscencs_h) $(gserror_h) $(gserrors_h)
+ $(GLCC) $(GLO_)gscencs.$(OBJ) $(C_) $(GLSRC)gscencs.c
+
$(GLOBJ)gschar.$(OBJ) : $(GLSRC)gschar.c $(GXERR)\
$(gscoord_h) $(gsmatrix_h) $(gsstruct_h)\
$(gxdevice_h) $(gxdevmem_h) $(gxchar_h) $(gxfont_h) $(gzstate_h)
@@ -971,8 +983,8 @@
LIB2s=$(GLOBJ)gsbitcom.$(OBJ) $(GLOBJ)gsbitops.$(OBJ) $(GLOBJ)gsbittab.$(OBJ)
# Note: gschar.c is no longer required for a standard build;
# we include it only for backward compatibility for library clients.
-LIB3s=$(GLOBJ)gschar.$(OBJ) $(GLOBJ)gscolor.$(OBJ) $(GLOBJ)gscoord.$(OBJ)
-LIB4s=$(GLOBJ)gscparam.$(OBJ) $(GLOBJ)gscspace.$(OBJ) $(GLOBJ)gscssub.$(OBJ)
+LIB3s=$(GLOBJ)gscedata.$(OBJ) $(GLOBJ)gscencs.$(OBJ) $(GLOBJ)gschar.$(OBJ) $(GLOBJ)gscolor.$(OBJ)
+LIB4s=$(GLOBJ)gscoord.$(OBJ) $(GLOBJ)gscparam.$(OBJ) $(GLOBJ)gscspace.$(OBJ) $(GLOBJ)gscssub.$(OBJ)
LIB5s=$(GLOBJ)gsdevice.$(OBJ) $(GLOBJ)gsdevmem.$(OBJ) $(GLOBJ)gsdparam.$(OBJ) $(GLOBJ)gsdfilt.$(OBJ)
LIB6s=$(GLOBJ)gsfname.$(OBJ) $(GLOBJ)gsfont.$(OBJ) $(GLOBJ)gsgdata.$(OBJ)
LIB7s=$(GLOBJ)gsht.$(OBJ) $(GLOBJ)gshtscr.$(OBJ)
@@ -1876,24 +1888,6 @@
# This is not really a library facility, but one piece of interpreter test
# code uses it.
-# C representation of known encodings.
-# gscedata.[ch] are generated automatically by lib/encs2c.ps.
-
-gscedata_h=$(GLSRC)gscedata.h
-gscencs_h=$(GLSRC)gscencs.h $(stdpre_h) $(gstypes_h) $(gsccode_h)
-
-$(GLOBJ)gscedata.$(OBJ) : $(GLSRC)gscedata.c\
- $(stdpre_h) $(gstypes_h) $(gscedata_h)
- $(GLCC) $(GLO_)gscedata.$(OBJ) $(C_) $(GLSRC)gscedata.c
-
-$(GLOBJ)gscencs.$(OBJ) : $(GLSRC)gscencs.c\
- $(memory__h) $(gscedata_h) $(gscencs_h) $(gserror_h) $(gserrors_h)
- $(GLCC) $(GLO_)gscencs.$(OBJ) $(C_) $(GLSRC)gscencs.c
-
-cencs_=$(GLOBJ)gscedata.$(OBJ) $(GLOBJ)gscencs.$(OBJ)
-$(GLD)cencs.dev : $(LIB_MAK) $(ECHOGS_XE) $(cencs_)
- $(SETMOD) $(GLD)cencs $(cencs_)
-
# Support for PostScript and PDF font writing
gdevpsf_h=$(GLSRC)gdevpsf.h $(gsccode_h) $(gsgdata_h)
@@ -1902,11 +1896,10 @@
psf_2=$(GLOBJ)gdevpsft.$(OBJ) $(GLOBJ)gdevpsfu.$(OBJ) $(GLOBJ)gdevpsfx.$(OBJ)
psf_3=$(GLOBJ)spsdf.$(OBJ)
psf_=$(psf_1) $(psf_2) $(psf_3)
-$(GLD)psf.dev : $(LIB_MAK) $(ECHOGS_XE) $(psf_) $(GLD)cencs.dev
+$(GLD)psf.dev : $(LIB_MAK) $(ECHOGS_XE) $(psf_)
$(SETMOD) $(DD)psf $(psf_1)
$(ADDMOD) $(DD)psf -obj $(psf_2)
$(ADDMOD) $(DD)psf -obj $(psf_3)
- $(ADDMOD) $(DD)psf -include $(GLD)cencs
$(GLOBJ)gdevpsf1.$(OBJ) : $(GLSRC)gdevpsf1.c $(GXERR) $(memory__h)\
$(gsccode_h) $(gsmatrix_h)\
Index: zbfont.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/zbfont.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- zbfont.c 21 Feb 2002 22:24:54 -0000 1.12
+++ zbfont.c 9 Jun 2002 23:08:23 -0000 1.13
@@ -21,6 +21,7 @@
#include "ghost.h"
#include "oper.h"
#include "gxfixed.h"
+#include "gscencs.h"
#include "gsmatrix.h"
#include "gxdevice.h"
#include "gxfont.h"
@@ -30,36 +31,15 @@
#include "idparam.h"
#include "ilevel.h"
#include "iname.h"
+#include "inamedef.h" /* for inlining name_index */
#include "interp.h" /* for initial_enter_name */
#include "ipacked.h"
#include "istruct.h"
#include "store.h"
-/* Registered encodings. See ifont.h for documentation. */
-ref registered_Encodings;
-private ref *const registered_Encodings_p = ®istered_Encodings;
-
/* Structure descriptor */
public_st_font_data();
-/* Initialize the font building operators */
-private int
-zbfont_init(i_ctx_t *i_ctx_p)
-{
- /* Initialize the registered Encodings. */
- int i;
-
- ialloc_ref_array(®istered_Encodings, a_all,
- registered_Encodings_countof,
- "registered_Encodings");
- for (i = 0; i < registered_Encodings_countof; i++)
- make_empty_array(®istered_Encoding(i), 0);
- initial_enter_name("registeredencodings", ®istered_Encodings);
- return gs_register_ref_root(imemory, NULL,
- (void **)®istered_Encodings_p,
- "registered_Encodings");
-}
-
/* <string|name> <font_dict> .buildfont3 <string|name> <font> */
/* Build a type 3 (user-defined) font. */
private int
@@ -95,29 +75,9 @@
return (gs_glyph)name_index(&cname);
}
-/* Encode a character in a known encoding. */
-private gs_glyph
-zfont_known_encode(gs_char chr, int encoding_index)
-{
- ulong index = chr; /* work around VAX widening bug */
- ref cname;
- int code;
-
- if (encoding_index < 0)
- return gs_no_glyph;
- code = array_get(®istered_Encoding(encoding_index),
- (long)index, &cname);
- if (code < 0 || !r_has_type(&cname, t_name))
- return gs_no_glyph;
- return (gs_glyph) name_index(&cname);
-}
-
/* Get the name of a glyph. */
-/* The following typedef is needed to work around a bug in */
-/* some AIX C compilers. */
-typedef const char *const_chars;
-private const_chars
-zfont_glyph_name(gs_glyph index, uint * plen)
+private int
+zfont_glyph_name(gs_font *font, gs_glyph index, gs_const_string *pstr)
{
ref nref, sref;
@@ -129,12 +89,13 @@
code = name_ref((const byte *)cid_name, strlen(cid_name),
&nref, 1);
if (code < 0)
- return 0; /* What can we possibly do here? */
+ return code;
} else
name_index_ref(index, &nref);
name_string_ref(&nref, &sref);
- *plen = r_size(&sref);
- return (const char *)sref.value.const_bytes;
+ pstr->data = sref.value.const_bytes;
+ pstr->size = r_size(&sref);
+ return 0;
}
/* ------ Initialization procedure ------ */
@@ -142,7 +103,7 @@
const op_def zbfont_op_defs[] =
{
{"2.buildfont3", zbuildfont3},
- op_def_end(zbfont_init)
+ op_def_end(0)
};
/* ------ Subroutines ------ */
@@ -383,52 +344,59 @@
lookup_gs_simple_font_encoding(gs_font_base * pfont)
{
const ref *pfe = &pfont_data(pfont)->Encoding;
- int index;
+ uint esize = r_size(pfe);
+ int index = -1;
- for (index = NUM_KNOWN_REAL_ENCODINGS; --index >= 0;)
- if (obj_eq(pfe, ®istered_Encoding(index)))
- break;
pfont->encoding_index = index;
- if (index < 0) { /* Look for an encoding that's "close". */
+ if (esize <= 256) {
+ /* Look for an encoding that's "close". */
int near_index = -1;
- uint esize = r_size(pfe);
uint best = esize / 3; /* must match at least this many */
+ gs_const_string fstrs[256];
+ int i;
- for (index = NUM_KNOWN_REAL_ENCODINGS; --index >= 0;) {
- const ref *pre = ®istered_Encoding(index);
- bool r_packed = r_has_type(pre, t_shortarray);
- bool f_packed = !r_has_type(pfe, t_array);
+ /* Get the string names of the glyphs in the font's Encoding. */
+ for (i = 0; i < esize; ++i) {
+ ref fchar;
+
+ if (array_get(pfe, (long)i, &fchar) < 0 ||
+ !r_has_type(&fchar, t_name)
+ )
+ fstrs[i].data = 0, fstrs[i].size = 0;
+ else {
+ ref nsref;
+
+ name_string_ref(&fchar, &nsref);
+ fstrs[i].data = nsref.value.const_bytes;
+ fstrs[i].size = r_size(&nsref);
+ }
+ }
+ /* Compare them against the known encodings. */
+ for (index = 0; index < NUM_KNOWN_REAL_ENCODINGS; ++index) {
uint match = esize;
- int i;
- ref fchar, rchar;
- const ref *pfchar = &fchar;
- if (r_size(pre) != esize)
- continue;
for (i = esize; --i >= 0;) {
- uint rnidx;
+ gs_const_string rstr;
- if (r_packed)
- rnidx = packed_name_index(pre->value.packed + i);
- else {
- array_get(pre, (long)i, &rchar);
- rnidx = name_index(&rchar);
- }
- if (f_packed)
- array_get(pfe, (long)i, &fchar);
- else
- pfchar = pfe->value.const_refs + i;
- if (!r_has_type(pfchar, t_name) ||
- name_index(pfchar) != rnidx
+ gs_c_glyph_name(gs_c_known_encode((gs_char)i, index), &rstr);
+ if (rstr.size == fstrs[i].size &&
+ !memcmp(rstr.data, fstrs[i].data, rstr.size)
)
- if (--match <= best)
- break;
+ continue;
+ if (--match <= best)
+ break;
+ }
+ if (match > best) {
+ best = match;
+ near_index = index;
+ /* If we have a perfect match, stop now. */
+ if (best == esize)
+ break;
}
- if (match > best)
- best = match,
- near_index = index;
}
index = near_index;
+ if (best == esize)
+ pfont->encoding_index = index;
}
pfont->nearest_encoding_index = index;
}
@@ -617,8 +585,7 @@
pfont->TransformedChar = fbit_use_outlines;
pfont->WMode = 0;
pfont->procs.encode_char = zfont_encode_char;
- pfont->procs.callbacks.glyph_name = zfont_glyph_name;
- pfont->procs.callbacks.known_encode = zfont_known_encode;
+ pfont->procs.glyph_name = zfont_glyph_name;
ialloc_set_space(idmemory, space);
copy_font_name(&pfont->font_name, &fname);
*ppfont = pfont;
Index: zchar1.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/zchar1.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- zchar1.c 21 Apr 2002 17:45:41 -0000 1.16
+++ zchar1.c 9 Jun 2002 23:08:23 -0000 1.17
@@ -28,6 +28,7 @@
#include "gxtype1.h"
#include "gzstate.h" /* for path for gs_type1_init */
/* (should only be gsstate.h) */
+#include "gscencs.h"
#include "gspaint.h" /* for gs_fill, gs_stroke */
#include "gspath.h"
#include "gsrect.h"
@@ -854,27 +855,22 @@
z1_seac_data(gs_font_type1 *pfont, int ccode, gs_glyph *pglyph,
gs_glyph_data_t *pgd)
{
- ref std_glyph;
- int code = array_get(&StandardEncoding, (long)ccode, &std_glyph);
+ gs_glyph glyph = gs_c_known_encode((gs_char)ccode,
+ ENCODING_INDEX_STANDARD);
+ int code;
+ gs_const_string gstr;
+ ref rglyph;
- if (code < 0)
+ if (glyph == GS_NO_GLYPH)
+ return_error(e_rangecheck);
+ if ((code = gs_c_glyph_name(glyph, &gstr)) < 0 ||
+ (code = name_ref(gstr.data, gstr.size, &rglyph, 0)) < 0
+ )
return code;
- if (pglyph) {
- switch (r_type(&std_glyph)) {
- case t_name:
- *pglyph = name_index(&std_glyph);
- break;
- case t_integer:
- *pglyph = gs_min_cid_glyph + std_glyph.value.intval;
- if (*pglyph < gs_min_cid_glyph || *pglyph > gs_max_glyph)
- *pglyph = gs_no_glyph;
- break;
- default:
- return_error(e_typecheck);
- }
- }
+ if (pglyph)
+ *pglyph = glyph;
if (pgd)
- code = zchar_charstring_data((gs_font *)pfont, &std_glyph, pgd);
+ code = zchar_charstring_data((gs_font *)pfont, &rglyph, pgd);
return code;
}
More information about the gs-cvs
mailing list