font/freetype: introduce mutexes to ensure thread safety of Library and Face

For details see comments and FreeType docs @
https://freetype.org/freetype2/docs/reference/ft2-library_setup.html#ft_library
https://freetype.org/freetype2/docs/reference/ft2-face_creation.html#ft_face

tl;dr: FT_New_Face and FT_Done_Face require the Library to be locked for
thread safety, and FT_Load_Glyph and FT_Render_Glyph and friends need
the face to be locked for thread safety, since we're sharing faces
across threads.
This commit is contained in:
Qwerasd
2025-04-30 14:02:46 -06:00
parent e79bf71f23
commit cfedd477b2
11 changed files with 115 additions and 53 deletions

View File

@@ -50,7 +50,7 @@ pub const InitError = Library.InitError;
/// Initialize a new SharedGridSet.
pub fn init(alloc: Allocator) InitError!SharedGridSet {
var font_lib = try Library.init();
var font_lib = try Library.init(alloc);
errdefer font_lib.deinit();
return .{