summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2010-11-29 14:04:18 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2010-11-29 14:04:18 +0000
commit3fb3ef70709de71399ece9e87194a3b9cc3f5118 (patch)
tree6681a3db6282dda17f91a2bf8c3b0c1b5f59d6d1
parentc01067dd32dd5d432ac6e409753c95e3ff8b43ca (diff)
still more writet1.c tweaks
git-svn-id: svn://tug.org/texlive/trunk@20599 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Build/source/texk/dvipsk/ChangeLog11
-rw-r--r--Build/source/texk/dvipsk/download.c24
-rw-r--r--Build/source/texk/dvipsk/protos.h2
-rw-r--r--Build/source/texk/dvipsk/writet1.c44
4 files changed, 48 insertions, 33 deletions
diff --git a/Build/source/texk/dvipsk/ChangeLog b/Build/source/texk/dvipsk/ChangeLog
index 284b2c05ebf..448b7d104cc 100644
--- a/Build/source/texk/dvipsk/ChangeLog
+++ b/Build/source/texk/dvipsk/ChangeLog
@@ -1,5 +1,16 @@
2010-11-29 Peter Breitenlohner <peb@mppmu.mpg.de>
+ * writet1.c: Further reduce diffs against pdftex's writet1.c.
+ Declare t1_encoding as enum instead of int.
+ Change t1_builtin_enc() from void to char **.
+
+ * writet1.c, protos.h: Replace void load_enc(char *, const char **)
+ by char **load_enc_file(char *).
+ * download.c (getEncoding): Adapt, and change result to non-const.
+ Somewhat better use of DOWNLOAD_USING_PDFTEX.
+
+2010-11-29 Peter Breitenlohner <peb@mppmu.mpg.de>
+
* writet1.c (t1_check_unusual_charstring): Drop unused variable.
2010-11-26 Peter Breitenlohner <peb@mppmu.mpg.de>
diff --git a/Build/source/texk/dvipsk/download.c b/Build/source/texk/dvipsk/download.c
index 055b2705e64..cd71ce1e5d3 100644
--- a/Build/source/texk/dvipsk/download.c
+++ b/Build/source/texk/dvipsk/download.c
@@ -328,6 +328,7 @@ download(charusetype *p, int psfont)
fprintf(bitfile, "%%EndDVIPSBitmapFont\n");
}
+#ifdef DOWNLOAD_USING_PDFTEX
/*
* Magic code to deal with PostScript font partial downloading.
* We track the encodings we've seen so far and keep them in these
@@ -336,14 +337,14 @@ download(charusetype *p, int psfont)
static struct seenEncodings {
struct seenEncodings *next;
const char *name;
- const char **glyphs;
+ char **glyphs;
} *seenEncodings;
-#define MAX_CHAR_CODE 255
+
/*
* Load a new encoding and return the array of glyphs as a vector.
* Linear search.
*/
-static const char **getEncoding(char *encoding) {
+static char **getEncoding(char *encoding) {
struct seenEncodings *p = seenEncodings;
while (p != 0)
if (strcmp(encoding, p->name) == 0)
@@ -351,15 +352,11 @@ static const char **getEncoding(char *encoding) {
else
p = p->next;
if (p == 0) {
- int i;
p = (struct seenEncodings *)mymalloc(sizeof(struct seenEncodings));
p->next = seenEncodings;
seenEncodings = p;
p->name = xstrdup(encoding);
- p->glyphs = (const char **)mymalloc((MAX_CHAR_CODE+1) * sizeof(char *));
- for (i=0; i<=MAX_CHAR_CODE; i++)
- p->glyphs[i] = ".notdef";
- load_enc(encoding, p->glyphs);
+ p->glyphs = load_enc_file(encoding);
}
return p->glyphs;
}
@@ -375,7 +372,6 @@ static const char **getEncoding(char *encoding) {
* the memory allocated for this is in extraGlyphSpace.
*/
static char *extraGlyphs = 0;
-#ifdef DOWNLOAD_USING_PDFTEX
static char *extraGlyphSpace = 0;
static int extraGlyphSize = 0;
static int glyphSizeUsed = 0;
@@ -423,9 +419,7 @@ static void addGlyph(const char *glyphName) {
static void
downpsfont(charusetype *p, charusetype *all)
{
-#ifdef DOWNLOAD_USING_PDFTEX
static unsigned char grid[256];
-#endif
int GridCount;
register int b;
register halfword bit;
@@ -470,7 +464,7 @@ downpsfont(charusetype *p, charusetype *all)
curfnt = all->fd;
#ifdef DOWNLOAD_USING_PDFTEX
if (curfnt->resfont->Vectfile) {
- const char **glyphs = getEncoding(curfnt->resfont->Vectfile);
+ char **glyphs = getEncoding(curfnt->resfont->Vectfile);
c = curfnt->chardesc + 255;
cc = 255;
for (b=15; b>=0; b--) {
@@ -506,7 +500,11 @@ downpsfont(charusetype *p, charusetype *all)
GridCount++;
}
}
- if(GridCount!=0 || extraGlyphs) {
+ if(GridCount!=0
+#ifdef DOWNLOAD_USING_PDFTEX
+ || extraGlyphs
+#endif
+ ) {
newline();
if (! disablecomments)
fprintf(bitfile, "%%%%BeginFont: %s\n", rf->PSname);
diff --git a/Build/source/texk/dvipsk/protos.h b/Build/source/texk/dvipsk/protos.h
index 52a25559240..3429da3a3b3 100644
--- a/Build/source/texk/dvipsk/protos.h
+++ b/Build/source/texk/dvipsk/protos.h
@@ -225,7 +225,7 @@ extern long unpack(unsigned char *pack, unsigned short *raster,
extern Boolean virtualfont(fontdesctype *curfnt);
/* prototypes for functions from writet1.c */
-extern void load_enc(char *, const char **);
+extern char **load_enc_file(char *);
extern boolean t1_subset_2(char *, unsigned char *, char *);
/*********** global variables ***********/
diff --git a/Build/source/texk/dvipsk/writet1.c b/Build/source/texk/dvipsk/writet1.c
index 377e82d6047..c77d79fc679 100644
--- a/Build/source/texk/dvipsk/writet1.c
+++ b/Build/source/texk/dvipsk/writet1.c
@@ -159,12 +159,10 @@ static const char *standard_glyph_names[256] = {
char **t1_glyph_names;
char *t1_builtin_glyph_names[256];
static boolean read_encoding_only;
-static int t1_encoding;
static char charstringname[] = "/CharStrings";
-#define ENC_STANDARD 0
-#define ENC_BUILTIN 1
+enum { ENC_STANDARD, ENC_BUILTIN } t1_encoding;
#define T1_BUF_SIZE 0x10
#define ENC_BUF_SIZE 0x1000
@@ -327,15 +325,21 @@ static void enc_getline(void)
goto restart;
}
-void load_enc(char *enc_name, const char **glyph_names)
+/* read encoding from .enc file, return glyph_names array, or pdffail() */
+
+char **load_enc_file(char *enc_name)
{
char buf[ENC_BUF_SIZE], *p, *r;
- int names_count;
+ int i, names_count;
+ char **glyph_names;
set_cur_file_name(enc_name);
+ glyph_names = (char **) mymalloc(256 * sizeof(char *));
+ for (i = 0; i < 256; i++)
+ glyph_names[i] = (char *) notdef;
if (!enc_open()) {
pdftex_warn("cannot open encoding file for reading");
cur_file_name = NULL;
- return;
+ return glyph_names;
}
t1_log("{");
t1_log(cur_file_name = full_file_name());
@@ -376,6 +380,7 @@ void load_enc(char *enc_name, const char **glyph_names)
enc_close();
t1_log("}");
cur_file_name = NULL;
+ return glyph_names;
}
static void t1_check_pfa(void)
@@ -683,24 +688,25 @@ static void copy_glyph_names(char **glyph_names, int a, int b)
}
}
-/* read encoding from Type1 font file or pdffail() */
+/* read encoding from Type1 font file, return glyph_names array, or pdffail() */
-static void t1_builtin_enc(void)
+static char **t1_builtin_enc(void)
{
int i, a, b, c, counter = 0;
- char *r, *p;
+ char *r, *p, **glyph_names;
/* At this moment "/Encoding" is the prefix of t1_line_array */
+ glyph_names = t1_builtin_glyph_names;
for (i = 0; i < 256; i++)
- t1_builtin_glyph_names[i] = (char *) notdef;
+ glyph_names[i] = (char *) notdef;
if (t1_suffix("def")) { /* predefined encoding */
sscanf(t1_line_array + strlen("/Encoding"), "%256s", t1_buf_array);
if (strcmp(t1_buf_array, "StandardEncoding") == 0) {
t1_encoding = ENC_STANDARD;
for (i = 0; i < 256; i++) {
if (standard_glyph_names[i] != notdef)
- t1_builtin_glyph_names[i] = xstrdup(standard_glyph_names[i]);
+ glyph_names[i] = xstrdup(standard_glyph_names[i]);
}
- return;
+ return glyph_names;
}
pdftex_fail("cannot subset font (unknown predefined encoding `%s')",
t1_buf_array);
@@ -734,7 +740,7 @@ static void t1_builtin_enc(void)
if (counter > 255)
pdftex_fail("encoding vector contains more than 256 names");
if (strcmp(t1_buf_array, notdef) != 0)
- t1_builtin_glyph_names[counter] = xstrdup(t1_buf_array);
+ glyph_names[counter] = xstrdup(t1_buf_array);
counter++;
}
if (*r != 10 && *r != '%') {
@@ -762,7 +768,7 @@ static void t1_builtin_enc(void)
if (sscanf(p, "dup %i%256s put", &i, t1_buf_array) == 2 &&
*t1_buf_array == '/' && valid_code(i)) {
if (strcmp(t1_buf_array + 1, notdef) != 0)
- t1_builtin_glyph_names[i] = xstrdup(t1_buf_array + 1);
+ glyph_names[i] = xstrdup(t1_buf_array + 1);
p = strstr(p, " put") + strlen(" put");
skip(p, ' ');
}
@@ -771,7 +777,7 @@ static void t1_builtin_enc(void)
*/
else if (sscanf(p, "dup dup %i exch %i get put", &b, &a) == 2
&& valid_code(a) && valid_code(b)) {
- copy_glyph_names(t1_builtin_glyph_names, a, b);
+ copy_glyph_names(glyph_names, a, b);
p = strstr(p, " get put") + strlen(" get put");
skip(p, ' ');
}
@@ -782,7 +788,7 @@ static void t1_builtin_enc(void)
&a, &c, &b) == 3
&& valid_code(a) && valid_code(b) && valid_code(c)) {
for (i = 0; i < c; i++)
- copy_glyph_names(t1_builtin_glyph_names, a + i, b + i);
+ copy_glyph_names(glyph_names, a + i, b + i);
p = strstr(p, " putinterval") + strlen(" putinterval");
skip(p, ' ');
}
@@ -791,7 +797,7 @@ static void t1_builtin_enc(void)
*/
else if ((p == t1_line_array || (p > t1_line_array && p[-1] == ' '))
&& strcmp(p, "def\n") == 0)
- return;
+ return glyph_names;
/*
skip an unrecognizable word
*/
@@ -802,6 +808,7 @@ static void t1_builtin_enc(void)
}
}
}
+ return glyph_names;
}
static void t1_check_end(void)
@@ -1163,11 +1170,10 @@ static void t1_subset_ascii_part(void)
t1_putline();
t1_getline();
}
- t1_builtin_enc();
if (is_reencoded(fm_cur))
t1_glyph_names = external_enc();
else
- t1_glyph_names = t1_builtin_glyph_names;
+ t1_glyph_names = t1_builtin_enc();
if (is_included(fm_cur) && is_subsetted(fm_cur)) {
make_subset_tag(fm_cur, t1_glyph_names);
update_subset_tag();