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

[issue #2002] Ensure that absolute LineHeight is always > 0.0 #2059

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 10 additions & 4 deletions tiny_skia/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ impl Pipeline {
pixels: &mut tiny_skia::PixmapMut<'_>,
clip_mask: Option<&tiny_skia::Mask>,
) {
let line_height = f32::from(line_height.to_absolute(Pixels(size)));
let line_height = f32::from(line_height.to_absolute(Pixels(size)))
.max(f32::MIN_POSITIVE);
hecrj marked this conversation as resolved.
Show resolved Hide resolved

let font_system = self.font_system.get_mut();
let key = Key {
Expand Down Expand Up @@ -134,7 +135,8 @@ impl Pipeline {
) -> Size {
let mut measurement_cache = self.cache.borrow_mut();

let line_height = f32::from(line_height.to_absolute(Pixels(size)));
let line_height = f32::from(line_height.to_absolute(Pixels(size)))
.max(f32::MIN_POSITIVE);

let (_, entry) = measurement_cache.allocate(
&mut self.font_system.borrow_mut(),
Expand Down Expand Up @@ -164,7 +166,8 @@ impl Pipeline {
) -> Option<Hit> {
let mut measurement_cache = self.cache.borrow_mut();

let line_height = f32::from(line_height.to_absolute(Pixels(size)));
let line_height = f32::from(line_height.to_absolute(Pixels(size)))
.max(f32::MIN_POSITIVE);

let (_, entry) = measurement_cache.allocate(
&mut self.font_system.borrow_mut(),
Expand Down Expand Up @@ -405,7 +408,10 @@ impl Cache {
}

if let hash_map::Entry::Vacant(entry) = self.entries.entry(hash) {
let metrics = cosmic_text::Metrics::new(key.size, key.size * 1.2);
let metrics = cosmic_text::Metrics::new(
key.size,
(key.size * 1.2).max(f32::MIN_POSITIVE),
hecrj marked this conversation as resolved.
Show resolved Hide resolved
);
let mut buffer = cosmic_text::Buffer::new(font_system, metrics);

buffer.set_size(
Expand Down
9 changes: 6 additions & 3 deletions wgpu/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ impl Pipeline {
section
.line_height
.to_absolute(Pixels(section.size)),
),
)
.max(f32::MIN_POSITIVE),
font: section.font,
bounds: Size {
width: section.bounds.width,
Expand Down Expand Up @@ -238,7 +239,8 @@ impl Pipeline {
) -> Size {
let mut cache = self.cache.borrow_mut();

let line_height = f32::from(line_height.to_absolute(Pixels(size)));
let line_height = f32::from(line_height.to_absolute(Pixels(size)))
.max(f32::MIN_POSITIVE);

let (_, entry) = cache.allocate(
&mut self.font_system.borrow_mut(),
Expand Down Expand Up @@ -269,7 +271,8 @@ impl Pipeline {
) -> Option<Hit> {
let mut cache = self.cache.borrow_mut();

let line_height = f32::from(line_height.to_absolute(Pixels(size)));
let line_height = f32::from(line_height.to_absolute(Pixels(size)))
.max(f32::MIN_POSITIVE);

let (_, entry) = cache.allocate(
&mut self.font_system.borrow_mut(),
Expand Down