Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default to a line height of 1.2 #756

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is surprising to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This moved in the opposite direction compared to the rest of the items in this PR. I wonder if this has anything to do with the alignment handling within textbox. Maybe padding only being counted once instead of both top and bottom?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at it again, it looks like the top line in all of the examples dropped, so I think this is fine.

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