Skip to content

Commit e36e7d4

Browse files
authored
Merge pull request #955 from pkgw/html-no-crash
engine_spx2html: fix up behavior when compiling un-customized documents
2 parents ef76a2e + 462bb92 commit e36e7d4

1 file changed

Lines changed: 26 additions & 9 deletions

File tree

  • crates/engine_spx2html/src

crates/engine_spx2html/src/lib.rs

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,16 +1657,27 @@ impl EmittingState {
16571657
)
16581658
};
16591659

1660-
let cur_fam = self.font_families.get(&cur_ffid).unwrap();
1660+
let (path, desired_af) = if let Some(cur_fam) = self.font_families.get(&cur_ffid) {
1661+
// Already set up for the right font? If so, great!
1662+
if cur_fam.relative_id_to_font_num(cur_af) == fnum {
1663+
return;
1664+
}
16611665

1662-
// Already set up for the right font? If so, great!
1663-
if cur_fam.relative_id_to_font_num(cur_af) == fnum {
1664-
return;
1665-
}
1666+
// No. Figure out what we need to do.
1667+
let desired_af = cur_fam.font_num_to_relative_id(fnum);
1668+
(cur_fam.path_to_new_font(cur_af, desired_af), desired_af)
1669+
} else {
1670+
// We don't seem to be in a defined "family". So we have to
1671+
// select it explicitly.
1672+
let path = PathToNewFont {
1673+
close_all: true,
1674+
select_explicitly: true,
1675+
..Default::default()
1676+
};
16661677

1667-
// No. Figure out what we need to do.
1668-
let desired_af = cur_fam.font_num_to_relative_id(fnum);
1669-
let path = cur_fam.path_to_new_font(cur_af, desired_af);
1678+
let desired_af = FamilyRelativeFontId::Other(fnum);
1679+
(path, desired_af)
1680+
};
16701681

16711682
if path.close_one_and_retry {
16721683
if cur_is_autofont {
@@ -1969,7 +1980,13 @@ impl EmittingState {
19691980
}
19701981

19711982
// Read in the template. Let's not cache it, in case someone wants to do
1972-
// something fancy with rewriting it.
1983+
// something fancy with rewriting it. If that setting is empty, probably
1984+
// the user is compiling the document in HTML mode without all of the
1985+
// TeX infrastructure that Tectonic needs to make it work.
1986+
1987+
if self.next_template_path.is_empty() {
1988+
bail!("need to emit HTML content but no template has been specified; is your document HTML-compatible?");
1989+
}
19731990

19741991
let mut ih = atry!(
19751992
common.hooks.io().input_open_name(&self.next_template_path, common.status).must_exist();

0 commit comments

Comments
 (0)