Apply Web2C TCX tables to native byte streams

This commit is contained in:
gloamxun committed 2026-11-28 09:55:09 +08:00
1 parent 3bb2330676
commit 509f229a52
13 files changed
+393 -38

No files matched your search

+17
View File
@@ -65,6 +65,7 @@ pub struct CompileRequest {
pub target: Target,
pub etex: bool,
pub input_profile: InputProfile,
pub translation_file: Option<PathBuf>,
pub time: JobTime,
pub limits: Limits,
pub resource_manifest: Option<PathBuf>,
@@ -164,6 +165,7 @@ impl CompileRequest {
target: Target::Shipouts,
etex: false,
input_profile: InputProfile::TeX8Bit,
translation_file: None,
time,
limits: Limits::default(),
resource_manifest: None,
@@ -336,6 +338,8 @@ pub struct AttemptRequest {
pub target: Target,
pub etex: bool,
pub input_profile: InputProfile,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub translation_file: Option<PathBuf>,
pub time: JobTime,
pub limits: Limits,
pub resource_manifest: Option<PathBuf>,
@@ -358,6 +362,7 @@ impl From<&CompileRequest> for AttemptRequest {
target: r.target,
etex: r.etex,
input_profile: r.input_profile,
translation_file: r.translation_file.clone(),
time: r.time,
limits: r.limits,
resource_manifest: r.resource_manifest.clone(),
@@ -784,6 +789,14 @@ fn prepare_checked(
} else {
state
};
let translation = request.translation_file.as_ref().map(|name| {
if request.input_profile != InputProfile::TeX8Bit {
return Err("a TCX file requires the TeX 8-bit profile".to_owned());
}
let loaded = world.read_shared(ResourceKind::Tex, &name.to_string_lossy(), &path)?;
texrra_tex_core::execution::ByteTranslation::from_tcx(&loaded.data)
.map_err(|e| format!("TCX {}: {e}", loaded.version.path.display()))
}).transpose()?;
let (executor, format_preparation) = if let Entry::Format(name) = &request.entry {
let loaded =
world.read_shared(ResourceKind::Tex, &name.display().to_string(), &path)?;
@@ -896,6 +909,10 @@ fn prepare_checked(
(kernel == KernelPreparation::Fresh).then(|| Executor::new(state, request.limits));
(executor, None)
};
let executor = match (executor, translation) {
(Some(executor), Some(table)) => Some(executor.with_byte_translation(table)),
(executor, _) => executor,
};
check(cancellation)?;
Ok((path, source, executor, output, format_preparation))
})();