ElyPDF: a document font that cannot take new text asks for another font (P-06)
This commit is contained in:
11 files changed
+144
-23
No files matched your search
@@ -59,6 +59,8 @@ pub enum Wrote {
|
||||
Done,
|
||||
/// A character the font cannot draw; nothing changed.
|
||||
Missing(char),
|
||||
/// The document's own font cannot write; nothing changed.
|
||||
Unwritable,
|
||||
/// The would-be result: BGRA, size, and whether it grew.
|
||||
Preview(Vec<u8>, (u32, u32), bool),
|
||||
}
|
||||
@@ -106,6 +108,9 @@ impl Mupdf {
|
||||
&mut height,
|
||||
)
|
||||
})?;
|
||||
if status == 3 {
|
||||
return Ok(Wrote::Unwritable);
|
||||
}
|
||||
if status == 2 {
|
||||
let missing = u32::try_from(missing).ok().and_then(char::from_u32);
|
||||
return Ok(Wrote::Missing(missing.ok_or_else(|| io::Error::other("a missing glyph out of range"))?));
|
||||
|
||||
@@ -147,6 +147,7 @@ impl Worker {
|
||||
Ok(match wrote? {
|
||||
content::Wrote::Done => Pack::new().u64(0).str(&doc.mark()).bytes(),
|
||||
content::Wrote::Missing(c) => Pack::new().u64(2).u64(u64::from(c)).bytes(),
|
||||
content::Wrote::Unwritable => Pack::new().u64(3).bytes(),
|
||||
content::Wrote::Preview(pixels, (w, h), grew) => {
|
||||
Pack::new().u64(1).u64(u64::from(w)).u64(u64::from(h)).u64(u64::from(grew)).blob(&pixels).bytes()
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ pub enum Wrote {
|
||||
Done(String),
|
||||
/// The font lacks this character; nothing changed.
|
||||
Missing(char),
|
||||
/// The document's own font cannot write; nothing changed.
|
||||
Unwritable,
|
||||
/// BGRA of the area, its size, whether text grew.
|
||||
Preview(Vec<u8>, (u32, u32), bool),
|
||||
}
|
||||
@@ -113,11 +115,13 @@ impl Worker {
|
||||
let code = u32::try_from(reply.u64()?).map_err(io::Error::other)?;
|
||||
Ok(Wrote::Missing(char::from_u32(code).ok_or_else(|| io::Error::other("a bad missing glyph"))?))
|
||||
}
|
||||
_ => {
|
||||
1 => {
|
||||
let size = (reply.u64()? as u32, reply.u64()? as u32);
|
||||
let grew = reply.u64()? != 0;
|
||||
Ok(Wrote::Preview(reply.blob()?, size, grew))
|
||||
}
|
||||
3 => Ok(Wrote::Unwritable),
|
||||
other => Err(io::Error::other(format!("a text reply of kind {other}"))),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user