pdftex[952]
commits+thanh at tug.org
commits+thanh at tug.org
Sun Feb 16 21:03:17 CET 2025
Revision: 952
https://tug.org/svn/pdftex?view=revision&revision=952
Author: thanh
Date: 2025-02-16 21:03:16 +0100 (Sun, 16 Feb 2025)
Log Message:
-----------
update: missing space chars at font switches
Modified Paths:
--------------
branches/stable/source/src/texk/web2c/pdftexdir/pdftex.web
Modified: branches/stable/source/src/texk/web2c/pdftexdir/pdftex.web
===================================================================
--- branches/stable/source/src/texk/web2c/pdftexdir/pdftex.web 2025-02-15 16:07:47 UTC (rev 951)
+++ branches/stable/source/src/texk/web2c/pdftexdir/pdftex.web 2025-02-16 20:03:16 UTC (rev 952)
@@ -15991,6 +15991,7 @@
@!pdf_draftmode_value: integer;
@!pdf_cur_Tm_a: integer; {|a| value of the current text matrix, i.e., the current
horizontal scaling factor}
+@!pdf_last_f: internal_font_number; {last font in PDF output page; this can differ from |pdf_f|}
@!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}
@@ -16042,17 +16043,21 @@
end;
end;
-procedure pdf_set_textmatrix(v, v_out: scaled; f: internal_font_number);
-{set the next starting point to |cur_h|, |cur_v|}
+function get_font_auto_expand_ratio(f: internal_font_number): integer;
+{return |pdf_font_expand_ratio[f]| if f is auto-expanded, 0 otherwise}
+begin
+ if pdf_font_auto_expand[f] then
+ get_font_auto_expand_ratio := pdf_font_expand_ratio[f]
+ else
+ get_font_auto_expand_ratio := 0;
+end;
+
+procedure pdf_set_text_pos(v, v_out: scaled; f: internal_font_number);
+{set the next starting point for text to |cur_h|, |cur_v|}
var pdf_new_Tm_a: integer; {|a| value of the new text matrix}
begin
pdf_out(" ");
- if f = pdf_f then
- pdf_new_Tm_a := pdf_cur_Tm_a
- else if not pdf_font_auto_expand[f] then
- pdf_new_Tm_a := 0
- else
- pdf_new_Tm_a := pdf_font_expand_ratio[f];
+ pdf_new_Tm_a := get_font_auto_expand_ratio(f);
if (pdf_new_Tm_a <> 0) or
((pdf_new_Tm_a = 0) and (pdf_cur_Tm_a <> 0)) then begin
pdf_print_real(1000 + pdf_new_Tm_a, 3);
@@ -16161,6 +16166,7 @@
var p: pointer;
k: internal_font_number;
begin
+ pdf_f := f;
if not font_used[f] then
pdf_init_font(f);
set_ff(f); {set |ff| to the tfm number of the font sharing the font object
@@ -16176,7 +16182,7 @@
end;
pdf_append_list(f)(pdf_font_list); {|f| not found in |pdf_font_list|, append it now}
found:
- if (k = pdf_f) and (font_size[f] = pdf_last_fs) then
+ if (k = pdf_last_f) and (font_size[f] = pdf_last_fs) then
return;
pdf_print("/F");
pdf_print_int(k);
@@ -16184,7 +16190,7 @@
pdf_out(" ");
pdf_print_real(divide_scaled(font_size[f], one_hundred_bp, 6), 4);
pdf_print(" Tf");
- pdf_f := k;
+ pdf_last_f := k;
pdf_last_fs := font_size[f];
end;
@@ -16194,6 +16200,7 @@
pdf_print_ln("BT");
pdf_doing_text := true;
pdf_f := null_font;
+ pdf_last_f := null_font;
pdf_last_fs := 0;
pdf_doing_string := false;
pdf_cur_Tm_a := 0;
@@ -16222,13 +16229,18 @@
s: integer;
must_end_string: boolean; {must we end the current string?}
must_insert_space: boolean; {must we insert an interword space?}
- move_by_tm: boolean; {movement must be set using Tm operator}
+ must_set_text_pos: boolean; {move must be set using Tm or Td operator}
+ move_looks_like_interword_space: boolean; {move could be a space}
+begin
+ must_insert_space := false;
+ must_end_string := false;
-begin
if not pdf_doing_text then
pdf_begin_text;
- if (not gen_faked_interword_space and pdf_f <> f)
- or (gen_faked_interword_space and not (font_used[f] and font_used[pdf_f]))
+
+ {delay font switch if we must insert interword space}
+ if (not gen_faked_interword_space and pdf_f <> f)
+ or (gen_faked_interword_space and not (font_used[f] and font_used[pdf_f]))
then begin
pdf_end_string;
pdf_set_font(f);
@@ -16261,17 +16273,21 @@
v_out := 0;
end;
- must_insert_space := false;
- must_end_string := false;
- move_by_tm := (v <> 0) or (abs(s) >= @'100000);
-
- if move_by_tm then begin
+ must_set_text_pos := (v <> 0)
+ or (abs(s) >= @'100000)
+ or (get_font_auto_expand_ratio(f) <> pdf_cur_Tm_a)
+ or get_font_auto_expand_ratio(f) <> get_font_auto_expand_ratio(pdf_f);
+ if must_set_text_pos then begin
must_end_string := true;
end;
+ move_looks_like_interword_space := (space(f) > one_bp)
+ and (s_out > space(f) - space_shrink(f) - one_bp div 10)
+ and (v = 0);
+
if gen_faked_interword_space
- and (not move_by_tm)
- and (s_out > space(f) - space_shrink(f) - 65536)
+ and move_looks_like_interword_space
+ and (not must_set_text_pos)
then begin
must_insert_space := true;
end;
@@ -16294,13 +16310,19 @@
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);
+ pdf_insert_interword_space; {this will change the current font}
end;
- pdf_set_textmatrix(v, v_out, f);
+ pdf_set_font(f);
+ pdf_set_text_pos(v, v_out, f);
s := 0;
end;
+ {do font switch here after interword space could have been inserted}
+ if gen_faked_interword_space and (pdf_f <> f) then begin
+ pdf_end_string;
+ pdf_set_font(f);
+ end;
+
if not pdf_doing_string then begin
pdf_print(" [");
if s = 0 then
@@ -27663,7 +27685,7 @@
("shrinkable glue, e.g., `\vss' or `\vskip 0pt minus 1fil'.")@/
("Such glue doesn't belong there; but you can safely proceed,")@/
("since the offensive shrinkability has been made finite.");
- error;
+ error;
end;
r:=new_spec(q); shrink_order(r):=normal; delete_glue_ref(q);
glue_ptr(p):=r; q:=r;
More information about the pdftex-commits
mailing list.