Skip to content

Commit

Permalink
Make tiny_skia_render output location invariant of CWD
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed May 22, 2024
1 parent 03a93f5 commit b57544f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
/examples/_output
16 changes: 14 additions & 2 deletions examples/tiny_skia_render/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
//! A simple example that lays out some text using Parley, extracts outlines using Skrifa and
//! then paints those outlines using Tiny-Skia.
use std::path::PathBuf;

use parley::layout::{Alignment, GlyphRun, Layout};
use parley::style::{FontStack, FontWeight, StyleProperty};
use parley::{FontContext, LayoutContext};
Expand Down Expand Up @@ -94,8 +96,18 @@ fn main() {
}
}

// Write image to PNG file
img.save_png("output.png").unwrap();
// Write image to PNG file in examples/_output dir
let output_path: PathBuf = {
let path = std::path::PathBuf::from(file!());
let mut path = std::fs::canonicalize(path).unwrap();
path.pop();
path.pop();
path.push("_output");
let _ = std::fs::create_dir(path.clone());
path.push("tiny_skia_render.png");
path
};
img.save_png(output_path).unwrap();
}

fn to_tiny_skia(color: PenikoColor) -> TinySkiaColor {
Expand Down

0 comments on commit b57544f

Please sign in to comment.