summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/pdftexdir
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-02-12 22:48:31 +0000
committerKarl Berry <karl@freefriends.org>2023-02-12 22:48:31 +0000
commit634a13fc4ef5429b15e523b444dc24d33e6e8a52 (patch)
tree7f159d76c935fe9000db7fdd88fd267ce11bf8dc /Build/source/texk/web2c/pdftexdir
parent4dea12a2bd6d7b14874b9f8f24c4cc2c93e29a0b (diff)
new procedure for finding the fake space used with \pdfinterwordspaceon and \pdffakespace (pdftex r893)
git-svn-id: svn://tug.org/texlive/trunk@65805 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/pdftexdir')
-rw-r--r--Build/source/texk/web2c/pdftexdir/ChangeLog20
-rw-r--r--Build/source/texk/web2c/pdftexdir/NEWS10
-rw-r--r--Build/source/texk/web2c/pdftexdir/mapfile.c23
-rw-r--r--Build/source/texk/web2c/pdftexdir/pdftex.ch4
-rw-r--r--Build/source/texk/web2c/pdftexdir/pdftex.defines2
-rw-r--r--Build/source/texk/web2c/pdftexdir/pdftex.web52
-rw-r--r--Build/source/texk/web2c/pdftexdir/ptexlib.h2
7 files changed, 97 insertions, 16 deletions
diff --git a/Build/source/texk/web2c/pdftexdir/ChangeLog b/Build/source/texk/web2c/pdftexdir/ChangeLog
index 26e28f1ef9c..937e5894ef0 100644
--- a/Build/source/texk/web2c/pdftexdir/ChangeLog
+++ b/Build/source/texk/web2c/pdftexdir/ChangeLog
@@ -1,3 +1,23 @@
+2023-02-11 Thanh Han The <hanthethanh@gmail.com>
+
+ * pdftex.ch (pdf_font_has_space_char): xmalloc and maintain new array.
+ * pdftex.web (pdf_init_font): update pdf_font_has_space_char array.
+ (pdf_read_dummy_font): use pdf_space_font_name instead of
+ hardwired "dummy-space".
+ (pdf_begin_string): use real space char if pdf_font_has_space_char,
+ else call pdf_insert_interword_space.
+ (pdf_space_font_code): new \pdfspacefont primitive.
+ (Put each ...): define it.
+ (Cases of |print_cmd_chr|...): print it.
+ (Declare act...): switch on it.
+ (Implement \.{\\pdfspacefont}): implement it.
+ (Glob...): declare pdf_space_font_name.
+ (Set init...): initialize it.
+ * pdftex.defines,
+ * ptexlib.h,
+ * mapfile.c (hasspacechar, pdfmaplinesp): new fns.
+ * NEWS: mention new behavior.
+
2021-02-17 Karl Berry <karl@tug.org>
* NEWS,
diff --git a/Build/source/texk/web2c/pdftexdir/NEWS b/Build/source/texk/web2c/pdftexdir/NEWS
index 894113bf3c4..51dd3a08a16 100644
--- a/Build/source/texk/web2c/pdftexdir/NEWS
+++ b/Build/source/texk/web2c/pdftexdir/NEWS
@@ -3,9 +3,17 @@ pdfTeX 3.141592653-2.6-1.40.25
- new keyword `shipout' for \special and \pdfliteral, delaying
expansion until the node is shipped out, like non-\immediate \write.
- new primitive \pdfinfoomitdict to omit /Info dictionary completely.
- - new primitive \pdfomitprocset to control omitting /ProcSet array;
+ - new primitive \pdfomitprocset to control omitting /ProcSet array:
/ProcSet is included if this parameter is negative, or if this
parameter is zero and pdftex is generating PDF 1.x output.
+ - with \pdfinterwordspaceon, if the current font's encoding has a /space
+ character at slot 32, it is used; otherwise, the /space from the
+ (new) default font "pdftexspace" is used. That default font can be
+ overridden with the new primitive \pdfspacefont. This same new
+ procedure is used for \pdffakespace.
+ (In the past, the inserted fake space was always taken from the font
+ "dummy-space", which contained a tiny space character. It turns out
+ a normally-sized space character works with more viewers.)
- bugfixes:
- finish omission of /Info dict when \pdfomitinfodict is not 0.
diff --git a/Build/source/texk/web2c/pdftexdir/mapfile.c b/Build/source/texk/web2c/pdftexdir/mapfile.c
index fa153bcb60a..f97cb57ef76 100644
--- a/Build/source/texk/web2c/pdftexdir/mapfile.c
+++ b/Build/source/texk/web2c/pdftexdir/mapfile.c
@@ -659,6 +659,24 @@ boolean isscalable(internalfontnumber f)
return hasfmentry(f) && (!is_pk((fm_entry *)pdffontmap[f]));
}
+boolean hasspacechar(internalfontnumber f)
+{
+ if (!isscalable(f))
+ return false;
+
+ fm_entry *fm = (fm_entry *)pdffontmap[f];
+ fe_entry *fe;
+
+ /* if a font is not re-encoded via its map entry, we assume it has no space char */
+ if (is_reencoded(fm) && (fe = get_fe_entry(fm->encname)) != NULL) {
+ char *s = fe->glyph_names[32];
+ assert(s != NULL);
+ if (strcmp(s, "space") == 0)
+ return true;
+ }
+ return false;
+}
+
/* check whether a map entry is valid for font replacement */
static boolean fm_valid_for_font_replacement(fm_entry * fm)
@@ -839,6 +857,11 @@ void pdfmapline(integer t)
flushstr(lasttokensstring);
}
+void pdfmaplinesp(void)
+{
+ process_map_item("=pdftexspace PdfTeX-Space <pdftexspace.pfb", MAPLINE);
+}
+
void pdfinitmapfile(const_string map_name)
{
assert(mitem == NULL);
diff --git a/Build/source/texk/web2c/pdftexdir/pdftex.ch b/Build/source/texk/web2c/pdftexdir/pdftex.ch
index 02346f324ac..7685a44c948 100644
--- a/Build/source/texk/web2c/pdftexdir/pdftex.ch
+++ b/Build/source/texk/web2c/pdftexdir/pdftex.ch
@@ -179,6 +179,7 @@ pdf_font_type:=xmalloc_array(eight_bits, font_max);
pdf_font_attr:=xmalloc_array(str_number, font_max);
pdf_font_blink:=xmalloc_array(internal_font_number, font_max);
pdf_font_elink:=xmalloc_array(internal_font_number, font_max);
+pdf_font_has_space_char:=xmalloc_array(internal_font_number, font_max);
pdf_font_stretch:=xmalloc_array(integer, font_max);
pdf_font_shrink:=xmalloc_array(integer, font_max);
pdf_font_step:=xmalloc_array(integer, font_max);
@@ -209,6 +210,7 @@ for font_k := font_base to font_max do begin
pdf_font_attr[font_k] := "";
pdf_font_blink[font_k] := null_font;
pdf_font_elink[font_k] := null_font;
+ pdf_font_has_space_char[font_k] := false;
pdf_font_stretch[font_k] := null_font;
pdf_font_shrink[font_k] := null_font;
pdf_font_step[font_k] := 0;
@@ -296,6 +298,7 @@ pdf_font_type:=xmalloc_array(eight_bits,font_max);
pdf_font_attr:=xmalloc_array(str_number,font_max);
pdf_font_blink:=xmalloc_array(internal_font_number,font_max);
pdf_font_elink:=xmalloc_array(internal_font_number,font_max);
+pdf_font_has_space_char:=xmalloc_array(internal_font_number,font_max);
pdf_font_stretch:=xmalloc_array(integer,font_max);
pdf_font_shrink:=xmalloc_array(integer,font_max);
pdf_font_step:=xmalloc_array(integer,font_max);
@@ -326,6 +329,7 @@ for font_k := font_base to font_max do begin
pdf_font_attr[font_k] := "";
pdf_font_blink[font_k] := null_font;
pdf_font_elink[font_k] := null_font;
+ pdf_font_has_space_char[font_k] := false;
pdf_font_stretch[font_k] := null_font;
pdf_font_shrink[font_k] := null_font;
pdf_font_step[font_k] := 0;
diff --git a/Build/source/texk/web2c/pdftexdir/pdftex.defines b/Build/source/texk/web2c/pdftexdir/pdftex.defines
index ae42355c27e..22f47466de7 100644
--- a/Build/source/texk/web2c/pdftexdir/pdftex.defines
+++ b/Build/source/texk/web2c/pdftexdir/pdftex.defines
@@ -39,9 +39,11 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
{ functions from mapfile.c }
@define function hasfmentry();
@define function isscalable();
+@define function hasspacechar();
@define procedure checkextfm();
@define procedure pdfmapfile();
@define procedure pdfmapline();
+@define procedure pdfmaplinesp;
@define procedure pdfinitmapfile();
{ functions from utils.c }
diff --git a/Build/source/texk/web2c/pdftexdir/pdftex.web b/Build/source/texk/web2c/pdftexdir/pdftex.web
index b92e7564a17..b4d251953df 100644
--- a/Build/source/texk/web2c/pdftexdir/pdftex.web
+++ b/Build/source/texk/web2c/pdftexdir/pdftex.web
@@ -15225,11 +15225,6 @@ begin
get_slant := slant(f);
end;
-function new_dummy_font: internal_font_number;
-begin
- new_dummy_font := read_font_info(null_cs, "dummy", "", -1000);
-end;
-
@ Helper for debugging purposes:
@p procedure short_display_n(@!p, m:integer); {prints highlights of list |p|}
@@ -15973,7 +15968,6 @@ DVI}
@!pdf_last_fs: internal_font_number; {last font size in PDF output page}
@!pdf_dummy_font: internal_font_number; {font used to insert artificial interword spaces}
-
@ Following procedures implement low-level subroutines to convert \TeX{}
internal structures to PDF page description.
@@ -16126,6 +16120,7 @@ begin
{create a new font object for |f|}
pdf_create_obj(obj_type_font, f);
+ pdf_font_has_space_char[f] := hasspacechar(f);
pdf_use_font(f, obj_ptr);
end;
@@ -16182,7 +16177,8 @@ end;
procedure pdf_read_dummy_font;
begin
if pdf_dummy_font = null_font then begin
- pdf_dummy_font := read_font_info(null_cs, "dummy-space", "", one_bp);
+ pdf_dummy_font := read_font_info(null_cs, pdf_space_font_name, "", -1000);
+ pdfmaplinesp;
pdf_mark_char(pdf_dummy_font, 32);
end;
end;
@@ -16253,17 +16249,26 @@ begin
end;
if (must_insert_space) then begin
- pdf_out(" ");
- save_pdf_delta_h := pdf_delta_h;
- adv_char_width(f, 32, 3); { to get |adv_char_width_s| and |adv_char_width_s_out|}
- pdf_delta_h := save_pdf_delta_h;
- s := s - adv_char_width_s;
- s_out := s_out - adv_char_width_s_out;
- cur_h := cur_h - char_width(f)(char_info(f)(32));
+ {insert a real space char from the font when possible}
+ if pdf_font_has_space_char[f] then begin
+ pdf_out(" ");
+ save_pdf_delta_h := pdf_delta_h;
+ adv_char_width(f, 32, 3); { to get |adv_char_width_s| and |adv_char_width_s_out|}
+ s := s - adv_char_width_s;
+ s_out := s_out - adv_char_width_s_out;
+ pdf_mark_char(f, 32);
+ end
+ else
+ must_end_string := true;
end;
if must_end_string then begin
pdf_end_string;
+ {insert a space char from the dummy font if needed}
+ if (must_insert_space) and (not pdf_font_has_space_char[f]) then begin
+ pdf_insert_interword_space; {this will change |pdf_f|}
+ pdf_set_font(f);
+ end;
pdf_set_textmatrix(v, v_out, f);
pdf_f := f;
s := 0;
@@ -20516,6 +20521,7 @@ location |adjust_tail|.
@ @<Glob...@>=
@!pdf_font_blink: ^internal_font_number; {link to base font (used for expanded fonts only)}
@!pdf_font_elink: ^internal_font_number; {link to expanded fonts (used for base fonts only)}
+@!pdf_font_has_space_char: ^boolean; {has font a real space char?}
@!pdf_font_stretch: ^integer; {link to font expanded by stretch limi}
@!pdf_font_shrink: ^integer; {link to font expanded by shrink limit}
@!pdf_font_step: ^integer; {amount of one step of expansion}
@@ -33720,7 +33726,8 @@ stays the same.
@d pdf_fake_space_node == pdftex_first_extension_code + 40
@d pdf_running_link_off_node == pdftex_first_extension_code + 41
@d pdf_running_link_on_node == pdftex_first_extension_code + 42
-@d pdftex_last_extension_code == pdftex_first_extension_code + 42
+@d pdf_space_font_code == pdftex_first_extension_code + 43
+@d pdftex_last_extension_code == pdftex_first_extension_code + 43
@<Put each...@>=
primitive("openout",extension,open_node);@/
@@ -33819,6 +33826,8 @@ primitive("pdfrunninglinkoff",extension,pdf_running_link_off_node);@/
@!@:pdf_running_link_off_}{\.{\\pdfrunninglinkoff} primitive@>
primitive("pdfrunninglinkon",extension,pdf_running_link_on_node);@/
@!@:pdf_running_link_on_}{\.{\\pdfrunninglinkon} primitive@>
+primitive("pdfspacefont",extension,pdf_space_font_code);@/
+@!@:pdf_space_font_}{\.{\\pdfspacefont} primitive@>
@ The variable |write_loc| just introduced is used to provide an
appropriate error message in case of ``runaway'' write texts.
@@ -33876,6 +33885,7 @@ extension: case chr_code of
pdf_fake_space_node: print_esc("pdffakespace");
pdf_running_link_off_node: print_esc("pdfrunninglinkoff");
pdf_running_link_on_node: print_esc("pdfrunninglinkon");
+ pdf_space_font_code: print_esc("pdfspacefont");
othercases print("[unknown extension!]")
endcases;
@@ -33939,6 +33949,7 @@ begin case cur_chr of
pdf_fake_space_node: @<Implement \.{\\pdffakespace}@>;
pdf_running_link_off_node: @<Implement \.{\\pdfrunninglinkoff}@>;
pdf_running_link_on_node: @<Implement \.{\\pdfrunninglinkon}@>;
+ pdf_space_font_code: @<Implement \.{\\pdfspacefont}@>;
othercases confusion("ext1")
@:this can't happen ext1}{\quad ext1@>
endcases;
@@ -35323,6 +35334,14 @@ begin
new_whatsit(pdf_running_link_on_node, small_node_size);
end
+@ @<Implement \.{\\pdfspacefont}@>=
+begin
+ check_pdfoutput("\pdfspacefont", true);
+ scan_pdf_ext_toks;
+ pdf_space_font_name := tokens_to_string(def_ref);
+ delete_token_ref(def_ref);
+end
+
@ The following function are needed for outputting article thread.
@<Declare procedures needed in |do_ext...@>=
@@ -36182,6 +36201,7 @@ thread}
@!pdf_trailer_id_toks: pointer; {custom Trailer ID}
@!gen_faked_interword_space: boolean; {flag to turn on/off faked interword spaces}
@!gen_running_link: boolean; {flag to turn on/off running link}
+@!pdf_space_font_name: str_number; {name of font used for inter-word space in PDF output}
@ @<Set init...@>=
pdf_first_outline:= 0;
@@ -36199,6 +36219,8 @@ pdf_trailer_toks := null;
pdf_trailer_id_toks := null;
gen_faked_interword_space := false;
gen_running_link := true;
+pdf_space_font_name := "pdftexspace";
+
@ The following procedures are needed for outputting whatsit nodes for
\pdfTeX{}.
diff --git a/Build/source/texk/web2c/pdftexdir/ptexlib.h b/Build/source/texk/web2c/pdftexdir/ptexlib.h
index 4a58e21118e..61d61024bad 100644
--- a/Build/source/texk/web2c/pdftexdir/ptexlib.h
+++ b/Build/source/texk/web2c/pdftexdir/ptexlib.h
@@ -180,11 +180,13 @@ extern const char *ptexbanner;
/* mapfile.c */
extern boolean hasfmentry(internalfontnumber);
extern boolean isscalable(internalfontnumber);
+extern boolean hasspacechar(internalfontnumber);
extern void fm_free(void);
extern void fm_read_info(void);
extern ff_entry *check_ff_exist(char *, boolean);
extern void pdfmapfile(integer);
extern void pdfmapline(integer);
+extern void pdfmaplinesp(void);
extern void pdfinitmapfile(const_string map_name);
extern fm_entry *new_fm_entry(void);
extern void delete_fm_entry(fm_entry *);