Skip to content

Commit 0b97440

Browse files
committed
fixes from thanh for pdftex font woes, from pdftex r953
git-svn-id: svn://tug.org/texlive/trunk/Build/source@74048 c570f23f-e606-0410-a88d-b1316a301751
1 parent df1039c commit 0b97440

File tree

2 files changed

+56
-25
lines changed

2 files changed

+56
-25
lines changed

texk/web2c/pdftexdir/ChangeLog

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2025-02-16 Thanh Han The <[email protected]>
2+
3+
* pdftex.web: fixes for previous change to add missing interword
4+
spaces at font switches, following reports:
5+
https://tug.org/pipermail/pdftex/2025-February/009443.html
6+
https://tug.org/pipermail/tex-live/2025-February/051136.html
7+
https://tug.org/pipermail/tex-live/2025-February/051139.html
8+
Copied from pdftex r953.
9+
110
2025-02-11 Max Chernoff <[email protected]>
211

312
* pdftex.web (scale_image): no warning if both resolutions are zero.

texk/web2c/pdftexdir/pdftex.web

+47-25
Original file line numberDiff line numberDiff line change
@@ -15991,6 +15991,7 @@ DVI}
1599115991
@!pdf_draftmode_value: integer;
1599215992
@!pdf_cur_Tm_a: integer; {|a| value of the current text matrix, i.e., the current
1599315993
horizontal scaling factor}
15994+
@!pdf_last_f: internal_font_number; {last font in PDF output page; this can differ from |pdf_f|}
1599415995
@!pdf_last_fs: internal_font_number; {last font size in PDF output page}
1599515996
@!pdf_dummy_font: internal_font_number; {font used to insert artificial interword spaces}
1599615997

@@ -16042,17 +16043,21 @@ begin
1604216043
end;
1604316044
end;
1604416045

