[HarfBuzz] How to get hb_face_t and hb_font_t without Freetype?

Jonathan Kew jfkthame at gmail.com
Sat May 11 19:11:17 UTC 2019

On 11/05/2019 19:51, Behdad Esfahbod wrote:
> On Sat, May 11, 2019 at 11:50 AM Eli Zaretskii <eliz at gnu.org 
> <mailto:eliz at gnu.org>> wrote:
>      > From: Behdad Esfahbod <behdad at behdad.org <mailto:behdad at behdad.org>>
>      > Date: Sat, 11 May 2019 11:38:58 -0700
>      > Cc: Jonathan Kew <jfkthame at gmail.com <mailto:jfkthame at gmail.com>>,
>      >       "harfbuzz at lists.freedesktop.org
>     <mailto:harfbuzz at lists.freedesktop.org>"
>     <harfbuzz at lists.freedesktop.org <mailto:harfbuzz at lists.freedesktop.org>>
>      >
>      > The blob simply hold the font file bytes.  There's even
>     hb_blob_create_from_file.
>      >
>      > Makes sense?
>     Not sure yet.  What is a "font" for this purpose?  Does it have to be
>     the full contents of a font file on disk?
> Yes. The font file.  Maybe describe what you are trying to do?

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.

In a case where you don't necessarily have easy access to the complete 
font file, but have platform APIs that you can use to retrieve specific 
font tables (like IDWriteFontFace::TryGetFontTable on Windows, or 
CGFontCopyTableForTag on macOS), that's where you might prefer to use 
hb_face_create_for_tables (like Firefox does). This expects you to 
provide a reference_table_func that will return a blob containing the 
data of any given font table (identified by its 32-bit OpenType table tag).


More information about the HarfBuzz mailing list