summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Build/source/texk/web2c/pdftexdir/pdftex.web81
-rw-r--r--Build/source/texk/web2c/pdftexdir/ptexlib.h2
-rw-r--r--Build/source/texk/web2c/pdftexdir/tounicode.c79
-rw-r--r--Build/source/texk/web2c/pdftexdir/writefont.c4
4 files changed, 126 insertions, 40 deletions
diff --git a/Build/source/texk/web2c/pdftexdir/pdftex.web b/Build/source/texk/web2c/pdftexdir/pdftex.web
index 3a241295e4d..b5d49d6cecb 100644
--- a/Build/source/texk/web2c/pdftexdir/pdftex.web
+++ b/Build/source/texk/web2c/pdftexdir/pdftex.web
@@ -288,7 +288,7 @@ known as `\eTeX'.
{printed when \eTeX\ starts}
@#
@d pdftex_version==140 { \.{\\pdftexversion} }
-@d pdftex_revision=="9" { \.{\\pdftexrevision} }
+@d pdftex_revision=="10" { \.{\\pdftexrevision} }
@d pdftex_version_string=='-1.40.10' {current \pdfTeX\ version}
@#
@d pdfeTeX_banner=='This is pdfeTeX, Version 3.1415926',pdftex_version_string,eTeX_version_string
@@ -9427,7 +9427,9 @@ label exit;
var p:pointer; {tail of the backup list}
@!q:pointer; {new node being added to the token list via |store_new_token|}
@!k:pool_pointer; {index into |str_pool|}
+@!save_cur_cs:pointer; {to save |cur_cs|}
begin p:=backup_head; link(p):=null; k:=str_start[s];
+save_cur_cs:=cur_cs;
while k<str_start[s+1] do
begin get_x_token; {recursion is possible here}
@^recursion@>
@@ -9438,6 +9440,7 @@ while k<str_start[s+1] do
else if (cur_cmd<>spacer)or(p<>backup_head) then
begin back_input;
if p<>backup_head then back_list(link(backup_head));
+ cur_cs:=save_cur_cs;
scan_keyword:=false; return;
end;
end;
@@ -19289,26 +19292,74 @@ if (pdf_unique_resname > 0) and (pdf_resname_prefix = 0) then
@ Finishing the PDF output file.
-The following procedures sort the table of destination names
-@p function str_less_str(s1, s2: str_number): boolean; {compare two strings}
-var j1, j2: pool_pointer;
- l, i: integer;
+The following procedures sort the table of destination names.
+@d get_next_char(#)==
+ c@&# := str_pool[j@&#];
+ incr(j@&#);
+ if (c@&# = 92) and (j@&# < e@&#) then begin
+ c@&# := str_pool[j@&#];
+ incr(j@&#);
+ if (c@&# >= 48) and (c@&# <= 55) then begin
+ c@&# := c@&# - 48;
+ if (j@&# < e@&#) and (str_pool[j@&#] >= 48)
+ and (str_pool[j@&#] <= 55) then begin
+ c@&# := 8 * c@&# + str_pool[j@&#] - 48;
+ incr(j@&#);
+ if (j@&# < e@&#) and (str_pool[j@&#] >= 48)
+ and (str_pool[j@&#] <= 55)
+ and (c@&# < 32) then begin
+ c@&# := 8 * c@&# + str_pool[j@&#] - 48;
+ incr(j@&#);
+ end;
+ end;
+ end else begin
+ case c@&# of
+ 98: c@&# := 8; {`\.b': backspace}
+ 102: c@&# := 12; {`\.f': form feed}
+ 110: c@&# := 10; {`\.n': line feed}
+ 114: c@&# := 13; {`\.r': carriage return}
+ 116: c@&# := 9; {`\.t': horizontal tab}
+ {nothing to do for `\.{\\}', `\.(', `\.)'}
+ othercases do_nothing
+ endcases;
+ end;
+ end
+
+@p function str_less_str(s1, s2: str_number): boolean; {compare two pdf strings}
+var j1, j2, e1, e2: pool_pointer;
+ c1, c2: packed_ASCII_code;
begin
+ {Minimal requirement: output of \.{\\pdfescapestring} must be supported.}
+ {This implementation also supports all escape sequences}
+ {listed in the table `Escape sequences in literal strings'}
+ {of the pdf specification.}
+ {End-of-line markers are not detected:}
+ {The marker is not replaced by `\.{\\n}' or removed if it is escaped.}
j1 := str_start[s1];
j2 := str_start[s2];
- if length(s1) < length(s2) then
- l := length(s1)
- else
- l := length(s2);
- i := 0;
- while (i < l) and (str_pool[j1 + i] = str_pool[j2 + i]) do
- incr(i);
- if ((i < l) and (str_pool[j1 + i] < str_pool[j2 + i])) or
- ((i = l) and (length(s1) < length(s2))) then
+ e1 := j1 + length(s1);
+ e2 := j2 + length(s2);
+ while (j1 < e1) and (j2 < e2) do begin
+ {get next character of first string}
+ get_next_char(1);
+ {get next character of second string}
+ get_next_char(2);
+ {compare characters}
+ if c1 < c2 then begin
+ str_less_str := true;
+ return;
+ end
+ else if c1 > c2 then begin
+ str_less_str := false;
+ return;
+ end;
+ end;
+ {compare string lengths}
+ if (j1 >= e1) and (j2 < e2) then
str_less_str := true
else
str_less_str := false;
-end;
+exit: end;
procedure sort_dest_names(l, r: integer); {sorts |dest_names| by names}
var i, j: integer;
diff --git a/Build/source/texk/web2c/pdftexdir/ptexlib.h b/Build/source/texk/web2c/pdftexdir/ptexlib.h
index 48eac9ae2bf..9c17e3eca4e 100644
--- a/Build/source/texk/web2c/pdftexdir/ptexlib.h
+++ b/Build/source/texk/web2c/pdftexdir/ptexlib.h
@@ -198,7 +198,7 @@ extern boolean handle_subfont_fm(fm_entry *, int);
/* tounicode.c */
extern void glyph_unicode_free(void);
extern void deftounicode(strnumber, strnumber);
-extern integer write_tounicode(char **, char *);
+extern integer write_tounicode(char **, const char *, const char *);
/* utils.c */
extern boolean str_eq_cstr(strnumber, char *);
diff --git a/Build/source/texk/web2c/pdftexdir/tounicode.c b/Build/source/texk/web2c/pdftexdir/tounicode.c
index 99b7d0fc247..80d52bf79dc 100644
--- a/Build/source/texk/web2c/pdftexdir/tounicode.c
+++ b/Build/source/texk/web2c/pdftexdir/tounicode.c
@@ -124,7 +124,7 @@ void deftounicode(strnumber glyph, strnumber unistr)
}
-static long check_unicode_value(char *s, boolean multiple_value)
+static long check_unicode_value(const char *s, boolean multiple_value)
{
int l = strlen(s);
int i;
@@ -181,12 +181,15 @@ static char *utf16be_str(long code)
}
-/* this function set proper values to *gp based on s; in case it returns
+/* this function writes /ToUnicode data to *gp based on glyph name s and
+ * taking into account tfmname; in case it returns
* gp->code == UNI_EXTRA_STRING then the caller is responsible for freeing
* gp->unicode_seq too */
-static void set_glyph_unicode(char *s, glyph_unicode_entry * gp)
+static void set_glyph_unicode(const char *s, const char* tfmname,
+ glyph_unicode_entry *gp)
{
char buf[SMALL_BUF_SIZE], buf2[SMALL_BUF_SIZE], *p;
+ const char *p2; /* p2 points in s; p above points in writable copies */
long code;
boolean last_component;
glyph_unicode_entry tmp, *ptmp;
@@ -220,7 +223,7 @@ static void set_glyph_unicode(char *s, glyph_unicode_entry * gp)
for (;;) {
*p = 0;
tmp.code = UNI_UNDEF;
- set_glyph_unicode(s, &tmp);
+ set_glyph_unicode(s, tfmname, &tmp);
switch (tmp.code) {
case UNI_UNDEF: /* not found, do nothing */
break;
@@ -253,8 +256,26 @@ static void set_glyph_unicode(char *s, glyph_unicode_entry * gp)
return;
}
- /* lookup for glyph name in the database */
- tmp.name = s;
+ /* Glyph name search strategy: first look up the glyph name in the
+ tfm's namespace, failing that look it up in the main database. */
+ /* Note: buf may alias s in the code below, but s and buf2 are
+ guaranteed to be distinct because the code changing buf2 above
+ always returns before reaching the code below. */
+
+ /* lookup for glyph name in the tfm's namespace */
+ snprintf(buf2, SMALL_BUF_SIZE, "tfm:%s/%s", tfmname, s);
+ tmp.name = buf2;
+ tmp.code = UNI_UNDEF;
+ ptmp = (glyph_unicode_entry *) avl_find(glyph_unicode_tree, &tmp);
+ if (ptmp != NULL) {
+ gp->code = ptmp->code;
+ gp->unicode_seq = ptmp->unicode_seq;
+ return;
+ }
+
+ /* lookup for glyph name in the main database */
+ tmp.name = (char *)s; /* this is okay since we're not calling
+ destroy_glyph_unicode_entry on this */
tmp.code = UNI_UNDEF;
ptmp = (glyph_unicode_entry *) avl_find(glyph_unicode_tree, &tmp);
if (ptmp != NULL) {
@@ -265,14 +286,14 @@ static void set_glyph_unicode(char *s, glyph_unicode_entry * gp)
/* check for case of "uniXXXX" (multiple 4-hex-digit values allowed) */
if (str_prefix(s, "uni")) {
- p = s + strlen("uni");
- code = check_unicode_value(p, true);
+ p2 = s + strlen("uni");
+ code = check_unicode_value(p2, true);
if (code != UNI_UNDEF) {
- if (strlen(p) == 4) /* single value */
+ if (strlen(p2) == 4) /* single value */
gp->code = code;
else { /* multiple value */
gp->code = UNI_EXTRA_STRING;
- gp->unicode_seq = xstrdup(p);
+ gp->unicode_seq = xstrdup(p2);
}
}
return; /* since the last case cannot happen */
@@ -280,8 +301,8 @@ static void set_glyph_unicode(char *s, glyph_unicode_entry * gp)
/* check for case of "uXXXX" (single value up to 6 hex digits) */
if (str_prefix(s, "u")) {
- p = s + strlen("u");
- code = check_unicode_value(p, false);
+ p2 = s + strlen("u");
+ code = check_unicode_value(p2, false);
if (code != UNI_UNDEF) {
assert(code >= 0);
gp->code = code;
@@ -289,27 +310,41 @@ static void set_glyph_unicode(char *s, glyph_unicode_entry * gp)
}
}
-integer write_tounicode(char **glyph_names, char *name)
+
+/* tfmname is without .tfm extension, but encname ends in .enc; */
+integer write_tounicode(char **glyph_names, const char *tfmname,
+ const char* encname)
{
char buf[SMALL_BUF_SIZE], *p;
- static char builtin_suffix[] = "-builtin";
+ static char builtin_suffix[] = "builtin";
short range_size[257];
glyph_unicode_entry gtab[257];
integer objnum;
int i, j;
int bfchar_count, bfrange_count, subrange_count;
- assert(strlen(name) + strlen(builtin_suffix) < SMALL_BUF_SIZE);
+
if (glyph_unicode_tree == NULL) {
pdftex_warn("no GlyphToUnicode entry has been inserted yet!");
fixedgentounicode = 0;
return 0;
}
- strcpy(buf, name);
- if ((p = strrchr(buf, '.')) != NULL && strcmp(p, ".enc") == 0)
- *p = 0; /* strip ".enc" from encoding name */
- else
- strcat(buf, builtin_suffix); /* ".enc" not present, this is a builtin
- encoding so the name is eg "cmr10-builtin" */
+
+ /* build the name for this CMap as <tfmname>-<encname>; if encname is NULL
+ * then this is a builtin encoding so use instead builtin_suffix */
+ strcpy(buf, tfmname);
+ strcat(buf, "-");
+ if (encname) {
+ assert(strlen(tfmname) + strlen(encname) + 1 < SMALL_BUF_SIZE);
+ strcat(buf, encname);
+ if ((p = strrchr(buf, '.')) != NULL && strcmp(p, ".enc") == 0)
+ *p = 0; /* strip ".enc" from encoding name */
+ else /* some silly encoding file name not ending in enc; use as-is */
+ pdftex_warn("Dubious encoding file name: `%s'", encname);
+ } else { /* this is a builtin encoding, so name is e.g. "cmr10-builtin" */
+ assert(strlen(tfmname) + strlen(builtin_suffix) + 1 < SMALL_BUF_SIZE);
+ strcat(buf, builtin_suffix);
+ }
+
objnum = pdfnewobjnum();
pdfbegindict(objnum, 0);
pdfbeginstream();
@@ -336,7 +371,7 @@ integer write_tounicode(char **glyph_names, char *name)
/* set gtab */
for (i = 0; i < 256; ++i) {
gtab[i].code = UNI_UNDEF;
- set_glyph_unicode(glyph_names[i], &gtab[i]);
+ set_glyph_unicode(glyph_names[i], tfmname, &gtab[i]);
}
gtab[256].code = UNI_UNDEF;
diff --git a/Build/source/texk/web2c/pdftexdir/writefont.c b/Build/source/texk/web2c/pdftexdir/writefont.c
index 29fe0b7fb8a..30ed172bad0 100644
--- a/Build/source/texk/web2c/pdftexdir/writefont.c
+++ b/Build/source/texk/web2c/pdftexdir/writefont.c
@@ -531,11 +531,11 @@ void write_fontdictionary(fo_entry * fo)
if (fixedgentounicode > 0 && fo->fd != NULL) {
if (fo->fe != NULL) {
fo->tounicode_objnum =
- write_tounicode(fo->fe->glyph_names, fo->fe->name);
+ write_tounicode(fo->fe->glyph_names, fo->fm->tfm_name, fo->fe->name);
} else if (is_type1(fo->fm)) {
assert(fo->fd->builtin_glyph_names != NULL);
fo->tounicode_objnum =
- write_tounicode(fo->fd->builtin_glyph_names, fo->fm->tfm_name);
+ write_tounicode(fo->fd->builtin_glyph_names, fo->fm->tfm_name, NULL);
}
}