<div dir="ltr"><div>Pardon me for the may inaccurate following answer I have to write quickly,</div><div><br></div>> Assuming that I want to use GetFontData, what factors and aspects should I consider when deciding whether to create a single blob with<br>the entire font's data or to go for the hb_face_create_for_tables variety?<div><br></div><div>Whatever works, harfbuzz tries to work on the same memory to reduce memory usage</div><div><br></div><div>> Also, does HarfBuzz support TrueType Collection (TTC) files, and if so, does it want the data only for the currently selected font or all</div>of the data?<div><br></div><div>It does, if you want harfbuzz handles it for you, you should give it the full blob and set the index you like in second argument of hb_face_create, otherwise you should handle it yourself.</div><div><br></div><div>> 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.<br></div><div><br></div><div>Is it DirectWrite? Have you seen the helper we have the in hb-directwrite.h and hb-uniscribe.h? They can be very useful.</div><div><br></div><div>> 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? </div><div><br></div><div>Don't free it yourself specially if in use, you can use harfbuzz destroy callback so harfbuzz can handle it for you.</div><div><br></div><div>> 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?</div><div><br></div><div>Some of the objects may work with empty comparison but it is not broken face <a href="https://github.com/harfbuzz/harfbuzz/issues/1572">https://github.com/harfbuzz/harfbuzz/issues/1572</a> but something does it very accurately is hb_face_get_glyph_count</div><div><br></div><div>> Where do those 64.0 factors come from? </div><div><br></div><div>Subpixel accuracy, harfbuzz works with integers but as subpixel accuracy needed you have to we need to do some scaling. Scaling is not the pixels but _set_ppem and _set_ptem is (this is very inaccurate, but I hope would be useful)</div><div><br></div><div>> Or point me to the documentation where that is described, if I missed it?</div><div><br></div><div><a href="https://harfbuzz.github.io/">https://harfbuzz.github.io/</a> may address some of your issues<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 24, 2019 at 1:08 PM Eli Zaretskii <<a href="mailto:eliz@gnu.org">eliz@gnu.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Ping! Could someone please help me understand how the memory for the<br>
various HarfBuzz objects should be handled? Or point me to the<br>
documentation where that is described, if I missed it? Please??<br>
<br>
> Date: Sat, 18 May 2019 14:33:45 +0300<br>
> From: Eli Zaretskii <<a href="mailto:eliz@gnu.org" target="_blank">eliz@gnu.org</a>><br>
> Cc: <a href="mailto:harfbuzz@lists.freedesktop.org" target="_blank">harfbuzz@lists.freedesktop.org</a><br>
> <br>
> > Cc: <a href="mailto:behdad@behdad.org" target="_blank">behdad@behdad.org</a>, <a href="mailto:harfbuzz@lists.freedesktop.org" target="_blank">harfbuzz@lists.freedesktop.org</a><br>
> > From: Jonathan Kew <<a href="mailto:jfkthame@gmail.com" target="_blank">jfkthame@gmail.com</a>><br>
> > Date: Sat, 11 May 2019 22:15:46 +0100<br>
> > <br>
> > >> If you've got access to the font as a file or as a single buffer in<br>
> > >> memory, then wrapping the entire thing as a blob and handing it to<br>
> > >> hb_face_create will be simplest.<br>
> > > <br>
> > > Would wrapping in a blob the buffer returned by GetFontData be enough?<br>
> > <br>
> > If you use GetFontData to get the complete font as a single buffer (i.e. <br>
> > pass zero for the dwTable parameter), yes.<br>
> <br>
> I'm now working on the HarfBuzz font driver for Emacs on Windows using<br>
> GetFontData with the dwTable argument zero, to get the entire data of<br>
> the font. The question for which I cannot find an answer is regarding<br>
> the memory management of the font data I get from GetFontData. The<br>
> buffer into which I get the font data is malloc'ed. Then I create a<br>
> blob from that buffer using hb_blob_create, use that blob to create a<br>
> face with hb_face_create, and finally use the face to create a font<br>
> with hb_font_create. The result of hb_font_create I cache and use<br>
> thereafter each time I need to call hb_shape_full. But what about the<br>
> hb_blob_t and the hb_face_t objects created in the process -- does<br>
> their memory need to be freed in some manner after I have the<br>
> hb_font_t object, or do I have to keep them as long as hb_font_t is in<br>
> use? The question about the blob also directly affects whether I need<br>
> to keep around the buffer allocated for the GetFontData call, or can<br>
> it be freed once I have the hb_font_t object.<br>
> <br>
> Another question is about error handling. I see that hb_blob_create,<br>
> hb_face_create etc. return empty objects when they fail. But I see no<br>
> "is-empty" function or macro in the docs, did I miss something? If<br>
> not, how does one test for errors in a C program? I assumed that any<br>
> errors cause subsequent calls to fail, and so only checked the last<br>
> call to hb_font_create for errors -- is that correct?<br>
> <br>
> Thanks in advance for any help.<br>
_______________________________________________<br>
HarfBuzz mailing list<br>
<a href="mailto:HarfBuzz@lists.freedesktop.org" target="_blank">HarfBuzz@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/harfbuzz" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/harfbuzz</a></blockquote></div>