Implement native text accents for unmodified LaTeX jobs
This commit is contained in:
1 parent
ca60c66a17
commit
4eeb5686b8
16 files changed
+269
-18
No files matched your search
@@ -332,6 +332,7 @@ impl NativeBox {
|
|||||||
}
|
}
|
||||||
TextNode::Indent(w)
|
TextNode::Indent(w)
|
||||||
| TextNode::MathBoundary { width: w, .. }
|
| TextNode::MathBoundary { width: w, .. }
|
||||||
|
| TextNode::AccentKern(w)
|
||||||
| TextNode::Kern { width: w, .. } => HorizontalItem::Box(HorizontalBox {
|
| TextNode::Kern { width: w, .. } => HorizontalItem::Box(HorizontalBox {
|
||||||
width: *w as i64,
|
width: *w as i64,
|
||||||
..HorizontalBox::default()
|
..HorizontalBox::default()
|
||||||
@@ -612,6 +613,7 @@ pub(super) fn hpack(
|
|||||||
}
|
}
|
||||||
TextNode::Indent(w)
|
TextNode::Indent(w)
|
||||||
| TextNode::MathBoundary { width: w, .. }
|
| TextNode::MathBoundary { width: w, .. }
|
||||||
|
| TextNode::AccentKern(w)
|
||||||
| TextNode::Kern { width: w, .. } => width += *w as i64,
|
| TextNode::Kern { width: w, .. } => width += *w as i64,
|
||||||
TextNode::Glue(g) | TextNode::NamedGlue(g, _) => {
|
TextNode::Glue(g) | TextNode::NamedGlue(g, _) => {
|
||||||
width += g.width as i64;
|
width += g.width as i64;
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ pub enum DiagnosticNode {
|
|||||||
},
|
},
|
||||||
Output(OutputNode),
|
Output(OutputNode),
|
||||||
Unsupported(String),
|
Unsupported(String),
|
||||||
|
AccentKern(i32),
|
||||||
}
|
}
|
||||||
/// A semantic view, without recursively copying the box's painted contents.
|
/// A semantic view, without recursively copying the box's painted contents.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
@@ -209,6 +210,7 @@ pub(super) fn text_nodes(nodes: &[TextNode]) -> Vec<DiagnosticNode> {
|
|||||||
name: None,
|
name: None,
|
||||||
},
|
},
|
||||||
TextNode::Leaders(leader) => leader_node(leader),
|
TextNode::Leaders(leader) => leader_node(leader),
|
||||||
|
TextNode::AccentKern(width) => DiagnosticNode::AccentKern(*width),
|
||||||
TextNode::Kern { width, explicit } => DiagnosticNode::Kern {
|
TextNode::Kern { width, explicit } => DiagnosticNode::Kern {
|
||||||
width: *width,
|
width: *width,
|
||||||
explicit: *explicit,
|
explicit: *explicit,
|
||||||
@@ -471,6 +473,12 @@ impl Printer<'_> {
|
|||||||
&format!("{prefix}."),
|
&format!("{prefix}."),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
DiagnosticNode::AccentKern(width) => {
|
||||||
|
self.command("kern");
|
||||||
|
self.literal(" ");
|
||||||
|
self.number(i64::from(*width));
|
||||||
|
self.literal(" (for accent)");
|
||||||
|
}
|
||||||
DiagnosticNode::Kern { width, explicit } => {
|
DiagnosticNode::Kern { width, explicit } => {
|
||||||
self.command("kern");
|
self.command("kern");
|
||||||
if *explicit {
|
if *explicit {
|
||||||
|
|||||||
@@ -3393,6 +3393,7 @@ impl Executor {
|
|||||||
)) | Meaning::CharGiven(_)
|
)) | Meaning::CharGiven(_)
|
||||||
| Meaning::Primitive(
|
| Meaning::Primitive(
|
||||||
Primitive::Char
|
Primitive::Char
|
||||||
|
| Primitive::Accent
|
||||||
| Primitive::Hskip
|
| Primitive::Hskip
|
||||||
| Primitive::Hfil
|
| Primitive::Hfil
|
||||||
| Primitive::Hfill
|
| Primitive::Hfill
|
||||||
@@ -3565,6 +3566,7 @@ impl Executor {
|
|||||||
}
|
}
|
||||||
Unskip | Unkern | Unpenalty => self.delete_last(primitive)?,
|
Unskip | Unkern | Unpenalty => self.delete_last(primitive)?,
|
||||||
ItalicCorrection => self.append_italic_correction()?,
|
ItalicCorrection => self.append_italic_correction()?,
|
||||||
|
Accent => self.text_accent(&token, files)?,
|
||||||
Shipout => self.scan_box(boxes::Destination::Shipout, files)?,
|
Shipout => self.scan_box(boxes::Destination::Shipout, files)?,
|
||||||
Leaders | Cleaders | Xleaders => self.scan_leaders(primitive, files)?,
|
Leaders | Cleaders | Xleaders => self.scan_leaders(primitive, files)?,
|
||||||
Vrule => {
|
Vrule => {
|
||||||
@@ -3741,13 +3743,23 @@ impl Executor {
|
|||||||
key: Option<Key>,
|
key: Option<Key>,
|
||||||
files: &mut impl SourceProvider,
|
files: &mut impl SourceProvider,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.assignment_inner(primitive, key, files)?;
|
self.assignment_with_box_policy(primitive, key, true, files)
|
||||||
|
}
|
||||||
|
fn assignment_with_box_policy(
|
||||||
|
&mut self,
|
||||||
|
primitive: Option<Primitive>,
|
||||||
|
key: Option<Key>,
|
||||||
|
allow_setbox: bool,
|
||||||
|
files: &mut impl SourceProvider,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
self.assignment_inner(primitive, key, allow_setbox, files)?;
|
||||||
self.finish_assignment()
|
self.finish_assignment()
|
||||||
}
|
}
|
||||||
fn assignment_inner(
|
fn assignment_inner(
|
||||||
&mut self,
|
&mut self,
|
||||||
mut primitive: Option<Primitive>,
|
mut primitive: Option<Primitive>,
|
||||||
mut key: Option<Key>,
|
mut key: Option<Key>,
|
||||||
|
allow_setbox: bool,
|
||||||
files: &mut impl SourceProvider,
|
files: &mut impl SourceProvider,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
use Primitive::*;
|
use Primitive::*;
|
||||||
@@ -3918,6 +3930,9 @@ impl Executor {
|
|||||||
}
|
}
|
||||||
Some(Parshape) => self.scan_paragraph_shape(global, files)?,
|
Some(Parshape) => self.scan_paragraph_shape(global, files)?,
|
||||||
Some(Setbox) => {
|
Some(Setbox) => {
|
||||||
|
if !allow_setbox {
|
||||||
|
return self.fail("improper native setbox in an assignment prefix");
|
||||||
|
}
|
||||||
let n = self.register_index(files)?;
|
let n = self.register_index(files)?;
|
||||||
self.optional_equals(files)?;
|
self.optional_equals(files)?;
|
||||||
if self
|
if self
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ impl Executor {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
if self.meaning(&t.token) == Meaning::Parameter(Parameter::Tabskip) {
|
if self.meaning(&t.token) == Meaning::Parameter(Parameter::Tabskip) {
|
||||||
self.assignment_inner(None, Some(Key::Parameter(Parameter::Tabskip)), files)?;
|
self.assignment_inner(None, Some(Key::Parameter(Parameter::Tabskip)), true, files)?;
|
||||||
} else {
|
} else {
|
||||||
return Ok(t);
|
return Ok(t);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,6 +249,7 @@ impl Executor {
|
|||||||
n,
|
n,
|
||||||
TextNode::Glyph { .. }
|
TextNode::Glyph { .. }
|
||||||
| TextNode::Kern { .. }
|
| TextNode::Kern { .. }
|
||||||
|
| TextNode::AccentKern(_)
|
||||||
| TextNode::Box(_)
|
| TextNode::Box(_)
|
||||||
| TextNode::Indent(_)
|
| TextNode::Indent(_)
|
||||||
| TextNode::Rule(_)
|
| TextNode::Rule(_)
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ impl Executor {
|
|||||||
self.display.as_mut().unwrap().alignment = Some(list);
|
self.display.as_mut().unwrap().alignment = Some(list);
|
||||||
// fin_align's do_assignments runs in the empty display math list. In
|
// fin_align's do_assignments runs in the empty display math list. In
|
||||||
// particular, the second closing shift is expanded before pop_nest.
|
// particular, the second closing shift is expanded before pop_nest.
|
||||||
let close = self.display_assignments(files)?;
|
let close = self.assignments_before_content(true, files)?;
|
||||||
if !matches!(
|
if !matches!(
|
||||||
self.meaning(&close.token),
|
self.meaning(&close.token),
|
||||||
Meaning::Character(TokenKind::Character(_, CatCode::MathShift))
|
Meaning::Character(TokenKind::Character(_, CatCode::MathShift))
|
||||||
@@ -353,14 +353,19 @@ impl Executor {
|
|||||||
self.display.take().unwrap();
|
self.display.take().unwrap();
|
||||||
self.resume_after_display(span, files)
|
self.resume_after_display(span, files)
|
||||||
}
|
}
|
||||||
fn display_assignments(
|
pub(super) fn assignments_before_content(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
allow_setbox: bool,
|
||||||
files: &mut impl SourceProvider,
|
files: &mut impl SourceProvider,
|
||||||
) -> Result<InputToken, Error> {
|
) -> Result<InputToken, Error> {
|
||||||
use Primitive::*;
|
use Primitive::*;
|
||||||
loop {
|
loop {
|
||||||
let t = self.expanded_non_space(files)?;
|
let t = self.expanded_non_space(files)?;
|
||||||
match self.meaning(&t.token) {
|
let meaning = self.meaning(&t.token);
|
||||||
|
if !allow_setbox && Self::suppresses_meaning(&t, &meaning) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
match meaning {
|
||||||
Meaning::Primitive(Relax) => continue,
|
Meaning::Primitive(Relax) => continue,
|
||||||
Meaning::Primitive(p)
|
Meaning::Primitive(p)
|
||||||
if p.page_dimension().is_some()
|
if p.page_dimension().is_some()
|
||||||
@@ -431,7 +436,7 @@ impl Executor {
|
|||||||
| Insertpenalties
|
| Insertpenalties
|
||||||
) =>
|
) =>
|
||||||
{
|
{
|
||||||
self.assignment(Some(p), None, files)?
|
self.assignment_with_box_policy(Some(p), None, allow_setbox, files)?
|
||||||
}
|
}
|
||||||
Meaning::Count(n) => self.assignment(None, Some(Key::Count(n)), files)?,
|
Meaning::Count(n) => self.assignment(None, Some(Key::Count(n)), files)?,
|
||||||
Meaning::Toks(n) => self.assignment(None, Some(Key::Toks(n)), files)?,
|
Meaning::Toks(n) => self.assignment(None, Some(Key::Toks(n)), files)?,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ impl Tail {
|
|||||||
TextNode::Glue(g)
|
TextNode::Glue(g)
|
||||||
| TextNode::NamedGlue(g, _)
|
| TextNode::NamedGlue(g, _)
|
||||||
| TextNode::Leaders(LeaderGlue { glue: g, .. }) => Self::Glue(*g, false),
|
| TextNode::Leaders(LeaderGlue { glue: g, .. }) => Self::Glue(*g, false),
|
||||||
TextNode::Kern { width, .. } => Self::Kern(*width),
|
TextNode::Kern { width, .. } | TextNode::AccentKern(width) => Self::Kern(*width),
|
||||||
TextNode::Penalty(n) => Self::Penalty(*n),
|
TextNode::Penalty(n) => Self::Penalty(*n),
|
||||||
TextNode::Glyph { ligature, .. } => Self::Other(if *ligature { 7 } else { 0 }),
|
TextNode::Glyph { ligature, .. } => Self::Other(if *ligature { 7 } else { 0 }),
|
||||||
TextNode::MathChar(_) => Self::Other(0),
|
TextNode::MathChar(_) => Self::Other(0),
|
||||||
|
|||||||
@@ -1,5 +1,128 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::provenance::{Derivation, PaintSource};
|
||||||
|
|
||||||
|
fn accent_glyph(state: &State, font: FontId, slot: u8, token: &Token, accent: bool) -> TextNode {
|
||||||
|
let origin = TokenOrigin::from(token);
|
||||||
|
let source = PaintSource::token(origin);
|
||||||
|
let source = if accent {
|
||||||
|
source.derived(Derivation::Accent)
|
||||||
|
} else {
|
||||||
|
source
|
||||||
|
};
|
||||||
|
let glyph = super::super::fonts::text_glyph(state, font, slot, source.clone());
|
||||||
|
TextNode::Glyph {
|
||||||
|
font,
|
||||||
|
glyph,
|
||||||
|
slot,
|
||||||
|
original: char::from(slot).to_string(),
|
||||||
|
ligature: false,
|
||||||
|
left_boundary: false,
|
||||||
|
right_boundary: false,
|
||||||
|
origins: vec![origin.span],
|
||||||
|
component_sources: vec![source],
|
||||||
|
hyphen_char: state.hyphen_character(font),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Executor {
|
impl Executor {
|
||||||
|
pub(super) fn text_accent(
|
||||||
|
&mut self,
|
||||||
|
token: &Token,
|
||||||
|
files: &mut impl SourceProvider,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
use super::super::boxes::{PackSpec, hpack};
|
||||||
|
|
||||||
|
if !self.math.is_empty() {
|
||||||
|
return self.fail("a text accent in math mode requires a math accent");
|
||||||
|
}
|
||||||
|
let span = token.invocation.unwrap_or(token.span);
|
||||||
|
self.reads.insert(Dependency::ParagraphMode);
|
||||||
|
self.reads.insert(Dependency::TextFont);
|
||||||
|
self.reads.insert(Dependency::FontResources);
|
||||||
|
let slot = self.integer(files)?;
|
||||||
|
let slot = u8::try_from(slot)
|
||||||
|
.map_err(|_| self.error("native accent character must be in 0..255", span))?;
|
||||||
|
let font = self.state.text_font();
|
||||||
|
if !self.state.font_has_slot(font, slot) {
|
||||||
|
return self.missing_glyph(font, slot, span, files);
|
||||||
|
}
|
||||||
|
let accent_font = self
|
||||||
|
.state
|
||||||
|
.fonts
|
||||||
|
.font(font)
|
||||||
|
.map_err(|error| self.error(error, span))?;
|
||||||
|
let x_height = i64::from(accent_font.x_height());
|
||||||
|
let accent_slant = f64::from(accent_font.parameters()[0]) / 65_536.0;
|
||||||
|
let mut accent = accent_glyph(&self.state, font, slot, token, true);
|
||||||
|
let base = self.assignments_before_content(false, files)?;
|
||||||
|
let base_slot = match self.meaning(&base.token) {
|
||||||
|
Meaning::Character(TokenKind::Character(c, CatCode::Letter | CatCode::Other)) => {
|
||||||
|
Some(i32::try_from(u32::from(c)).expect("a Unicode scalar fits i32"))
|
||||||
|
}
|
||||||
|
Meaning::CharGiven(c) => Some(i32::from(c)),
|
||||||
|
Meaning::Primitive(Primitive::Char) => Some(self.integer(files)?),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
let mut assembled = Vec::with_capacity(4);
|
||||||
|
if let Some(base_slot) = base_slot {
|
||||||
|
let base_span = base.token.invocation.unwrap_or(base.token.span);
|
||||||
|
let base_slot = u8::try_from(base_slot).map_err(|_| {
|
||||||
|
self.error("native accent base character must be in 0..255", base_span)
|
||||||
|
})?;
|
||||||
|
let base_font = self.state.text_font();
|
||||||
|
if self.state.font_has_slot(base_font, base_slot) {
|
||||||
|
let font = self
|
||||||
|
.state
|
||||||
|
.fonts
|
||||||
|
.font(base_font)
|
||||||
|
.map_err(|error| self.error(error, base_span))?;
|
||||||
|
let base_slant = f64::from(font.parameters()[0]) / 65_536.0;
|
||||||
|
let base_node = accent_glyph(&self.state, base_font, base_slot, &base.token, false);
|
||||||
|
let TextNode::Glyph { glyph: mark, .. } = &accent else {
|
||||||
|
unreachable!("a text accent begins with its character");
|
||||||
|
};
|
||||||
|
let TextNode::Glyph { glyph: base, .. } = &base_node else {
|
||||||
|
unreachable!("an accent base is an unshaped character");
|
||||||
|
};
|
||||||
|
let shift = x_height - base.height;
|
||||||
|
let left = (((base.width - mark.width) as f64) / 2.0
|
||||||
|
+ base.height as f64 * base_slant
|
||||||
|
- x_height as f64 * accent_slant)
|
||||||
|
.round() as i64;
|
||||||
|
let right = -mark.width - left;
|
||||||
|
let kern = |width| {
|
||||||
|
i32::try_from(width)
|
||||||
|
.map(TextNode::AccentKern)
|
||||||
|
.map_err(|_| self.error("native accent kern exceeds capacity", span))
|
||||||
|
};
|
||||||
|
let left = kern(left)?;
|
||||||
|
let right = kern(right)?;
|
||||||
|
if shift != 0 {
|
||||||
|
self.reads.insert(Dependency::BoxPackState);
|
||||||
|
let mut shifted = hpack(vec![accent], PackSpec::Natural, span, &self.state)
|
||||||
|
.map_err(|error| self.error(error, span))?;
|
||||||
|
self.state.last_badness = shifted.badness;
|
||||||
|
shifted.shift = shift;
|
||||||
|
accent = TextNode::Box(shifted.horizontal_item());
|
||||||
|
}
|
||||||
|
assembled.extend([left, accent, right, base_node]);
|
||||||
|
} else {
|
||||||
|
self.missing_glyph(base_font, base_slot, base_span, files)?;
|
||||||
|
assembled.push(accent);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.unread(base)?;
|
||||||
|
assembled.push(accent);
|
||||||
|
}
|
||||||
|
let paragraph = self
|
||||||
|
.paragraph
|
||||||
|
.as_mut()
|
||||||
|
.expect("the text accent starts horizontal mode");
|
||||||
|
paragraph.nodes.extend(assembled);
|
||||||
|
paragraph.space_factor = 1000;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) fn append_italic_correction(&mut self) -> Result<(), Error> {
|
pub(super) fn append_italic_correction(&mut self) -> Result<(), Error> {
|
||||||
self.reads.insert(Dependency::ParagraphMode);
|
self.reads.insert(Dependency::ParagraphMode);
|
||||||
self.reads.insert(Dependency::BoxPackState);
|
self.reads.insert(Dependency::BoxPackState);
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ use std::{
|
|||||||
sync::{Arc, Mutex, OnceLock, Weak},
|
sync::{Arc, Mutex, OnceLock, Weak},
|
||||||
};
|
};
|
||||||
|
|
||||||
const SCHEMA: u32 = 27;
|
const SCHEMA: u32 = 28;
|
||||||
|
const PREVIOUS_SCHEMA: u32 = 27;
|
||||||
const ENGINE: &str = concat!("texrra-native/", env!("CARGO_PKG_VERSION"));
|
const ENGINE: &str = concat!("texrra-native/", env!("CARGO_PKG_VERSION"));
|
||||||
|
|
||||||
#[derive(serde::Serialize, serde::Deserialize)]
|
#[derive(serde::Serialize, serde::Deserialize)]
|
||||||
@@ -105,16 +106,16 @@ impl FormatImage {
|
|||||||
schema: u32,
|
schema: u32,
|
||||||
engine: String,
|
engine: String,
|
||||||
}
|
}
|
||||||
// Check identity before decoding state: old schemas can lack fields
|
// Schema 28 adds primitive and node variants. All schema 27 state
|
||||||
// which the current kernel must own, even with a valid checksum.
|
// fields and variants remain readable with their original meanings.
|
||||||
let identity: Identity =
|
let identity: Identity =
|
||||||
serde_json::from_str(&envelope.payload).map_err(|error| error.to_string())?;
|
serde_json::from_str(&envelope.payload).map_err(|error| error.to_string())?;
|
||||||
if identity.schema != SCHEMA || identity.engine != ENGINE {
|
if !matches!(identity.schema, PREVIOUS_SCHEMA | SCHEMA) || identity.engine != ENGINE {
|
||||||
return Err("incompatible native format image".into());
|
return Err("incompatible native format image".into());
|
||||||
}
|
}
|
||||||
let image: Self =
|
let image: Self =
|
||||||
serde_json::from_str(&envelope.payload).map_err(|error| error.to_string())?;
|
serde_json::from_str(&envelope.payload).map_err(|error| error.to_string())?;
|
||||||
if image.schema != SCHEMA
|
if image.schema != identity.schema
|
||||||
|| image.engine != ENGINE
|
|| image.engine != ENGINE
|
||||||
|| image.state.is_initex()
|
|| image.state.is_initex()
|
||||||
|| image.state.group_depth() != 0
|
|| image.state.group_depth() != 0
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ pub enum TextNode {
|
|||||||
post_break: Vec<TextNode>,
|
post_break: Vec<TextNode>,
|
||||||
replacement_count: u8,
|
replacement_count: u8,
|
||||||
},
|
},
|
||||||
|
/// Spacing owned by a text accent and protected from leading discard.
|
||||||
|
AccentKern(i32),
|
||||||
}
|
}
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct NativeParagraph {
|
pub struct NativeParagraph {
|
||||||
@@ -383,6 +385,7 @@ fn width(n: &TextNode) -> i64 {
|
|||||||
TextNode::Rule(r) => r.dimensions().0,
|
TextNode::Rule(r) => r.dimensions().0,
|
||||||
TextNode::Output(node) => node.dimensions().map_or(0, |(width, _, _)| width),
|
TextNode::Output(node) => node.dimensions().map_or(0, |(width, _, _)| width),
|
||||||
TextNode::Kern { width: n, .. }
|
TextNode::Kern { width: n, .. }
|
||||||
|
| TextNode::AccentKern(n)
|
||||||
| TextNode::MathBoundary { width: n, .. }
|
| TextNode::MathBoundary { width: n, .. }
|
||||||
| TextNode::Indent(n) => *n as i64,
|
| TextNode::Indent(n) => *n as i64,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
@@ -584,6 +587,7 @@ fn break_lines(
|
|||||||
&& matches!(
|
&& matches!(
|
||||||
projected[i - 1],
|
projected[i - 1],
|
||||||
BreakNode::Content(_)
|
BreakNode::Content(_)
|
||||||
|
| BreakNode::AccentKern(_)
|
||||||
| BreakNode::Discretionary { .. }
|
| BreakNode::Discretionary { .. }
|
||||||
| BreakNode::Kern {
|
| BreakNode::Kern {
|
||||||
explicit: false,
|
explicit: false,
|
||||||
@@ -1316,6 +1320,7 @@ fn add_hyphens(
|
|||||||
| TextNode::NamedGlue(_, _)
|
| TextNode::NamedGlue(_, _)
|
||||||
| TextNode::Leaders(_)
|
| TextNode::Leaders(_)
|
||||||
| TextNode::Penalty(_)
|
| TextNode::Penalty(_)
|
||||||
|
| TextNode::AccentKern(_)
|
||||||
| TextNode::Kern { explicit: true, .. }
|
| TextNode::Kern { explicit: true, .. }
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ pub(super) enum BreakNode {
|
|||||||
post_break: Option<Widths>,
|
post_break: Option<Widths>,
|
||||||
replacement_count: u8,
|
replacement_count: u8,
|
||||||
},
|
},
|
||||||
|
AccentKern(i32),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BreakNode {
|
impl BreakNode {
|
||||||
@@ -146,6 +147,7 @@ impl BreakNode {
|
|||||||
TextNode::Glue(glue)
|
TextNode::Glue(glue)
|
||||||
| TextNode::NamedGlue(glue, _)
|
| TextNode::NamedGlue(glue, _)
|
||||||
| TextNode::Leaders(LeaderGlue { glue, .. }) => Self::Glue(*glue),
|
| TextNode::Leaders(LeaderGlue { glue, .. }) => Self::Glue(*glue),
|
||||||
|
TextNode::AccentKern(width) => Self::AccentKern(*width),
|
||||||
TextNode::Kern { width, explicit } => Self::Kern {
|
TextNode::Kern { width, explicit } => Self::Kern {
|
||||||
width: *width,
|
width: *width,
|
||||||
explicit: *explicit,
|
explicit: *explicit,
|
||||||
@@ -178,7 +180,9 @@ impl BreakNode {
|
|||||||
natural,
|
natural,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
Self::Kern { width, .. } | Self::MathBoundary { width, .. } => Widths {
|
Self::Kern { width, .. }
|
||||||
|
| Self::AccentKern(width)
|
||||||
|
| Self::MathBoundary { width, .. } => Widths {
|
||||||
natural: i64::from(width),
|
natural: i64::from(width),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ impl<'a> Tracer<'a> {
|
|||||||
self.short(post_break, out)?;
|
self.short(post_break, out)?;
|
||||||
i += usize::from(*replacement_count);
|
i += usize::from(*replacement_count);
|
||||||
}
|
}
|
||||||
TextNode::Kern { .. } | TextNode::Penalty(_) => {}
|
TextNode::Kern { .. } | TextNode::AccentKern(_) | TextNode::Penalty(_) => {}
|
||||||
}
|
}
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -312,6 +312,7 @@ pub enum Primitive {
|
|||||||
Overwithdelims,
|
Overwithdelims,
|
||||||
Atopwithdelims,
|
Atopwithdelims,
|
||||||
Abovewithdelims,
|
Abovewithdelims,
|
||||||
|
Accent,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Primitive {
|
impl Primitive {
|
||||||
@@ -722,6 +723,7 @@ impl Default for State {
|
|||||||
("radical", Radical),
|
("radical", Radical),
|
||||||
("left", Left),
|
("left", Left),
|
||||||
("right", Right),
|
("right", Right),
|
||||||
|
("accent", Accent),
|
||||||
("mathaccent", Mathaccent),
|
("mathaccent", Mathaccent),
|
||||||
("mathchoice", Mathchoice),
|
("mathchoice", Mathchoice),
|
||||||
("overline", Overline),
|
("overline", Overline),
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
//! Actual native box/list displays against independent INITEX diagnostics.
|
//! Actual native box/list displays against independent INITEX diagnostics.
|
||||||
|
#[path = "support/dvi_shipout.rs"]
|
||||||
|
mod dvi_shipout;
|
||||||
#[path = "support/font_world.rs"]
|
#[path = "support/font_world.rs"]
|
||||||
mod font_world;
|
mod font_world;
|
||||||
use std::{fs, process::Command};
|
use std::{fs, process::Command};
|
||||||
@@ -301,3 +303,57 @@ fn errmessage_uses_scoped_unexpanded_error_help() {
|
|||||||
.unwrap_err();
|
.unwrap_err();
|
||||||
assert_eq!(error.help, None);
|
assert_eq!(error.help, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn text_accents_preserve_font_metrics_kerns_and_paint_positions() {
|
||||||
|
let case = directory("text-accent");
|
||||||
|
let source = r"\catcode123=1 \catcode125=2
|
||||||
|
\font\regular=cmr10
|
||||||
|
\font\slanted=cmti10
|
||||||
|
\font\smaller=cmr7
|
||||||
|
\regular
|
||||||
|
\showboxbreadth=99 \showboxdepth=99
|
||||||
|
\setbox1=\hbox{\regular\accent19 A}
|
||||||
|
\setbox2=\hbox{\regular\accent19\slanted\char84}
|
||||||
|
\setbox3=\hbox{\regular\accent19\relax}
|
||||||
|
\setbox4=\hbox{\regular\accent255 Z}
|
||||||
|
\setbox5=\hbox{\regular\accent19\let\letter=a\letter}
|
||||||
|
\setbox6=\hbox{\regular\accent19\count0=731 \smaller\char97\message{ACCENT-ASSIGNMENT:\the\count0}}
|
||||||
|
\setbox7=\vbox{\hsize=50pt \baselineskip=12pt \parfillskip=0pt plus1fil
|
||||||
|
\noindent W\hfil\penalty-10000 \accent19 A\par}
|
||||||
|
\setbox8=\vbox{\hsize=50pt \parfillskip=0pt plus1fil
|
||||||
|
\everypar{\global\count2=197}\accent19 A\par}
|
||||||
|
\message{ACCENT-EVERYPAR:\the\count2}
|
||||||
|
\showbox1 \showbox2 \showbox3 \showbox4 \showbox5 \showbox6 \showbox7 \showbox8
|
||||||
|
\shipout\vbox{\box1\box2\box3\box4\box5\box6\box7\box8}
|
||||||
|
\end
|
||||||
|
";
|
||||||
|
let log = dvi_shipout::run_reference_with_showboxes(&case, source, 8);
|
||||||
|
assert!(log.contains("ACCENT-ASSIGNMENT:731"));
|
||||||
|
assert!(log.contains("ACCENT-EVERYPAR:197"));
|
||||||
|
let actual = Executor::new(State::initex().with_etex(), Limits::default())
|
||||||
|
.with_native_pages()
|
||||||
|
.run(
|
||||||
|
SourceFile {
|
||||||
|
name: "text-accent.tex".into(),
|
||||||
|
data: source.as_bytes().to_vec(),
|
||||||
|
},
|
||||||
|
&mut Host::default(),
|
||||||
|
)
|
||||||
|
.unwrap_or_else(|error| panic!("{case:?}: {error}"));
|
||||||
|
assert_eq!(actual.state.count(2), 197);
|
||||||
|
let lists = reports(&actual);
|
||||||
|
assert_eq!(lists.len(), 8);
|
||||||
|
for report in lists {
|
||||||
|
assert!(
|
||||||
|
log.contains(&report.text),
|
||||||
|
"{case:?}\nnative:\n{}\nreference:\n{log}",
|
||||||
|
report.text
|
||||||
|
);
|
||||||
|
}
|
||||||
|
let pages = dvi_shipout::compare_shipouts(&case, &actual)
|
||||||
|
.unwrap_or_else(|error| panic!("{case:?}: {error}"));
|
||||||
|
assert_eq!(pages.len(), 1);
|
||||||
|
assert_eq!(pages[0]["glyphs"].as_u64(), Some(15));
|
||||||
|
assert!(pages[0]["max_coordinate_error_sp"].as_i64().unwrap() <= 1);
|
||||||
|
}
|
||||||
+16
-4
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
2026-11-02:用户已授权完整执行 [阶段目标](NATIVE_FORMAT_ARTICLE_STAGE.md),
|
2026-11-02:用户已授权完整执行 [阶段目标](NATIVE_FORMAT_ARTICLE_STAGE.md),
|
||||||
并要求 **G1 的全部退出条件为 W1 必选门禁**。整体状态:**执行中,未完成**。
|
并要求 **G1 的全部退出条件为 W1 必选门禁**。整体状态:**执行中,未完成**。
|
||||||
最近可复现的完整工作区回归为 **1564 tests / 0 failed**,覆盖已推广的公式编号
|
最近一次完整工作区回归为 **1628 项通过、零失败**,覆盖来源映射指纹复用。
|
||||||
和 `\mathchoice`。前序显示数学对齐正式验收为 1553/0。P2-M1 总验收仍按原 W0–W7 门槛执行。
|
之后的检查点和文本重音变更使用定向回归及原样项目对照。P2-M1 总验收仍按原 W0–W7 门槛执行。
|
||||||
|
|
||||||
## 工作包状态
|
## 工作包状态
|
||||||
|
|
||||||
@@ -1106,8 +1106,20 @@ avg10 从7.08%升至42.39%。此轮对照表明快照预算的执行时间和内
|
|||||||
新写入的格式使用 schema28。已用优化候选和原样 A0 载入既有
|
新写入的格式使用 schema28。已用优化候选和原样 A0 载入既有
|
||||||
schema27,生成单页 PDF,逐词坐标和 aux 与已验证的旧结果一致。
|
schema27,生成单页 PDF,逐词坐标和 aux 与已验证的旧结果一致。
|
||||||
验证首轮误用未存档的源副本,修正后从原资源记录核对源文件指纹。
|
验证首轮误用未存档的源副本,修正后从原资源记录核对源文件指纹。
|
||||||
正在用原样 pdflatex.ini 生成新镜像,继续 APS 的实际多轮文献和 PDF。
|
同一程序从原样 pdflatex.ini 生成 schema28,实际记录 firstaid
|
||||||
阶段源码仍在隔离工作树。
|
依赖,并在格式状态中保存原生 `\accent`。
|
||||||
|
|
||||||
|
原样 APS 使用新版格式经过四轮和一次实际 BibTeX,生成7页 PDF。
|
||||||
|
PDF 的4926个提取词及坐标、7页144 DPI灰度像素、生成文献及逐轮
|
||||||
|
aux 都与冻结的 pdfTeX 对照一致。所有页面有左右栏文字,最后
|
||||||
|
两轮 aux 收敛。首次汇总时,Poppler 的词框含 XML 禁止的字符,
|
||||||
|
保存编译产物与解析失败,通过正文词框原字节比较继续审计。
|
||||||
|
格式与新旧项目证据在 `target/p3-text-accent`。APS 回执
|
||||||
|
`aps-original/receipt.json` SHA-256 为
|
||||||
|
`8a5c885e504171e88b6dae499c3403b99ddfe9d2c09b6aff0ef2a14c07ab4c23`。
|
||||||
|
按14份候选源码指纹合入,其中一处调用按 rustfmt 换行。
|
||||||
|
[原样模板记录](PUBLISHER_TEMPLATE_MATRIX.md#aps-revtex-原样双栏样稿)
|
||||||
|
[pdfTeX 的重音布局](https://github.com/TeX-Live/texlive-source/blob/trunk/texk/web2c/pdftexdir/pdftex.web#L28084-L28143)
|
||||||
|
|
||||||
### TeX 输入的默认扩展名候选
|
### TeX 输入的默认扩展名候选
|
||||||
|
|
||||||
|
|||||||
@@ -407,6 +407,23 @@ Springer LNCS、CVPR 2026 共5份 PDF。成功项的页数、词框和逐轮 aux
|
|||||||
`00265ef887ae499fa3ed5164f349198dfad6fb60ce9d07310c293cfa5ef9a6fb`。
|
`00265ef887ae499fa3ed5164f349198dfad6fb60ce9d07310c293cfa5ef9a6fb`。
|
||||||
初次报告、超时记录和同日重跑均保留。
|
初次报告、超时记录和同日重跑均保留。
|
||||||
|
|
||||||
|
### APS REVTeX 原样双栏样稿
|
||||||
|
|
||||||
|
`apssamp.tex` 的原样 reprint 版本已通过 schema28 原生格式编译。
|
||||||
|
同一官方源码、实际 REVTeX 类、字体资源和四份 EPS 转换产物保持固定。
|
||||||
|
第一轮生成参考文献所需的 aux,独立运行 BibTeX,后续三轮实际读入
|
||||||
|
`apssamp.bbl`。通用文本 `\accent` 处理了文献中 OT1 的实际重音。
|
||||||
|
|
||||||
|
原生和冻结的 pdfTeX 参考均为7页。4926个词的顺序及坐标相同,每页的
|
||||||
|
左右两栏均有实际字框。144 DPI 灰度图逐页像素相同。生成的 BBL 与
|
||||||
|
四轮 aux 逐字节一致,最后两轮收敛且没有未定义引用告警。此次证据
|
||||||
|
为主线功能的 APS 单项对照。最近同版本全矩阵仍是14份参考、5份原生,
|
||||||
|
发布时再对整批模板做组合验收。
|
||||||
|
|
||||||
|
`target/p3-text-accent/aps-original/receipt.json` SHA-256 为
|
||||||
|
`8a5c885e504171e88b6dae499c3403b99ddfe9d2c09b6aff0ef2a14c07ab4c23`。
|
||||||
|
[APS REVTeX](https://journals.aps.org/revtex)
|
||||||
|
|
||||||
### IEEE 双栏期刊与 CVPR 会议的实时会话对照
|
### IEEE 双栏期刊与 CVPR 会议的实时会话对照
|
||||||
|
|
||||||
使用矩阵中同一原样输入、TeX 格式和已验证的字体资源,验证编辑后
|
使用矩阵中同一原样输入、TeX 格式和已验证的字体资源,验证编辑后
|
||||||
|
|||||||
Reference in new issue
Block a user