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

@@ -407,7 +407,7 @@ test "fontconfig" {
const alloc = testing.allocator;
// Load freetype
var lib = try Library.init();
var lib = try Library.init(alloc);
defer lib.deinit();
// Get a deferred face from fontconfig
@@ -437,7 +437,7 @@ test "coretext" {
const alloc = testing.allocator;
// Load freetype
var lib = try Library.init();
var lib = try Library.init(alloc);
defer lib.deinit();
// Get a deferred face from fontconfig