diff --git a/fonts.d b/fonts.d index 44d82c8..c56f05c 100644 --- a/fonts.d +++ b/fonts.d @@ -103,10 +103,12 @@ CreateAtlas(Arena* arena, FontFace font, f32 size, u32 dimension, bool y_origin_ // TODO: proper packing algorithm if(font != null) { + FT_Set_Pixel_Sizes(font, 0, cast(FT_UInt)((96.0f/72.0f) * size)); + i64 bbox_ymax = font.bbox.yMax >> 6; i64 bbox_ymin = font.bbox.yMin >> 6; - abuf.atlas.line_height = cast(f32)(bbox_ymax - bbox_ymin); + abuf.atlas.line_height = size; abuf.atlas.units_per_em = cast(f32)font.units_per_EM; abuf.atlas.ascent = cast(f32)font.ascender; abuf.atlas.descent = cast(f32)font.descender; @@ -119,7 +121,6 @@ CreateAtlas(Arena* arena, FontFace font, f32 size, u32 dimension, bool y_origin_ foreach(FT_ULong char_code; 0 .. 0x7F) { - FT_Set_Char_Size(font, font_size, 0, 0, 0); FT_Error res = FT_Load_Char(font, char_code, cast(FT_Int32)FT_LOAD_RENDER); if(res != 0) { @@ -150,7 +151,6 @@ CreateAtlas(Arena* arena, FontFace font, f32 size, u32 dimension, bool y_origin_ foreach(FT_ULong char_code; 0 .. 0x7F) { - FT_Set_Char_Size(font, font_size, 0, 0, 0); FT_Error res = FT_Load_Char(font, char_code, cast(FT_Int32)FT_LOAD_RENDER); if(res != 0) {