Function glifparser::read_pedantic
source · pub fn read_pedantic<PD: PointData>(
glif: &str,
pedantry: Pedantry
) -> Result<Glif<PD>, GlifParserError>Examples found in repository?
src/glif/read.rs (line 59)
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
pub fn read_ufo_glif_from_filename_pedantic<F: AsRef<path::Path> + Clone, PD: PointData>(filename: F, pedantry: Pedantry) -> Result<Glif<PD>, GlifParserError> {
let glifxml = match fs::read_to_string(&filename) {
Ok(s) => s,
Err(ioe) => Err(GlifParserError::GlifFileIoError(Some(Rc::new(ioe))))?
};
let mut glif: Glif<PD> = read_ufo_glif_pedantic(&glifxml, pedantry)?;
let filenamepb = filename.as_ref().to_path_buf();
for component in glif.components.vec.iter_mut() {
component.set_file_name(&filenamepb);
}
glif.filename = Some(filenamepb);
Ok(glif)
}
/// Read UFO .glif XML to Glif struct. This should only be used when you have no known filename,
/// and the glif is unattached from a UFO.
pub fn read_ufo_glif<PD: PointData>(glif: &str) -> Result<Glif<PD>, GlifParserError> {
read_ufo_glif_pedantic(glif, Pedantry::default())
}