Include unboxed inline math in pdfTeX font expansion
This commit is contained in:
1 parent
8cd0263b97
commit
0f10163b5b
4 files changed
+91
-8
No files matched your search
@@ -73,17 +73,21 @@ struct Character<'a> {
|
||||
}
|
||||
|
||||
fn character(node: &TextNode) -> Option<Character<'_>> {
|
||||
let TextNode::Glyph { font: id, glyph, slot, .. } = node else {
|
||||
return None;
|
||||
let (glyph, text_character) = match node {
|
||||
TextNode::Glyph { font, glyph, slot, .. } => (glyph, Some((*font, *slot))),
|
||||
// Inline math contributes its unboxed characters to the paragraph.
|
||||
TextNode::MathChar(glyph) => (glyph, None),
|
||||
_ => return None,
|
||||
};
|
||||
let geometry = glyph.math_geometry.as_ref()?;
|
||||
let MathItem::NativeGlyph { font, .. } = &geometry.items.first()?.item else {
|
||||
let MathItem::NativeGlyph { font, slot, .. } = &geometry.items.first()?.item else {
|
||||
return None;
|
||||
};
|
||||
let (id, slot) = text_character.unwrap_or((font.id, *slot));
|
||||
Some(Character {
|
||||
font,
|
||||
id: *id,
|
||||
slot: *slot,
|
||||
id,
|
||||
slot,
|
||||
width: glyph.width,
|
||||
})
|
||||
}
|
||||
@@ -445,10 +449,14 @@ pub(super) fn pack(
|
||||
let metrics = state.fonts.character(selected, glyph.slot)?
|
||||
.ok_or_else(|| format!("expanded font has no TFM slot {}", glyph.slot))?;
|
||||
let face = state.fonts.glyph_font(selected)?;
|
||||
let TextNode::Glyph { font, glyph, .. } = &mut material[i] else {
|
||||
unreachable!()
|
||||
let glyph = match &mut material[i] {
|
||||
TextNode::Glyph { font, glyph, .. } => {
|
||||
*font = selected;
|
||||
glyph
|
||||
}
|
||||
TextNode::MathChar(glyph) => glyph,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
*font = selected;
|
||||
glyph.width = metrics.width;
|
||||
glyph.height = metrics.height;
|
||||
glyph.depth = metrics.depth;
|
||||
|
||||
@@ -461,6 +461,40 @@ fn font_expansion_codes_invalidate_cached_break_geometry() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn font_expansion_uses_unboxed_inline_math() {
|
||||
let source = r"\catcode123=1 \catcode125=2 \catcode36=3
|
||||
\font\roman=cmr10 \roman
|
||||
\textfont0=\roman \scriptfont0=\roman \scriptscriptfont0=\roman
|
||||
\font\symbol=cmsy10
|
||||
\textfont2=\symbol \scriptfont2=\symbol \scriptscriptfont2=\symbol
|
||||
\font\extension=cmex10
|
||||
\textfont3=\extension \scriptfont3=\extension \scriptscriptfont3=\extension
|
||||
\mathcode65=65
|
||||
\pdfoutput=1 \pdffontexpand\roman 100 100 10 autoexpand
|
||||
\hsize=31pt \parfillskip=0pt plus1fil \rightskip=0pt plus1fil
|
||||
\pretolerance=100 \tolerance=200 \linepenalty=10 \baselineskip=12pt
|
||||
\showboxbreadth=99 \showboxdepth=99
|
||||
\setbox0=\vbox{\pdfadjustspacing=1 \noindent $AA$ $AA$\par}
|
||||
\setbox1=\vbox{\pdfadjustspacing=2 \noindent $AA$ $AA$\par}
|
||||
\setbox2=\vbox{\pdfadjustspacing=2 \noindent \hbox{$AA$} $AA$\par}
|
||||
\showbox0 \showbox1 \showbox2
|
||||
\end
|
||||
";
|
||||
let executed = execute(source, &mut Host::default()).unwrap();
|
||||
let lists = reports(&executed);
|
||||
assert_eq!(lists.len(), 3);
|
||||
for (report, (line_count, expanded_chars)) in lists.iter().zip([(2, 0), (1, 4), (2, 0)]) {
|
||||
assert_eq!(
|
||||
report.text.lines().filter(|line| line.starts_with(r".\hbox(")).count(),
|
||||
line_count,
|
||||
"{}",
|
||||
report.text
|
||||
);
|
||||
assert_eq!(report.text.matches(r"\roman (-80) A").count(), expanded_chars);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn autoexpand_assigns_font_numbers_and_shares_parameters() {
|
||||
let declaration = r"\catcode123=1 \catcode125=2
|
||||
|
||||
@@ -979,6 +979,27 @@ DVI 模式的原生出页几何、两种格式镜像和二十五项定向回归
|
||||
schema90 支持草稿参数持久化,schema89 镜像加载时恢复此原语。
|
||||
回执 SHA-256 为 0084b0d17763f7a9b6f5d6d6816334a40e9e1ff069428e3f8880866fb77a3396。
|
||||
|
||||
### 行内数学字符参与 pdfTeX 字宽伸缩
|
||||
|
||||
行内数学结束后,实际未装盒的传统字体字符进入段落水平列表。
|
||||
断行搜索和装盒用同一字符投影度量伸缩、登记真实字体档位并更新字形
|
||||
几何。已经装盒的数学保留自身几何,其内部字符不计入外层段落伸缩。
|
||||
真实 pdfTeX 对照覆盖伸缩档位、行数和装盒边界。四个未装盒的字符在
|
||||
模式 2 收缩到 92% 排成一行,模式 1 与装盒用例保留两行。
|
||||
三份原始列表、PDF 字形和 144 DPI 灰度像素与参考一致。
|
||||
十项诊断回归通过。
|
||||
[pdfTeX 的行内数学列表](https://github.com/TeX-Live/texlive-source/blob/fb6158926661cb7a7246b3a94a0cb170a9624d5a/texk/web2c/pdftexdir/pdftex.web#L31337-L31344)
|
||||
[pdfTeX 的断行字符容量](https://github.com/TeX-Live/texlive-source/blob/fb6158926661cb7a7246b3a94a0cb170a9624d5a/texk/web2c/pdftexdir/pdftex.web#L25583-L25596)
|
||||
|
||||
三页会话两次往返改子文件的 efcode。各恢复 1,184 步执行,
|
||||
只更新第 2 页。PDF 字节、测量页面、SVG 和来源映射与同修订的
|
||||
独立零复用全量一致。回执位于 target/p3-publisher-warm-nov27/math-expansion,
|
||||
minimal-audit.json 的 SHA-256 为
|
||||
b63c8e0789643785a4d72d61080ce4ef4d33f240a4ba385d0a01592605ddf80a,
|
||||
incremental-result.log 为
|
||||
54b4b0adc67f6debeeccddf62512cd7c6d3da8ad18bf681162e9baa6cf7fb304。
|
||||
[原样 ACM 双栏版面对照](PUBLISHER_TEMPLATE_MATRIX.md#acm-双栏的稳定版面与行内数学伸缩)
|
||||
|
||||
### PDF 预览按实际页面资源复用
|
||||
|
||||
编译会话的 SVG 缓存采用预览读取器解析出的页面、有效页框、旋转和资源。
|
||||
|
||||
@@ -1109,6 +1109,26 @@ ACM 的 acm/cold/second/reference-audit.json 为
|
||||
6217ad577d81306913f230898c086821602c4ffc353923bb24bc24240fdfae98。
|
||||
本轮范围是两项主线复验,统一矩阵仍待冻结后执行。
|
||||
|
||||
### ACM 双栏的稳定版面与行内数学伸缩
|
||||
|
||||
上次 f14669a 的作业在同一目录续编第三轮,aux 与冻结参考逐字节
|
||||
一致,原样项目第三页仍把网址字符排为原宽,参考为 98%。改用真实
|
||||
行内数学字符的伸缩能力后,第四轮继续读取实际第三轮辅助文件。
|
||||
44 份原始交付文件、schema51、冻结字体映射和既有原生 BibTeX
|
||||
产物身份保持。第四轮 aux 和 bbl 与第三轮及冻结参考逐字节一致。
|
||||
|
||||
七页的 31,040 个字形记录在提取精度内相同,4,780 个提取词、
|
||||
顺序和词框逐项相同。144 DPI 灰度差异从 162,281 个像素降为零。
|
||||
PDF 2.0 的结构树和父树均存在,121 个结构链接动作的目标、角色
|
||||
和视图类型仍与参考一致。双方的 Poppler 标记警告仍保留,
|
||||
完整可访问性与同版模板矩阵待统一验收。
|
||||
|
||||
前后证据在 target/p3-publisher-warm-nov27/acm/cold 的
|
||||
third/geometry-audit.json 和 fourth/geometry-audit.json,
|
||||
SHA-256 分别为 56b88af4953a46dc4e1ea29074149dfc1b7ddb538466e7f62250d27e6cef4453
|
||||
和 23fd7b4259cee9540c07f3a12a7f31d0b68c8e053706759626e59a693bff68f1。
|
||||
[行内数学原始列表与编辑会话对照](P2_M1_PROGRESS.md#行内数学字符参与-pdftex-字宽伸缩)
|
||||
|
||||
单纯生成 PDF 或 DVI 只说明编译路径可达。完整验收要在参考环境闭合后比较页数、
|
||||
双栏位置及跨栏材料、实际字体/字形、图表浮动、引用收敛、词框及墨迹;测试源
|
||||
与容差都不得为通过而替换。类 Typst 的编辑延迟另用同批原样项目分规模测量,
|
||||
|
||||
Reference in new issue
Block a user