[HarfBuzz] How to get hb_face_t and hb_font_t without Freetype?
Ebrahim Byagowi
ebraminio at gmail.com
Fri May 24 15:43:43 UTC 2019
Pardon me for the may inaccurate following answer I have to write quickly,
> Assuming that I want to use GetFontData, what factors and aspects should
I consider when deciding whether to create a single blob with
the entire font's data or to go for the hb_face_create_for_tables variety?
Whatever works, harfbuzz tries to work on the same memory to reduce memory
usage
> Also, does HarfBuzz support TrueType Collection (TTC) files, and if so,
does it want the data only for the currently selected font or all
of the data?
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.
> 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.
Is it DirectWrite? Have you seen the helper we have the in hb-directwrite.h
and hb-uniscribe.h? They can be very useful.
> 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?
Don't free it yourself specially if in use, you can use harfbuzz destroy
callback so harfbuzz can handle it for you.
> 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?
Some of the objects may work with empty comparison but it is not broken
face https://github.com/harfbuzz/harfbuzz/issues/1572 but something does it
very accurately is hb_face_get_glyph_count
> Where do those 64.0 factors come from?
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)
> Or point me to the documentation where that is described, if I missed it?
https://harfbuzz.github.io/ may address some of your issues
On Fri, May 24, 2019 at 1:08 PM Eli Zaretskii <eliz at gnu.org> wrote:
> 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.
> _______________________________________________
> HarfBuzz mailing list
> HarfBuzz at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/harfbuzz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/harfbuzz/attachments/20190524/daf398db/attachment.html>
More information about the HarfBuzz
mailing list