[HarfBuzz] How to get hb_face_t and hb_font_t without Freetype?
eliz at gnu.org
Fri May 24 08:38:55 UTC 2019
Ping! Could someone please help me understand how the memory for the
various HarfBuzz objects should be handled? Or point me to the
documentation where that is described, if I missed it? Please??
> Date: Sat, 18 May 2019 14:33:45 +0300
> From: Eli Zaretskii <eliz at gnu.org>
> Cc: harfbuzz at lists.freedesktop.org
> > Cc: behdad at behdad.org, harfbuzz at lists.freedesktop.org
> > From: Jonathan Kew <jfkthame at gmail.com>
> > Date: Sat, 11 May 2019 22:15:46 +0100
> > >> If you've got access to the font as a file or as a single buffer in
> > >> memory, then wrapping the entire thing as a blob and handing it to
> > >> hb_face_create will be simplest.
> > >
> > > Would wrapping in a blob the buffer returned by GetFontData be enough?
> > If you use GetFontData to get the complete font as a single buffer (i.e.
> > pass zero for the dwTable parameter), yes.
> I'm now working on the HarfBuzz font driver for Emacs on Windows using
> GetFontData with the dwTable argument zero, to get the entire data of
> the font. The question for which I cannot find an answer is regarding
> the memory management of the font data I get from GetFontData. The
> buffer into which I get the font data is malloc'ed. Then I create a
> blob from that buffer using hb_blob_create, use that blob to create a
> face with hb_face_create, and finally use the face to create a font
> with hb_font_create. The result of hb_font_create I cache and use
> thereafter each time I need to call hb_shape_full. But what about the
> hb_blob_t and the hb_face_t objects created in the process -- does
> their memory need to be freed in some manner after I have the
> hb_font_t object, or do I have to keep them as long as hb_font_t is in
> use? The question about the blob also directly affects whether I need
> to keep around the buffer allocated for the GetFontData call, or can
> it be freed once I have the hb_font_t object.
> Another question is about error handling. I see that hb_blob_create,
> hb_face_create etc. return empty objects when they fail. But I see no
> "is-empty" function or macro in the docs, did I miss something? If
> not, how does one test for errors in a C program? I assumed that any
> errors cause subsequent calls to fail, and so only checked the last
> call to hb_font_create for errors -- is that correct?
> Thanks in advance for any help.
More information about the HarfBuzz