texlive[65805] Build/source/texk/web2c/pdftexdir: new procedure for

commits+karl at tug.org commits+karl at tug.org
Sun Feb 12 23:48:31 CET 2023


Revision: 65805
          http://tug.org/svn/texlive?view=revision&revision=65805
Author:   karl
Date:     2023-02-12 23:48:31 +0100 (Sun, 12 Feb 2023)
Log Message:
-----------
new procedure for finding the fake space used with \pdfinterwordspaceon and \pdffakespace (pdftex r893)

Revision Links:
--------------
    http://tug.org/svn/texlive?view=revision&revision=893

Modified Paths:
--------------
    trunk/Build/source/texk/web2c/pdftexdir/ChangeLog
    trunk/Build/source/texk/web2c/pdftexdir/NEWS
    trunk/Build/source/texk/web2c/pdftexdir/mapfile.c
    trunk/Build/source/texk/web2c/pdftexdir/pdftex.ch
    trunk/Build/source/texk/web2c/pdftexdir/pdftex.defines
    trunk/Build/source/texk/web2c/pdftexdir/pdftex.web
    trunk/Build/source/texk/web2c/pdftexdir/ptexlib.h

Modified: trunk/Build/source/texk/web2c/pdftexdir/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/ChangeLog	2023-02-12 22:25:13 UTC (rev 65804)
+++ trunk/Build/source/texk/web2c/pdftexdir/ChangeLog	2023-02-12 22:48:31 UTC (rev 65805)
@@ -1,3 +1,23 @@
+2023-02-11  Thanh Han The  <hanthethanh at 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 at tug.org>
 
         * NEWS,

Modified: trunk/Build/source/texk/web2c/pdftexdir/NEWS
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/NEWS	2023-02-12 22:25:13 UTC (rev 65804)
+++ trunk/Build/source/texk/web2c/pdftexdir/NEWS	2023-02-12 22:48:31 UTC (rev 65805)
@@ -3,9 +3,17 @@
   - 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.

Modified: trunk/Build/source/texk/web2c/pdftexdir/mapfile.c
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/mapfile.c	2023-02-12 22:25:13 UTC (rev 65804)
+++ trunk/Build/source/texk/web2c/pdftexdir/mapfile.c	2023-02-12 22:48:31 UTC (rev 65805)
@@ -659,6 +659,24 @@
     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 @@
     flushstr(lasttokensstring);
 }
 
+void pdfmaplinesp(void)
+{
+    process_map_item("=pdftexspace PdfTeX-Space <pdftexspace.pfb", MAPLINE);
+}
+
 void pdfinitmapfile(const_string map_name)
 {
     assert(mitem == NULL);

Modified: trunk/Build/source/texk/web2c/pdftexdir/pdftex.ch
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/pdftex.ch	2023-02-12 22:25:13 UTC (rev 65804)
+++ trunk/Build/source/texk/web2c/pdftexdir/pdftex.ch	2023-02-12 22:48:31 UTC (rev 65805)
@@ -179,6 +179,7 @@
 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 @@
     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_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 @@
     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;

Modified: trunk/Build/source/texk/web2c/pdftexdir/pdftex.defines
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/pdftex.defines	2023-02-12 22:25:13 UTC (rev 65804)
+++ trunk/Build/source/texk/web2c/pdftexdir/pdftex.defines	2023-02-12 22:48:31 UTC (rev 65805)
@@ -39,9 +39,11 @@
 { functions from mapfile.c }
 @define function hasfmentry();
 @define function isscalable();
+ at define function hasspacechar();
 @define procedure checkextfm();
 @define procedure pdfmapfile();
 @define procedure pdfmapline();
+ at define procedure pdfmaplinesp;
 @define procedure pdfinitmapfile();
 
 { functions from utils.c }

Modified: trunk/Build/source/texk/web2c/pdftexdir/pdftex.web
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/pdftex.web	2023-02-12 22:25:13 UTC (rev 65804)
+++ trunk/Build/source/texk/web2c/pdftexdir/pdftex.web	2023-02-12 22:48:31 UTC (rev 65805)
@@ -15225,11 +15225,6 @@
     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 @@
 @!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 @@
 
     {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 @@
 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 @@
     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 @@
 @ @<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 @@
 @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
- at d pdftex_last_extension_code  == pdftex_first_extension_code + 42
+ at d pdf_space_font_code         == pdftex_first_extension_code + 43
+ at d pdftex_last_extension_code  == pdftex_first_extension_code + 43
 
 @<Put each...@>=
 primitive("openout",extension,open_node);@/
@@ -33819,6 +33826,8 @@
 @!@: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 @@
   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 @@
   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 @@
     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 @@
 @!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,7 +36219,9 @@
 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{}.
 

Modified: trunk/Build/source/texk/web2c/pdftexdir/ptexlib.h
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/ptexlib.h	2023-02-12 22:25:13 UTC (rev 65804)
+++ trunk/Build/source/texk/web2c/pdftexdir/ptexlib.h	2023-02-12 22:48:31 UTC (rev 65805)
@@ -180,11 +180,13 @@
 /* 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 *);



More information about the tex-live-commits mailing list.