Skip to content

Commit

Permalink
Default to a line height of 1.2 (#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
DJMcNab authored Nov 26, 2024
1 parent af96e78 commit 15c0a55
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 14 deletions.
17 changes: 10 additions & 7 deletions masonry/src/testing/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,16 +666,19 @@ impl TestHarness {
// TODO: If this file is corrupted, it could be an lfs bandwidth/installation issue.
// Have a warning for that case (i.e. differentiation between not-found and invalid format)
// and a environment variable to ignore the test in that case.
if let Ok(reference_file) = ImageReader::open(reference_path) {
if let Ok(reference_file) = ImageReader::open(&reference_path) {
let ref_image = reference_file.decode().unwrap().to_rgb8();

if let Some(diff_image) = get_image_diff(&ref_image, &new_image.to_rgb8()) {
// Remove '<test_name>.new.png' '<test_name>.diff.png' files if they exist
let _ = std::fs::remove_file(&new_path);
let _ = std::fs::remove_file(&diff_path);
new_image.save(&new_path).unwrap();
diff_image.save(&diff_path).unwrap();
panic!("Snapshot test '{test_name}' failed: Images are different");
if std::env::var_os("MASONRY_TEST_BLESS").is_some_and(|it| !it.is_empty()) {
let _ = std::fs::remove_file(&new_path);
let _ = std::fs::remove_file(&diff_path);
new_image.save(&reference_path).unwrap();
} else {
new_image.save(&new_path).unwrap();
diff_image.save(&diff_path).unwrap();
panic!("Snapshot test '{test_name}' failed: Images are different");
}
} else {
// Remove the vestigial new and diff images
let _ = std::fs::remove_file(&new_path);
Expand Down
4 changes: 4 additions & 0 deletions masonry/src/text/styleset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ impl<Brush: parley::Brush> StyleSet<Brush> {
pub fn new(font_size: f32) -> Self {
let mut this = Self(Default::default());
this.insert(StyleProperty::FontSize(font_size));
// Emulate: https://developer.mozilla.org/en-US/docs/Web/CSS/line-height#normal
// This is a more sensible default that Parley's default.
// We expect Parley to make a different choice here at some point?
this.insert(StyleProperty::LineHeight(1.2));
this
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 15c0a55

Please sign in to comment.