Skip to content

Commit

Permalink
[write-fonts] Improve error docs
Browse files Browse the repository at this point in the history
The main motivation here was to provide more information about how to
debug a packing error.
  • Loading branch information
cmyr committed Aug 29, 2023
1 parent 3538a7a commit 8ad1d6c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions write-fonts/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ use std::sync::Arc;
use crate::{graph::Graph, validate::ValidationReport};

/// A packing could not be found that satisfied all offsets
///
/// If the "dot2" feature is enabled, you can use the `write_graph_viz` method
/// on this error to dump a text representation of the graph to disk. You can
/// then use graphviz to convert this into an image. For example, to create
/// an SVG, you might use, `dot -v -Tsvg failure.dot2 > failure.svg`, where
/// 'failure.dot2' is the path where you dumped the graph.
#[derive(Clone)]
pub struct PackingError {
// this is Arc so that we can clone and still be sent between threads.
Expand All @@ -14,7 +20,17 @@ pub struct PackingError {
/// An error occured while writing this table
#[derive(Debug, Clone)]
pub enum Error {
/// The table failed a validation check
///
/// This indicates that the table contained invalid or inconsistent data
/// (for instance, it had an explicit version set, but contained fields
/// not present in that version).
ValidationFailed(ValidationReport),
/// The table contained overflowing offsets
///
/// This indicates that an ordering could not be found that allowed all
/// tables to be reachable from their parents. See [`PackingError`] for
/// more details.
PackingFailed(PackingError),
}

Expand Down

0 comments on commit 8ad1d6c

Please sign in to comment.