diff --git a/src/Surface.zig b/src/Surface.zig index 7fa51c268..046197ea2 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -1192,6 +1192,18 @@ pub fn scrollCallback( try self.queueRender(); } +pub fn contentScaleCallback(self: *Surface, content_scale: apprt.ContentScale) void { + const x_dpi = content_scale.x * font.face.default_dpi; + const y_dpi = content_scale.y * font.face.default_dpi; + const size = size: { + var size = self.font_size; + size.xdpi = @intFromFloat(x_dpi); + size.ydpi = @intFromFloat(y_dpi); + break :size size; + }; + self.setFontSize(size); +} + /// The type of action to report for a mouse event. const MouseReportAction = enum { press, release, motion }; diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index 75cfeeb3b..d0d70686a 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -349,6 +349,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 {