16045-
procedure pdf_set_textmatrix(v, v_out: scaled; f: internal_font_number);
16046-
{set the next starting point to |cur_h|, |cur_v|}
16046+
function get_font_auto_expand_ratio(f: internal_font_number): integer;
16047+
{return |pdf_font_expand_ratio[f]| if f is auto-expanded, 0 otherwise}
16048+
begin
16049+
if pdf_font_auto_expand[f] then
16050+
get_font_auto_expand_ratio := pdf_font_expand_ratio[f]
16051+
else
16052+
get_font_auto_expand_ratio := 0;
16053+
end;
16054+
16055+
procedure pdf_set_text_pos(v, v_out: scaled; f: internal_font_number);
16056+
{set the next starting point for text to |cur_h|, |cur_v|}
1604716057
var pdf_new_Tm_a: integer; {|a| value of the new text matrix}
1604816058
begin
1604916059
pdf_out(" ");
16050-
if f = pdf_f then
16051-
pdf_new_Tm_a := pdf_cur_Tm_a
16052-
else if not pdf_font_auto_expand[f] then
16053-
pdf_new_Tm_a := 0
16054-
else
16055-
pdf_new_Tm_a := pdf_font_expand_ratio[f];
16060+
pdf_new_Tm_a := get_font_auto_expand_ratio(f);
1605616061
if (pdf_new_Tm_a <> 0) or
1605716062
((pdf_new_Tm_a = 0) and (pdf_cur_Tm_a <> 0)) then begin
1605816063
pdf_print_real(1000 + pdf_new_Tm_a, 3);
@@ -16161,6 +16166,7 @@ label found, found1;
1616116166
var p: pointer;
1616216167
k: internal_font_number;
1616316168
begin
16169+
pdf_f := f;
1616416170
if not font_used[f] then
1616516171
pdf_init_font(f);
1616616172
set_ff(f); {set |ff| to the tfm number of the font sharing the font object
@@ -16176,15 +16182,15 @@ begin
1617616182
end;
1617716183
pdf_append_list(f)(pdf_font_list); {|f| not found in |pdf_font_list|, append it now}
1617816184
found:
16179-
if (k = pdf_f) and (font_size[f] = pdf_last_fs) then
16185+
if (k = pdf_last_f) and (font_size[f] = pdf_last_fs) then
1618016186
return;
1618116187
pdf_print("/F");
1618216188
pdf_print_int(k);
1618316189
pdf_print_resname_prefix;
1618416190
pdf_out(" ");
1618516191
pdf_print_real(divide_scaled(font_size[f], one_hundred_bp, 6), 4);
1618616192
pdf_print(" Tf");
16187-
pdf_f := k;
16193+
pdf_last_f := k;
1618816194
pdf_last_fs := font_size[f];
1618916195
end;
1619016196

@@ -16194,6 +16200,7 @@ begin
1619416200
pdf_print_ln("BT");
1619516201
pdf_doing_text := true;
1619616202
pdf_f := null_font;
16203+
pdf_last_f := null_font;
1619716204
pdf_last_fs := 0;
1619816205
pdf_doing_string := false;
1619916206
pdf_cur_Tm_a := 0;
@@ -16222,13 +16229,18 @@ var s_out, v, v_out: scaled;
1622216229
s: integer;
1622316230
must_end_string: boolean; {must we end the current string?}
1622416231
must_insert_space: boolean; {must we insert an interword space?}
16225-
move_by_tm: boolean; {movement must be set using Tm operator}
16226-
16232+
must_set_text_pos: boolean; {move must be set using Tm or Td operator}
16233+
move_looks_like_interword_space: boolean; {move could be a space}
1622716234
begin
16235+
must_insert_space := false;
16236+
must_end_string := false;
16237+
1622816238
if not pdf_doing_text then
1622916239
pdf_begin_text;
16230-
if (not gen_faked_interword_space and pdf_f <> f)
16231-
or (gen_faked_interword_space and not (font_used[f] and font_used[pdf_f]))
16240+
16241+
{delay font switch if we must insert interword space}
16242+
if (not gen_faked_interword_space and pdf_f <> f)
16243+
or (gen_faked_interword_space and not (font_used[f] and font_used[pdf_f]))
1623216244
then begin
1623316245
pdf_end_string;
1623416246
pdf_set_font(f);
@@ -16261,17 +16273,21 @@ begin
1626116273
v_out := 0;
1626216274
end;
1626316275

16264-
must_insert_space := false;
16265-
must_end_string := false;
16266-
move_by_tm := (v <> 0) or (abs(s) >= @'100000);
16267-
16268-
if move_by_tm then begin
16276+
must_set_text_pos := (v <> 0)
16277+
or (abs(s) >= @'100000)
16278+
or (get_font_auto_expand_ratio(f) <> pdf_cur_Tm_a)
16279+
or get_font_auto_expand_ratio(f) <> get_font_auto_expand_ratio(pdf_f);
16280+
if must_set_text_pos then begin
1626916281
must_end_string := true;
1627016282
end;
1627116283

16284+
move_looks_like_interword_space := (space(f) > one_bp)
16285+
and (s_out > space(f) - space_shrink(f) - one_bp div 10)
16286+
and (v = 0);
16287+
1627216288
if gen_faked_interword_space
16273-
and (not move_by_tm)
16274-
and (s_out > space(f) - space_shrink(f) - 65536)
16289+
and move_looks_like_interword_space
16290+
and (not must_set_text_pos)
1627516291
then begin
1627616292
must_insert_space := true;
1627716293
end;
@@ -16294,13 +16310,19 @@ begin
1629416310
pdf_end_string;
1629516311
{insert a space char from the dummy font if needed}
1629616312
if (must_insert_space) and (not pdf_font_has_space_char[f]) then begin
16297-
pdf_insert_interword_space; {this will change |pdf_f|}
16298-
pdf_set_font(f);
16313+
pdf_insert_interword_space; {this will change the current font}
1629916314
end;
16300-
pdf_set_textmatrix(v, v_out, f);
16315+
pdf_set_font(f);
16316+
pdf_set_text_pos(v, v_out, f);
1630116317
s := 0;
1630216318
end;
1630316319

16320+
{do font switch here after interword space could have been inserted}
16321+
if gen_faked_interword_space and (pdf_f <> f) then begin
16322+
pdf_end_string;
16323+
pdf_set_font(f);
16324+
end;
16325+
1630416326
if not pdf_doing_string then begin
1630516327
pdf_print(" [");
1630616328
if s = 0 then
@@ -27663,7 +27685,7 @@ else begin q:=glue_ptr(p);
2766327685
("shrinkable glue, e.g., `\vss' or `\vskip 0pt minus 1fil'.")@/
2766427686
("Such glue doesn't belong there; but you can safely proceed,")@/
2766527687
("since the offensive shrinkability has been made finite.");
27666-
error;
27688+
error;
2766727689
end;
2766827690
r:=new_spec(q); shrink_order(r):=normal; delete_glue_ref(q);
2766927691
glue_ptr(p):=r; q:=r;

0 commit comments

Comments
 (0)