Update font DPI when the content scale is updated

This commit is contained in:
Mat
2023-09-02 13:00:04 -04:00
parent 4ae1f821d2
commit 0d094f244e
2 changed files with 11 additions and 0 deletions

View File

@@ -1192,6 +1192,15 @@ pub fn scrollCallback(
try self.queueRender();
}
pub fn contentScaleCallback(self: *Surface, content_scale: apprt.ContentScale) void {
var size = self.font_size;
const x_dpi = content_scale.x * font.face.default_dpi;
const y_dpi = content_scale.y * font.face.default_dpi;
size.xdpi = @intFromFloat(x_dpi);
size.ydpi = @intFromFloat(y_dpi);
self.setFontSize(size);
}
/// The type of action to report for a mouse event.
const MouseReportAction = enum { press, release, motion };

View File

@@ -348,6 +348,8 @@ pub const Surface = struct {
.x = @floatCast(x),
.y = @floatCast(y),
};
self.core_surface.contentScaleCallback(self.content_scale);
}
pub fn updateSize(self: *Surface, width: u32, height: u32) void {