Persist language-specific e-TeX hyphenation codes
This commit is contained in:
1 parent
11fd66713b
commit
b472f66d04
10 files changed
+198
-45
No files matched your search
@@ -79,6 +79,20 @@ impl Executor {
|
|||||||
_ => return self.fail("bad token in hyphenation patterns"),
|
_ => return self.fail("bad token in hyphenation patterns"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if self.read_parameter(Parameter::Savinghyphcodes).width() > 0 {
|
||||||
|
let mut codes = BTreeMap::new();
|
||||||
|
for slot in 0..=u8::MAX {
|
||||||
|
let c = char::from(slot);
|
||||||
|
self.reads.insert(Dependency::CaseCode(CaseCode::Lower, c));
|
||||||
|
// The packed trie stores this code in a quarterword. The
|
||||||
|
// XeTeX slot can map to a supplementary value before saving.
|
||||||
|
let lower = self.state.case_code(CaseCode::Lower, c) as u16;
|
||||||
|
if lower != 0 {
|
||||||
|
codes.insert(slot, lower);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.state.hyphenation.save_codes(language, codes);
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub(super) fn set_language(&mut self, files: &mut impl SourceProvider) -> Result<(), Error> {
|
pub(super) fn set_language(&mut self, files: &mut impl SourceProvider) -> Result<(), Error> {
|
||||||
|
|||||||
@@ -796,19 +796,18 @@ impl Executor {
|
|||||||
self.reads.insert(Dependency::Parameter(Parameter::XeTeXhyphenatablelength));
|
self.reads.insert(Dependency::Parameter(Parameter::XeTeXhyphenatablelength));
|
||||||
}
|
}
|
||||||
let max_length = super::super::hyphenation::max_word_length(&self.state);
|
let max_length = super::super::hyphenation::max_word_length(&self.state);
|
||||||
let (mut word, mut points, mut count, mut units) = (String::new(), Vec::new(), 0, 0);
|
let use_saved = !self.state.is_initex() || self.state.hyphenation.sealed;
|
||||||
|
if use_saved {
|
||||||
|
self.reads.insert(Dependency::Hyphenation);
|
||||||
|
}
|
||||||
|
let (mut word, mut points, mut units) = (Vec::new(), Vec::new(), 0);
|
||||||
loop {
|
loop {
|
||||||
let t = self.required_expanded(files)?.token;
|
let t = self.required_expanded(files)?.token;
|
||||||
let meaning = self.meaning(&t);
|
let meaning = self.meaning(&t);
|
||||||
let c = match meaning {
|
let c = match meaning {
|
||||||
Meaning::Character(TokenKind::Character(_, CatCode::Space | CatCode::EndGroup)) => {
|
Meaning::Character(TokenKind::Character(_, CatCode::Space | CatCode::EndGroup)) => {
|
||||||
if count > 1 {
|
if word.len() > 1 {
|
||||||
self.state
|
self.state.hyphenation.insert_exception(language, &word, std::mem::take(&mut points));
|
||||||
.hyphenation
|
|
||||||
.exceptions
|
|
||||||
.entry(language)
|
|
||||||
.or_default()
|
|
||||||
.insert(word.clone(), points.clone());
|
|
||||||
}
|
}
|
||||||
if matches!(
|
if matches!(
|
||||||
meaning,
|
meaning,
|
||||||
@@ -818,7 +817,6 @@ impl Executor {
|
|||||||
}
|
}
|
||||||
word.clear();
|
word.clear();
|
||||||
points.clear();
|
points.clear();
|
||||||
count = 0;
|
|
||||||
units = 0;
|
units = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -833,20 +831,25 @@ impl Executor {
|
|||||||
};
|
};
|
||||||
if c == '-' {
|
if c == '-' {
|
||||||
if units < max_length {
|
if units < max_length {
|
||||||
points.push(count);
|
points.push(word.len());
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
self.reads.insert(Dependency::CaseCode(CaseCode::Lower, c));
|
let saved = if use_saved {
|
||||||
let lower = self.state.case_code(CaseCode::Lower, c);
|
self.state.hyphenation.saved_code(language, c)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
let lower = saved.unwrap_or_else(|| {
|
||||||
|
self.reads.insert(Dependency::CaseCode(CaseCode::Lower, c));
|
||||||
|
self.state.case_code(CaseCode::Lower, c)
|
||||||
|
});
|
||||||
if lower == 0 {
|
if lower == 0 {
|
||||||
return self.fail("hyphenation character must have nonzero lccode");
|
return self.fail("hyphenation character must have nonzero lccode");
|
||||||
}
|
}
|
||||||
let lower = char::from_u32(lower).expect("validated case code");
|
let size = if xetex && lower >= 0x10000 { 2 } else { 1 };
|
||||||
let size = if xetex { lower.len_utf16() } else { 1 };
|
|
||||||
if units + size <= max_length {
|
if units + size <= max_length {
|
||||||
word.push(lower);
|
word.push(lower);
|
||||||
count += 1;
|
|
||||||
units += size;
|
units += size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ use std::{
|
|||||||
sync::{Arc, Mutex, OnceLock, Weak},
|
sync::{Arc, Mutex, OnceLock, Weak},
|
||||||
};
|
};
|
||||||
|
|
||||||
const SCHEMA: u32 = 98;
|
const SCHEMA: u32 = 99;
|
||||||
const COMPATIBLE_SCHEMAS: [u32; 64] = [
|
const COMPATIBLE_SCHEMAS: [u32; 65] = [
|
||||||
27, 28, 31, 32, 33, 34, 35, 36, 37, 38, 39, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 96, 97, SCHEMA,
|
27, 28, 31, 32, 33, 34, 35, 36, 37, 38, 39, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 96, 97, 98, SCHEMA,
|
||||||
];
|
];
|
||||||
const ENGINE: &str = concat!("texrra-native/", env!("CARGO_PKG_VERSION"));
|
const ENGINE: &str = concat!("texrra-native/", env!("CARGO_PKG_VERSION"));
|
||||||
|
|
||||||
@@ -209,7 +209,10 @@ impl FormatImage {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
if image.schema < 98 {
|
if image.schema < 98 {
|
||||||
image.state.restore_legacy_last_line_fit();
|
image.state.restore_legacy_etex_parameter(Parameter::Lastlinefit);
|
||||||
|
}
|
||||||
|
if image.schema < 99 {
|
||||||
|
image.state.restore_legacy_etex_parameter(Parameter::Savinghyphcodes);
|
||||||
}
|
}
|
||||||
let pdf_objects = image.state.pdf_objects.as_deref();
|
let pdf_objects = image.state.pdf_objects.as_deref();
|
||||||
let mut numbered_images = 0;
|
let mut numbered_images = 0;
|
||||||
|
|||||||
@@ -46,6 +46,14 @@ pub(super) fn max_word_length(state: &State) -> usize {
|
|||||||
pub(super) fn normalize_language(n: i32) -> u8 {
|
pub(super) fn normalize_language(n: i32) -> u8 {
|
||||||
if (1..=255).contains(&n) { n as u8 } else { 0 }
|
if (1..=255).contains(&n) { n as u8 } else { 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(super) fn lower_code(state: &State, language: u8, c: char) -> u32 {
|
||||||
|
state
|
||||||
|
.hyphenation
|
||||||
|
.saved_code(language, c)
|
||||||
|
.unwrap_or_else(|| state.case_code(CaseCode::Lower, c))
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
struct TrieNode {
|
struct TrieNode {
|
||||||
edges: BTreeMap<u32, usize>,
|
edges: BTreeMap<u32, usize>,
|
||||||
@@ -79,10 +87,28 @@ impl Hash for TrieNodes {
|
|||||||
pub(super) struct HyphenationData {
|
pub(super) struct HyphenationData {
|
||||||
nodes: Arc<TrieNodes>,
|
nodes: Arc<TrieNodes>,
|
||||||
roots: BTreeMap<u8, usize>,
|
roots: BTreeMap<u8, usize>,
|
||||||
|
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||||
|
saved_codes: Arc<BTreeMap<u8, BTreeMap<u8, u16>>>,
|
||||||
pub exceptions: BTreeMap<u8, BTreeMap<String, Vec<usize>>>,
|
pub exceptions: BTreeMap<u8, BTreeMap<String, Vec<usize>>>,
|
||||||
pub sealed: bool,
|
pub sealed: bool,
|
||||||
}
|
}
|
||||||
impl HyphenationData {
|
impl HyphenationData {
|
||||||
|
pub(super) fn save_codes(&mut self, language: u8, codes: BTreeMap<u8, u16>) {
|
||||||
|
Arc::make_mut(&mut self.saved_codes).insert(language, codes);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn saved_code(&self, language: u8, c: char) -> Option<u32> {
|
||||||
|
let slot = u8::try_from(c).ok()?;
|
||||||
|
let codes = self.saved_codes.get(&language)?;
|
||||||
|
// An absent slot in a saved table has lccode zero. Only an absent
|
||||||
|
// table, or a XeTeX character above 255, consults the live table.
|
||||||
|
Some(u32::from(codes.get(&slot).copied().unwrap_or(0)))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn saved_code_count(&self) -> usize {
|
||||||
|
self.saved_codes.values().map(BTreeMap::len).sum()
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) fn resource_counts(&self) -> (usize, usize, usize) {
|
pub(super) fn resource_counts(&self) -> (usize, usize, usize) {
|
||||||
let (edges, weights) = *self.nodes.counts.get_or_init(|| {
|
let (edges, weights) = *self.nodes.counts.get_or_init(|| {
|
||||||
self.nodes
|
self.nodes
|
||||||
@@ -134,8 +160,14 @@ impl HyphenationData {
|
|||||||
nodes.push(TrieNode::default());
|
nodes.push(TrieNode::default());
|
||||||
Ok(next)
|
Ok(next)
|
||||||
}
|
}
|
||||||
pub fn points(&self, language: u8, word: &str) -> Vec<usize> {
|
pub(super) fn insert_exception(&mut self, language: u8, word: &[u32], points: Vec<usize>) {
|
||||||
if let Some(points) = self.exceptions.get(&language).and_then(|e| e.get(word)) {
|
self.exceptions.entry(language).or_default().insert(exception_key(word), points);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn points(&self, language: u8, word: &[u32]) -> Vec<usize> {
|
||||||
|
if let Some(exceptions) = self.exceptions.get(&language)
|
||||||
|
&& let Some(points) = exceptions.get(&exception_key(word))
|
||||||
|
{
|
||||||
return points.clone();
|
return points.clone();
|
||||||
}
|
}
|
||||||
let Some(&root) = self.roots.get(&language) else {
|
let Some(&root) = self.roots.get(&language) else {
|
||||||
@@ -143,7 +175,7 @@ impl HyphenationData {
|
|||||||
};
|
};
|
||||||
let nodes = &self.nodes.values;
|
let nodes = &self.nodes.values;
|
||||||
let letters: Vec<_> = std::iter::once(0)
|
let letters: Vec<_> = std::iter::once(0)
|
||||||
.chain(word.chars().map(|c| c as u32))
|
.chain(word.iter().copied())
|
||||||
.chain([0])
|
.chain([0])
|
||||||
.collect();
|
.collect();
|
||||||
let mut scores = vec![0; letters.len() + 1];
|
let mut scores = vec![0; letters.len() + 1];
|
||||||
@@ -159,12 +191,27 @@ impl HyphenationData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(1..word.chars().count())
|
(1..word.len())
|
||||||
.filter(|i| scores[i + 1] % 2 == 1)
|
.filter(|i| scores[i + 1] % 2 == 1)
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn exception_key(word: &[u32]) -> String {
|
||||||
|
let mut key = String::with_capacity(word.len());
|
||||||
|
for &code in word {
|
||||||
|
if let Some(c) = char::from_u32(code) {
|
||||||
|
key.push(c);
|
||||||
|
} else {
|
||||||
|
// XeTeX can truncate a saved code to a UTF-16 surrogate. Escape
|
||||||
|
// that unit with NUL, which cannot occur as a hyphenation letter.
|
||||||
|
key.push('\0');
|
||||||
|
key.push(char::from_u32(code - 0xd800).expect("saved surrogate code"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
key
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cloned_patterns_remain_isolated_on_assignment() {
|
fn cloned_patterns_remain_isolated_on_assignment() {
|
||||||
let mut format = HyphenationData::default();
|
let mut format = HyphenationData::default();
|
||||||
@@ -177,8 +224,9 @@ fn cloned_patterns_remain_isolated_on_assignment() {
|
|||||||
format.insert(0, &['a' as u32], &[0, 0], 12).unwrap();
|
format.insert(0, &['a' as u32], &[0, 0], 12).unwrap();
|
||||||
assert_eq!(format.resource_counts(), (4, 3, 5));
|
assert_eq!(format.resource_counts(), (4, 3, 5));
|
||||||
assert_eq!(shared.resource_counts(), (3, 2, 3));
|
assert_eq!(shared.resource_counts(), (3, 2, 3));
|
||||||
assert_eq!(shared.points(0, "tea"), [1]);
|
let tea = [u32::from(b't'), u32::from(b'e'), u32::from(b'a')];
|
||||||
assert_eq!(format.points(0, "tea"), [1]);
|
assert_eq!(shared.points(0, &tea), [1]);
|
||||||
|
assert_eq!(format.points(0, &tea), [1]);
|
||||||
|
|
||||||
let encoded = serde_json::to_value(&shared).unwrap();
|
let encoded = serde_json::to_value(&shared).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|||||||
@@ -1656,7 +1656,12 @@ fn add_hyphens(
|
|||||||
let mut edits = Vec::new();
|
let mut edits = Vec::new();
|
||||||
let mut word_font = None;
|
let mut word_font = None;
|
||||||
while i <= nodes.len() {
|
while i <= nodes.len() {
|
||||||
let word_node=nodes.get(i).is_some_and(|n|matches!(n,TextNode::Glyph{original,..} if original.chars().all(|c| state.case_code(super::CaseCode::Lower,c) != 0)))||nodes.get(i).is_some_and(|n|matches!(n,TextNode::Kern{explicit:false,..}));
|
let lower = |c| super::hyphenation::lower_code(state, language.language, c);
|
||||||
|
let word_node = match nodes.get(i) {
|
||||||
|
Some(TextNode::Glyph { original, .. }) => original.chars().all(|c| lower(c) != 0),
|
||||||
|
Some(TextNode::Kern { explicit: false, .. }) => true,
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
let glyph_font = match nodes.get(i) {
|
let glyph_font = match nodes.get(i) {
|
||||||
Some(TextNode::Glyph { font, .. }) => Some(*font),
|
Some(TextNode::Glyph { font, .. }) => Some(*font),
|
||||||
_ => None,
|
_ => None,
|
||||||
@@ -1703,7 +1708,7 @@ fn add_hyphens(
|
|||||||
TextNode::Glyph { original, .. } => original
|
TextNode::Glyph { original, .. } => original
|
||||||
.chars()
|
.chars()
|
||||||
.next()
|
.next()
|
||||||
.is_some_and(|c| state.case_code(super::CaseCode::Lower, c) != 0),
|
.is_some_and(|c| lower(c) != 0),
|
||||||
_ => true,
|
_ => true,
|
||||||
})
|
})
|
||||||
.is_some_and(|n| {
|
.is_some_and(|n| {
|
||||||
@@ -1717,7 +1722,7 @@ fn add_hyphens(
|
|||||||
|| word
|
|| word
|
||||||
.chars()
|
.chars()
|
||||||
.next()
|
.next()
|
||||||
.is_some_and(|c| state.case_code(super::CaseCode::Lower, c) == c as u32))
|
.is_some_and(|c| lower(c) == c as u32))
|
||||||
&& state.hyphen_character(font).is_some()
|
&& state.hyphen_character(font).is_some()
|
||||||
&& nodes[i..]
|
&& nodes[i..]
|
||||||
.iter()
|
.iter()
|
||||||
@@ -1750,13 +1755,7 @@ fn add_hyphens(
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
let normalized: String = word
|
let normalized: Vec<_> = word.chars().map(lower).collect();
|
||||||
.chars()
|
|
||||||
.map(|c| {
|
|
||||||
char::from_u32(state.case_code(super::CaseCode::Lower, c))
|
|
||||||
.expect("nonzero case mapping")
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
let points: Vec<_> = state
|
let points: Vec<_> = state
|
||||||
.hyphenation
|
.hyphenation
|
||||||
.points(language.language, &normalized)
|
.points(language.language, &normalized)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ pub(super) fn add_hyphens(
|
|||||||
let mut edits = Vec::new();
|
let mut edits = Vec::new();
|
||||||
|
|
||||||
for (index, node) in nodes.iter().enumerate() {
|
for (index, node) in nodes.iter().enumerate() {
|
||||||
|
let lower = |c| super::super::hyphenation::lower_code(state, language.language, c);
|
||||||
match node {
|
match node {
|
||||||
TextNode::Language(next) => language = *next,
|
TextNode::Language(next) => language = *next,
|
||||||
TextNode::Direction(_)
|
TextNode::Direction(_)
|
||||||
@@ -38,14 +39,15 @@ pub(super) fn add_hyphens(
|
|||||||
&& original
|
&& original
|
||||||
.chars()
|
.chars()
|
||||||
.next()
|
.next()
|
||||||
.is_none_or(|c| state.case_code(CaseCode::Lower, c) == 0) => {}
|
.is_none_or(|c| lower(c) == 0) => {}
|
||||||
TextNode::OpenType(run) if after_glue => {
|
TextNode::OpenType(run) if after_glue => {
|
||||||
let lower =
|
|
||||||
|c| char::from_u32(state.case_code(CaseCode::Lower, c)).filter(|c| *c != '\0');
|
|
||||||
let Some((start, first, first_lower)) = run
|
let Some((start, first, first_lower)) = run
|
||||||
.text
|
.text
|
||||||
.char_indices()
|
.char_indices()
|
||||||
.find_map(|(at, c)| lower(c).map(|value| (at, c, value)))
|
.find_map(|(at, c)| {
|
||||||
|
let code = lower(c);
|
||||||
|
(code != 0).then_some((at, c, code))
|
||||||
|
})
|
||||||
else {
|
else {
|
||||||
// A punctuation-only native node does not end the search.
|
// A punctuation-only native node does not end the search.
|
||||||
continue;
|
continue;
|
||||||
@@ -53,7 +55,7 @@ pub(super) fn add_hyphens(
|
|||||||
after_glue = false;
|
after_glue = false;
|
||||||
let left = usize::from(language.left_min);
|
let left = usize::from(language.left_min);
|
||||||
let right = usize::from(language.right_min);
|
let right = usize::from(language.right_min);
|
||||||
if (!uppercase && first != first_lower)
|
if (!uppercase && u32::from(first) != first_lower)
|
||||||
|| left + right > max_length
|
|| left + right > max_length
|
||||||
|| !following_nodes_allow_hyphenation(&nodes[index + 1..])
|
|| !following_nodes_allow_hyphenation(&nodes[index + 1..])
|
||||||
{
|
{
|
||||||
@@ -68,16 +70,17 @@ pub(super) fn add_hyphens(
|
|||||||
|
|
||||||
// Match normalized letters in the language trie but preserve UTF-16
|
// Match normalized letters in the language trie but preserve UTF-16
|
||||||
// lengths for XeTeX's limits and byte offsets for shaping/provenance.
|
// lengths for XeTeX's limits and byte offsets for shaping/provenance.
|
||||||
let mut word = String::new();
|
let mut word = Vec::new();
|
||||||
let mut boundaries = vec![(start, 0)];
|
let mut boundaries = vec![(start, 0)];
|
||||||
let mut end = run.text.len();
|
let mut end = run.text.len();
|
||||||
let mut units = 0;
|
let mut units = 0;
|
||||||
for (offset, c) in run.text[start..].char_indices() {
|
for (offset, c) in run.text[start..].char_indices() {
|
||||||
let at = start + offset;
|
let at = start + offset;
|
||||||
let Some(value) = lower(c) else {
|
let value = lower(c);
|
||||||
|
if value == 0 {
|
||||||
end = at;
|
end = at;
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
if units + c.len_utf16() > max_length {
|
if units + c.len_utf16() > max_length {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ pub enum Parameter {
|
|||||||
Pdfptexuseunderscore,
|
Pdfptexuseunderscore,
|
||||||
Ignoreprimitiveerror,
|
Ignoreprimitiveerror,
|
||||||
Lastlinefit,
|
Lastlinefit,
|
||||||
|
Savinghyphcodes,
|
||||||
}
|
}
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum ParameterValue {
|
pub enum ParameterValue {
|
||||||
@@ -344,6 +345,7 @@ impl Parameter {
|
|||||||
Self::XeTeXlinebreakpenalty,
|
Self::XeTeXlinebreakpenalty,
|
||||||
Self::XeTeXinputnormalization,
|
Self::XeTeXinputnormalization,
|
||||||
Self::Lastlinefit,
|
Self::Lastlinefit,
|
||||||
|
Self::Savinghyphcodes,
|
||||||
];
|
];
|
||||||
pub fn name(self) -> String {
|
pub fn name(self) -> String {
|
||||||
match self {
|
match self {
|
||||||
|
|||||||
@@ -1293,6 +1293,7 @@ impl Default for State {
|
|||||||
| Parameter::Ignoreprimitiveerror
|
| Parameter::Ignoreprimitiveerror
|
||||||
| Parameter::TeXXeTstate
|
| Parameter::TeXXeTstate
|
||||||
| Parameter::Lastlinefit
|
| Parameter::Lastlinefit
|
||||||
|
| Parameter::Savinghyphcodes
|
||||||
) || Parameter::XETEX.contains(p) {
|
) || Parameter::XETEX.contains(p) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1346,6 +1347,7 @@ impl State {
|
|||||||
+ self.sfcodes.len()
|
+ self.sfcodes.len()
|
||||||
+ self.xe_char_classes.len()
|
+ self.xe_char_classes.len()
|
||||||
+ self.case_codes.len()
|
+ self.case_codes.len()
|
||||||
|
+ self.hyphenation.saved_code_count()
|
||||||
+ self.mathfonts.len();
|
+ self.mathfonts.len();
|
||||||
c.usage.state.save_entries = self.groups.iter().map(|g| g.saved.len()).sum();
|
c.usage.state.save_entries = self.groups.iter().map(|g| g.saved.len()).sum();
|
||||||
c.usage.state.font_instances = self.fonts.fonts().len() - 1;
|
c.usage.state.font_instances = self.fonts.fonts().len() - 1;
|
||||||
@@ -1545,6 +1547,7 @@ impl State {
|
|||||||
Parameter::Savingvdiscards,
|
Parameter::Savingvdiscards,
|
||||||
Parameter::Ignoreprimitiveerror,
|
Parameter::Ignoreprimitiveerror,
|
||||||
Parameter::Lastlinefit,
|
Parameter::Lastlinefit,
|
||||||
|
Parameter::Savinghyphcodes,
|
||||||
] {
|
] {
|
||||||
self.commands.insert(
|
self.commands.insert(
|
||||||
CommandName::Control(parameter.name()),
|
CommandName::Control(parameter.name()),
|
||||||
@@ -1795,9 +1798,8 @@ impl State {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn restore_legacy_last_line_fit(&mut self) {
|
pub(super) fn restore_legacy_etex_parameter(&mut self, parameter: Parameter) {
|
||||||
if self.profile == Profile::EtexBootstrap {
|
if self.profile == Profile::EtexBootstrap {
|
||||||
let parameter = Parameter::Lastlinefit;
|
|
||||||
self.commands
|
self.commands
|
||||||
.entry(CommandName::Control(parameter.name()))
|
.entry(CommandName::Control(parameter.name()))
|
||||||
.or_insert(Meaning::Parameter(parameter));
|
.or_insert(Meaning::Parameter(parameter));
|
||||||
|
|||||||
@@ -81,6 +81,51 @@ fn legal_dump_loads_owned_format_state_into_a_new_job() {
|
|||||||
assert!(ordinary.message.contains("INITEX"));
|
assert!(ordinary.message.contains("INITEX"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn saved_hyphenation_codes_survive_groups_and_format_reload() {
|
||||||
|
let seed = r"\catcode123=1 \catcode125=2
|
||||||
|
\let\save=\savinghyphcodes
|
||||||
|
{\save=1 \language=0 \patterns{a1b}}
|
||||||
|
\language=1 \patterns{a1b}
|
||||||
|
{\save=1 \language=2 \lccode97=0 \patterns{}}
|
||||||
|
\lccode97=0 \dump";
|
||||||
|
let state = State::initex().with_etex();
|
||||||
|
let early = seed.replace(r"\dump", r"\language=0 \hyphenation{a-ba}\end");
|
||||||
|
let error = Executor::new(state.clone(), Limits::default())
|
||||||
|
.run(source("seed.tex", &early), &mut Host)
|
||||||
|
.unwrap_err();
|
||||||
|
assert!(error.message.contains("nonzero lccode"));
|
||||||
|
|
||||||
|
let dump = Executor::new(state.clone(), Limits::default())
|
||||||
|
.run(source("seed.tex", seed), &mut Host)
|
||||||
|
.unwrap();
|
||||||
|
let image = FormatImage::from_dump(dump, Vec::new(), Vec::new())
|
||||||
|
.unwrap()
|
||||||
|
.encode()
|
||||||
|
.unwrap();
|
||||||
|
let run = |text| {
|
||||||
|
FormatImage::decode(&image)
|
||||||
|
.unwrap()
|
||||||
|
.new_job(
|
||||||
|
state.profile(),
|
||||||
|
state.input_profile(),
|
||||||
|
JobTime::new(2026, 1, 2, 0).unwrap(),
|
||||||
|
Limits::default(),
|
||||||
|
|_| Ok(seed.as_bytes().to_vec()),
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
.run(source("document.tex", text), &mut Host)
|
||||||
|
};
|
||||||
|
let job = run(r"\language=0 \hyphenation{a-ba}\message{\the\lccode97/\the\save}\end").unwrap();
|
||||||
|
assert!(job.events.iter().any(
|
||||||
|
|event| matches!(event, Event::Message { text, .. } if text == "0/0")
|
||||||
|
));
|
||||||
|
let error = run(r"\language=1 \hyphenation{a-ba}\end").unwrap_err();
|
||||||
|
assert!(error.message.contains("nonzero lccode"));
|
||||||
|
let error = run(r"\language=2 \lccode97=97 \hyphenation{a-ba}\end").unwrap_err();
|
||||||
|
assert!(error.message.contains("nonzero lccode"));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn format_stream_ranges_are_verified_against_one_read_per_path() {
|
fn format_stream_ranges_are_verified_against_one_read_per_path() {
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
|
|||||||
@@ -18,6 +18,40 @@
|
|||||||
| W6 会话 | 实施中 | 共享库/CLI 与当前原生文字/数学/规则来源进入公共结果;真实 A4 副本九类/27 revision 与独立干净作业页面/PDF/aux/映射一致,新增数学场景独立参考通过;详细失败/捕获重放及宿主/离线/CLI观察已通过;原子项目版本/已知生成初态及TeX流记录已接通;完整副作用/恢复契约、旧来源和性能仍缺 |
|
| W6 会话 | 实施中 | 共享库/CLI 与当前原生文字/数学/规则来源进入公共结果;真实 A4 副本九类/27 revision 与独立干净作业页面/PDF/aux/映射一致,新增数学场景独立参考通过;详细失败/捕获重放及宿主/离线/CLI观察已通过;原子项目版本/已知生成初态及TeX流记录已接通;完整副作用/恢复契约、旧来源和性能仍缺 |
|
||||||
| W7 总验收 | 未满足 | 原有和新增测试、原样项目、格式与会话门禁全部通过才能结项 |
|
| W7 总验收 | 未满足 | 原有和新增测试、原样项目、格式与会话门禁全部通过才能结项 |
|
||||||
|
|
||||||
|
## 2026-11-28 e-TeX 按语言保存断词代码
|
||||||
|
|
||||||
|
`\savinghyphcodes` 为正时,在 `\patterns` 读完后保存该语言当时的
|
||||||
|
0 至 255 号字符小写代码。再次保存替换同语言的快照,零值也保留其含义。
|
||||||
|
词识别、断词和已就绪格式的 `\hyphenation` 例外使用该表,普通
|
||||||
|
`\lccode` 查询仍读取实时值。XeTeX 的 255 以上字符仍读实时表,快照
|
||||||
|
映射值按参考引擎的 16 位存储规则写入。断词表尚未就绪时,INITEX
|
||||||
|
中的例外登记使用实时值。schema99 保存快照和原语别名,加载
|
||||||
|
schema98 时保留已有的同名用户定义。
|
||||||
|
|
||||||
|
保存的冻结断词用例及格式重载用例在 pdfTeX、XeTeX 各五页。每种模式
|
||||||
|
49 行断行跟踪、17 个词框和 144 DPI 灰度图与参考一致。重载覆盖局部
|
||||||
|
保存、空 `\patterns`、替换快照、按语言回退实时值及例外登记。
|
||||||
|
两个使用实际 Latin Modern OTF 的 XeTeX 专项用例显式给定 10 pt 时,
|
||||||
|
11 页、45 个原始字形及坐标、17 个词框与灰度图和断行跟踪均一致。
|
||||||
|
原样 `pdflatex.ini` 和 `xelatex.ini` 生成的格式均完成重载,
|
||||||
|
实际 LaTeX3 别名驱动整数赋值并生成一页 article。冻结的原样 ACL
|
||||||
|
在既有 schema71 下复编,PDF、布局清单和辅助文件与前版一致。
|
||||||
|
|
||||||
|
原先省略字号的两个 OpenType 用例仍保留差异。参考使用 657,818 sp,
|
||||||
|
原生使用 655,360 sp。保持相同断词行为、改用实时表的旧内核对照复现
|
||||||
|
了相同差异。需接通原生字体的实际设计字号读取及比例计算。
|
||||||
|
|
||||||
|
三页会话从单独的输入文件修改快照,三轮各复用 1,119 步。改动保存值
|
||||||
|
会刷新第二页,只改被快照覆盖的实时值时没有页面变化且复用断行。
|
||||||
|
PDF、测量页面、SVG、稳定辅助文件和来源映射逐轮与独立全量一致。
|
||||||
|
|
||||||
|
11 项格式与段落跟踪测试通过。原始输入、冻结失败、双模式输出、
|
||||||
|
显式字号对照和编辑记录保存在 `target/p2-etex-saved-hyphenation-codes`。
|
||||||
|
`receipt.json` 的 SHA-256 为
|
||||||
|
`cb29f88bce823aa8be96397c1be4c4f3fafded6c4a29ca58c427b69d39a565c2`。
|
||||||
|
[e-TeX 保存机制](https://github.com/TeX-Live/texlive-source/blob/fb6158926661cb7a7246b3a94a0cb170a9624d5a/texk/web2c/etexdir/etex.ch#L5963-L6025)
|
||||||
|
· [XeTeX 原生字体与断词](https://github.com/TeX-Live/texlive-source/blob/fb6158926661cb7a7246b3a94a0cb170a9624d5a/texk/web2c/xetexdir/xetex.web)
|
||||||
|
|
||||||
## 2026-11-28 e-TeX 段落末行调整
|
## 2026-11-28 e-TeX 段落末行调整
|
||||||
|
|
||||||
原生 e-TeX 两种 profile 都执行 `\lastlinefit`。正常断行的候选记录
|
原生 e-TeX 两种 profile 都执行 `\lastlinefit`。正常断行的候选记录
|
||||||
|
|||||||
Reference in new issue
Block a user