From 079fe7bc949b59646699c1053a589fc4f1fa2e63 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 30 Jun 2023 14:13:40 -0700 Subject: [PATCH] coretext: the size needs to be in pixels! (see comment) --- src/font/face/coretext.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/font/face/coretext.zig b/src/font/face/coretext.zig index 3de6f6964..39d5987be 100644 --- a/src/font/face/coretext.zig +++ b/src/font/face/coretext.zig @@ -41,8 +41,10 @@ pub const Face = struct { /// because the font is loaded at a default size during discovery, and then /// adjusted to the final size for final load. pub fn initFontCopy(base: *macos.text.Font, size: font.face.DesiredSize) !Face { - // Create a copy - const ct_font = try base.copyWithAttributes(@floatFromInt(size.points), null); + // Create a copy. The copyWithAttributes docs say the size is in points, + // but we need to scale the points by the DPI and to do that we use our + // function called "pixels". + const ct_font = try base.copyWithAttributes(@floatFromInt(size.pixels()), null); errdefer ct_font.release(); var hb_font = try harfbuzz.coretext.createFont(ct_font);