Apply native font protrusion during line breaking and packing
This commit is contained in:
1 parent
361e8d070f
commit
4777d66fc8
22 files changed
+441
-32
No files matched your search
@@ -1988,6 +1988,16 @@ impl Executor {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn font_character_target(
|
||||
&mut self, files: &mut impl SourceProvider,
|
||||
) -> Result<(FontId, u8), Error> {
|
||||
let font = self.font_identifier(files)?;
|
||||
let slot = self.integer(files)?;
|
||||
let slot = u8::try_from(slot).map_err(|_| {
|
||||
self.error("font character code must be in 0..255", self.current)
|
||||
})?;
|
||||
Ok((font, slot))
|
||||
}
|
||||
fn internal_integer_from(
|
||||
&mut self,
|
||||
next: InputToken,
|
||||
@@ -2012,6 +2022,10 @@ impl Executor {
|
||||
}
|
||||
Ok(value.width())
|
||||
}
|
||||
Meaning::Primitive(p @ (Primitive::Lpcode | Primitive::Rpcode)) => {
|
||||
let (font, slot) = self.font_character_target(files)?;
|
||||
Ok(self.state.fonts.protrusion_code(font, slot, p == Primitive::Rpcode))
|
||||
}
|
||||
Meaning::Primitive(p @ (Primitive::Hyphenchar | Primitive::Skewchar)) => {
|
||||
let font = self.font_identifier(files)?;
|
||||
let values = self.state.font_integers(font);
|
||||
@@ -3847,6 +3861,12 @@ impl Executor {
|
||||
matches!(primitive, Some(Edef | Xdef)),
|
||||
files,
|
||||
)?,
|
||||
Some(Lpcode | Rpcode) => {
|
||||
let (font, slot) = self.font_character_target(files)?;
|
||||
self.optional_equals(files)?;
|
||||
let code = self.integer(files)?;
|
||||
self.state.fonts.set_protrusion_code(font, slot, primitive == Some(Rpcode), code);
|
||||
}
|
||||
Some(Hyphenchar | Skewchar) => {
|
||||
let font = self.font_identifier(files)?;
|
||||
self.optional_equals(files)?;
|
||||
|
||||
Reference in new issue
Block a user