-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[issue #2002] Ensure that absolute LineHeight
is always > 0.0
#2059
[issue #2002] Ensure that absolute LineHeight
is always > 0.0
#2059
Conversation
Awesome! The patch fixed the issue for me. |
Since this is a limitation of a dependency used in the renderers, I believe the fix should live there. |
Hmm, the panic is in /// Create a new [`Buffer`] with the provided [`FontSystem`] and [`Metrics`]
///
/// # Panics
///
/// Will panic if `metrics.line_height` is zero.
pub fn new(font_system: &mut FontSystem, metrics: Metrics) -> Self {
let mut buffer = Self::new_empty(metrics);
buffer.set_text(font_system, "", Attrs::new(), Shaping::Advanced);
buffer
} So it's the caller's responsibility ( Edit: I understand your concerns of course, but I think |
@joshuamegnauth54 For sure! I meant that the fix should live in |
Alright, that makes sense! I'll look into it soon. |
f8f051a
to
ef429fb
Compare
I updated the WGPU and Tiny Skia renders. Let me know if there's anything else I should do. |
Okay, so I moved the LineHeight logic to allocate and removed the previous checks. Everything still works! |
tiny_skia/src/text.rs
Outdated
key.line_height, | ||
(key.line_height * 1.2).max(f32::MIN_POSITIVE), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost! This should look the same as the wgpu
code:
key.line_height, | |
(key.line_height * 1.2).max(f32::MIN_POSITIVE), | |
key.size, | |
key.line_height.max(f32::MIN_POSITIVE), |
You can test the tiny-skia
backend by setting the ICED_BACKEND=tiny-skia
env variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I just committed the requested changes.
Also, I've been recompiling iced
with default-features=false
to test Tiny Skia. 😅 That env var is very helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks.
Fixes #2002.
The gist of the problem is that LineHeight::to_absolute in conjunction with other widgets may inadvertently return
0.0
. This triggers a panic in cosmic_text's Buffer regardless of the renderer.The original issue has a minimal example. My patch just ensures that absolute LineHeight is > 0.0 to avoid the panic.