From be565d17141818e006aa1e4582f3ae14c726fa85 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Fri, 24 Jun 2016 11:42:01 +0430 Subject: [PATCH] [dwrite] Release allocated blob on face destroy This reduces memory consumption of my iterated font create/destroy cycle test significantly and makes it much better than uniscribe backend even --- src/hb-directwrite.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hb-directwrite.cc b/src/hb-directwrite.cc index c6fac4d30..a74e31833 100644 --- a/src/hb-directwrite.cc +++ b/src/hb-directwrite.cc @@ -134,6 +134,7 @@ struct hb_directwrite_shaper_face_data_t { IDWriteFontFile* fontFile; IDWriteFontFileLoader* fontFileLoader; IDWriteFontFace* fontFace; + hb_blob_t* faceBlob; }; hb_directwrite_shaper_face_data_t * @@ -153,7 +154,7 @@ _hb_directwrite_shaper_face_data_create(hb_face_t *face) ); HRESULT hr; - hb_blob_t* blob = hb_face_reference_blob (face); + hb_blob_t *blob = hb_face_reference_blob (face); IDWriteFontFileStream *fontFileStream = new DWriteFontFileStream ( (uint8_t*) hb_blob_get_data (blob, NULL), hb_blob_get_length (blob)); @@ -196,6 +197,7 @@ _hb_directwrite_shaper_face_data_create(hb_face_t *face) data->fontFile = fontFile; data->fontFileLoader = fontFileLoader; data->fontFace = fontFace; + data->faceBlob = blob; return data; } @@ -205,6 +207,7 @@ _hb_directwrite_shaper_face_data_destroy(hb_directwrite_shaper_face_data_t *data { data->dwriteFactory->UnregisterFontFileLoader (data->fontFileLoader); delete data->fontFileLoader; + hb_blob_destroy (data->faceBlob); free (data); }