Merge pull request #385 from mgeist/update-font-dpi

Update font DPI when the content scale is updated
This commit is contained in:
Mitchell Hashimoto
2023-09-02 10:41:07 -07:00
committed by GitHub
2 changed files with 14 additions and 0 deletions

View File

@ -1192,6 +1192,18 @@ pub fn scrollCallback(
try self.queueRender(); 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. /// The type of action to report for a mouse event.
const MouseReportAction = enum { press, release, motion }; const MouseReportAction = enum { press, release, motion };

View File

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