diff --git a/gfx/drivers_font/metal_raster_font.m b/gfx/drivers_font/metal_raster_font.m index 4e0b2dc04f..fd27733311 100644 --- a/gfx/drivers_font/metal_raster_font.m +++ b/gfx/drivers_font/metal_raster_font.m @@ -50,6 +50,7 @@ @property (readonly) struct font_atlas *atlas; +- (void)deinit; - (instancetype)initWithDriver:(MetalDriver *)driver fontPath:(const char *)font_path fontSize:(unsigned)font_size; - (int)getWidthForMessage:(const char *)msg length:(NSUInteger)length scale:(float)scale; @@ -58,6 +59,12 @@ @implementation MetalRaster +- (void)deinit +{ + if (_font_driver && _font_data) + _font_driver->free(_font_data); +} + - (instancetype)initWithDriver:(MetalDriver *)driver fontPath:(const char *)font_path fontSize:(unsigned)font_size { if (self = [super init]) @@ -511,6 +518,8 @@ static void *metal_raster_font_init_font(void *data, static void metal_raster_font_free_font(void *data, bool is_threaded) { MetalRaster *r = (__bridge_transfer MetalRaster *)data; + + [r deinit]; r = nil; }