This commit is contained in:
Simon Gardling 2023-08-30 09:32:40 -04:00
parent 0800b94c9f
commit 346c9ee267
2 changed files with 11 additions and 2 deletions

View File

@ -28,6 +28,7 @@ fn font_stripper(from: &str, out: &str, unicodes: Vec<char>) -> Result<Vec<u8>,
.collect::<Vec<String>>() .collect::<Vec<String>>()
.join(","); .join(",");
// Test to see if pyftsubset is found
let pyftsubset_detect = run_script::run("whereis pyftsubset", &(vec![]), &ScriptOptions::new()); let pyftsubset_detect = run_script::run("whereis pyftsubset", &(vec![]), &ScriptOptions::new());
match pyftsubset_detect { match pyftsubset_detect {
Ok((_i, s1, _s2)) => { Ok((_i, s1, _s2)) => {
@ -35,9 +36,11 @@ fn font_stripper(from: &str, out: &str, unicodes: Vec<char>) -> Result<Vec<u8>,
return Err(String::from("pyftsubset not found")); return Err(String::from("pyftsubset not found"));
} }
} }
// It was not, return an error and abort
Err(x) => return Err(x.to_string()), Err(x) => return Err(x.to_string()),
} }
let script_result = run_script::run( let script_result = run_script::run(
&format!( &format!(
"pyftsubset {}/assets/{} --unicodes={} "pyftsubset {}/assets/{} --unicodes={}

View File

@ -29,7 +29,7 @@ pub fn split_function(input: &str, split: SplitType) -> Vec<String> {
.collect::<Vec<String>>() .collect::<Vec<String>>()
} }
#[derive(PartialEq, Debug)] #[derive(PartialEq, Debug, Copy, Clone)]
pub enum SplitType { pub enum SplitType {
Multiplication, Multiplication,
Term, Term,
@ -279,7 +279,7 @@ include!(concat!(env!("OUT_DIR"), "/codegen.rs"));
#[cfg(test)] #[cfg(test)]
fn assert_test(input: &str, expected: &[&str], split: SplitType) { fn assert_test(input: &str, expected: &[&str], split: SplitType) {
let output = split_function("sin(x)cos(x)", SplitType::Multiplication); let output = split_function(input, split);
let expected_owned = expected let expected_owned = expected
.iter() .iter()
.map(|&x| x.to_owned()) .map(|&x| x.to_owned())
@ -305,4 +305,10 @@ fn split_function_test() {
&["tanh(cos(x)", "x", "x)", "cos(x)"], &["tanh(cos(x)", "x", "x)", "cos(x)"],
SplitType::Multiplication, SplitType::Multiplication,
); );
assert_test(
"tanh(sin(cos(x)xsin(x)))",
&["tanh(sin(cos(x)", "x", "sin(x)))"],
SplitType::Multiplication,
);
} }