Shape and render explicit OpenType fonts in native Unicode jobs
This commit is contained in:
1 parent
3caf1eced2
commit
70822cbd94
33 files changed
+1255
-80
No files matched your search
@@ -70,6 +70,19 @@ 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 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]);
|
||||
return Ok(match p {
|
||||
Primitive::Fontcharwd => metrics[0],
|
||||
Primitive::Fontcharht => metrics[1],
|
||||
Primitive::Fontchardp => metrics[2],
|
||||
Primitive::Fontcharic => metrics[3],
|
||||
_ => unreachable!(),
|
||||
} as i32);
|
||||
}
|
||||
let slot = u8::try_from(slot)
|
||||
.map_err(|_| self.error("font character index must be in 0..255", self.current))?;
|
||||
let Some(m) = self
|
||||
|
||||
Reference in new issue
Block a user