[HarfBuzz] How to get hb_face_t and hb_font_t without Freetype?
jfkthame at gmail.com
Sat May 11 21:15:46 UTC 2019
On 11/05/2019 20:38, Eli Zaretskii wrote:
>> Cc: Behdad Esfahbod <behdad at behdad.org>,
>> "harfbuzz at lists.freedesktop.org" <harfbuzz at lists.freedesktop.org>
>> From: Jonathan Kew <jfkthame at gmail.com>
>> Date: Sat, 11 May 2019 20:11:17 +0100
>>> 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.
> 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.
Alternatively, you could use hb_face_create_for_tables, with a
reference_table_func that uses GetFontData to read individual tables
when harfbuzz asks for them.
>> 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).
> So there should be a function for each of the OpenType table tag, each
> function returning a pointer to the table's data?
There's a single reference_table_func that is passed a table tag and
returns a blob for the requested table. How that reference_table_func is
implemented is up to you, depending on what the platform provides; in
practice, most platforms offer a single function that similarly accepts
a table tag and returns that table.
More information about the HarfBuzz