Add a pdfLaTeX oracle and clamp justification glue
This commit is contained in:
1 parent
1e2d4afd6b
commit
9726f5f736
6 files changed
+379
-18
No files matched your search
@@ -295,14 +295,20 @@ fn parse_kerns(
|
||||
};
|
||||
if let Some(unicode) = unicode {
|
||||
let right = char::from_u32(u32::from(next)).unwrap_or('?');
|
||||
ligatures.insert((left, right), (unicode, slot_char));
|
||||
ligatures
|
||||
.entry((left, right))
|
||||
.or_insert((unicode, slot_char));
|
||||
}
|
||||
} else {
|
||||
let kern_index = usize::from(op - 128) * 256 + usize::from(remainder);
|
||||
if let Some(raw) = kern_table.get(kern_index) {
|
||||
let right = char::from_u32(u32::from(next)).unwrap_or('?');
|
||||
// Kern values are design-size-relative, like character
|
||||
// widths; at the design size they are in 1/16 pt units.
|
||||
let value = (f64::from(*raw) * design_size_pt / 16.0).round() as i64;
|
||||
kerns.insert((left, right), value);
|
||||
// TeX stops at the first instruction that matches the
|
||||
// pair, so later instructions must not overwrite it.
|
||||
kerns.entry((left, right)).or_insert(value);
|
||||
}
|
||||
}
|
||||
if skip >= 128 {
|
||||
@@ -333,6 +339,21 @@ mod tests {
|
||||
assert!(font.depth('g') > 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cmr10_kerning_is_design_size_relative() {
|
||||
let font = cmr10();
|
||||
let kern = font.kern('m', 'b');
|
||||
assert!(
|
||||
(kern + 18_205).abs() <= 4,
|
||||
"m/b kern should be -0.277779pt, got {kern}"
|
||||
);
|
||||
let apostrophe = font.kern('f', '\'');
|
||||
assert!(
|
||||
(apostrophe - 50_973).abs() <= 4,
|
||||
"f/apostrophe kern should be +0.777779pt, got {apostrophe}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cmr10_has_an_fi_ligature() {
|
||||
let font = cmr10();
|
||||
|
||||
Reference in new issue
Block a user