Implement XeTeX OpenType letterspacing and contextual line widths
This commit is contained in:
1 parent
4a77540e46
commit
cc0246016d
10 files changed
+223
-97
No files matched your search
@@ -70,11 +70,12 @@ impl Executor {
|
||||
}
|
||||
let font = self.font_identifier(files)?;
|
||||
let slot = self.integer(files)?;
|
||||
if let Some(face) = self.state.fonts.font(font).map_err(|e| self.error(e, self.current))?.opentype() {
|
||||
let instance = self.state.fonts.font(font).map_err(|e| self.error(e, self.current))?;
|
||||
if let Some(face) = instance.opentype() {
|
||||
let character = u32::try_from(slot).ok().and_then(char::from_u32)
|
||||
.ok_or_else(|| self.error("invalid Unicode font character", self.current))?;
|
||||
let metrics = face.glyph_metrics(character)
|
||||
.map_err(|e| self.error(e, self.current))?.unwrap_or([0; 4]);
|
||||
let metrics = face.glyph_metrics(character, instance.parameters())
|
||||
.map_err(|e| self.error(e, self.current))?;
|
||||
return Ok(match p {
|
||||
Primitive::Fontcharwd => metrics[0],
|
||||
Primitive::Fontcharht => metrics[1],
|
||||
@@ -85,13 +86,7 @@ impl Executor {
|
||||
}
|
||||
let slot = u8::try_from(slot)
|
||||
.map_err(|_| self.error("font character index must be in 0..255", self.current))?;
|
||||
let Some(m) = self
|
||||
.state
|
||||
.fonts
|
||||
.font(font)
|
||||
.map_err(|e| self.error(e, self.current))?
|
||||
.metrics()
|
||||
else {
|
||||
let Some(m) = instance.metrics() else {
|
||||
return Ok(0);
|
||||
};
|
||||
let c = char::from(slot);
|
||||
|
||||
@@ -131,6 +131,10 @@ impl Executor {
|
||||
};
|
||||
let italic = match paragraph.nodes.last() {
|
||||
Some(TextNode::Glyph { glyph, .. } | TextNode::MathChar(glyph)) => glyph.italic,
|
||||
Some(TextNode::OpenType(run)) if self.state.input_profile() == InputProfile::XeTeX => {
|
||||
run.glyphs.last().map_or(Ok(0), |glyph| run.font.italic_correction(glyph.id))
|
||||
.map_err(|error| self.error(error, self.current))?
|
||||
}
|
||||
_ => return Ok(()),
|
||||
};
|
||||
self.reads.insert(Dependency::FontResources);
|
||||
|
||||
Reference in new issue
Block a user