Skip to content

Commit

Permalink
remove embolden for macos and fix scale changes updates
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Jun 1, 2024
1 parent ab699f8 commit ed882c8
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
7 changes: 6 additions & 1 deletion frontends/rioterm/src/screen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,12 @@ impl Screen {
) -> &mut Self {
self.sugarloaf.rescale(new_scale);
self.sugarloaf.resize(new_size.width, new_size.height);
self.resize_all_contexts();
self.render();

if self.sugarloaf.dimensions_changed() {
self.resize_all_contexts();
}

self
}

Expand Down
9 changes: 5 additions & 4 deletions frontends/rioterm/src/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,10 +1028,11 @@ impl Sequencer {
..
} => {
if let Some(route) = self.router.routes.get_mut(&window_id) {
route.window.screen.set_scale(
scale_factor as f32,
route.window.winit_window.inner_size(),
);
let scale = scale_factor as f32;
route
.window
.screen
.set_scale(scale, route.window.winit_window.inner_size());
route.redraw();
}
}
Expand Down
4 changes: 2 additions & 2 deletions sugarloaf/src/components/rich_text/image_cache/glyph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ impl<'a> GlyphCacheSession<'a> {
}
}
self.scaled_image.data.clear();
let embolden = if IS_MACOS { 0.25 } else { 0. };
// let embolden = if IS_MACOS { 0.25 } else { 0. };
if Render::new(SOURCES)
.format(Format::CustomSubpixel([0.3, 0., -0.3]))
.offset(Vector::new(subpx[0].to_f32(), subpx[1].to_f32()))
.embolden(embolden)
// .embolden(embolden)
.render_into(&mut self.scaler, id, self.scaled_image)
{
let p = self.scaled_image.placement;
Expand Down
5 changes: 5 additions & 0 deletions sugarloaf/src/layout/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ impl LayoutContext {
cache: &mut self.cache,
}
}

#[inline]
pub fn clear_cache(&mut self) {
self.cache.inner.clear();
}
}

/// Builder for computing the layout of a paragraph.
Expand Down
4 changes: 3 additions & 1 deletion sugarloaf/src/sugarloaf/compositors/advanced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ impl Advanced {
}

pub fn reset(&mut self) {}
pub fn clean(&mut self) {}
pub fn clean(&mut self) {
self.layout_context.clear_cache();
}

#[inline]
pub fn font_library(&self) -> &FontLibrary {
Expand Down
3 changes: 3 additions & 0 deletions sugarloaf/src/sugarloaf/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ impl SugarState {

#[inline]
pub fn compute_layout_rescale(&mut self, scale: f32) {
// In rescale case, we actually need to clean cache from the compositors
// because it's based on sugarline hash which only consider the font size
self.compositors.advanced.clean();
self.next.layout.rescale(scale).update();
}

Expand Down

1 comment on commit ed882c8

@fabiomcosta
Copy link

Choose a reason for hiding this comment

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

is this what improved the rendering quality on MacOS?

Please sign in to comment.