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

Jonathan Kew jfkthame at gmail.com
Sat May 11 10:08:42 UTC 2019


On 11/05/2019 10:39, Eli Zaretskii wrote:
> Is it possible to create a hb_face_t without going through Freetype?
> If so, could someone please tell what that would entail?

You can use hb_face_create_for_tables, passing it a function that can 
retrieve font tables (as hb_blobs) when requested by harfbuzz.

This is what Firefox does, to use harfbuzz with Windows or MacOS font 
APIs; a starting point to explore the Firefox code would be [1], where 
we call hb_face_create_for_tables and pass it HBGetTable as the 
reference_table_func. This calls down to the GetFontTable() method, 
which has separate implementations for the various platforms.

JK

[1] 
https://searchfox.org/mozilla-central/rev/b418634cb3fe83ebb8d2c019cc1ba76974da1a0d/gfx/thebes/gfxFontEntry.cpp#587

> 
> The tutorial only shows how to create hb_font_t using Freetype, and I
> found no other documentation related to this, except the functions'
> signatures.  The implementations of hb_ft_face_create and
> hb_ft_face_create look deceptively simple, so maybe it wouldn't be
> hard to implement something similar without going through Freetype.
> But the question is what is needed from the data stashed away by
> hb_blob_create, and where is that data used?  I guess there are some
> callbacks specific to Freetype which the HarfBuzz shaper needs, and
> those callbacks need to access the blob data?  But none of that seems
> to be documented.
> 
> Could someone please post some information about these issues, or
> point me to existing documentation if I missed it?
> 
> The context for these questions is WIP to add a HarfBuzz shaping
> capabilities to Emacs on MS-Windows.  The existing HarfBuzz
> integration, for Posix platforms, uses Freetype, because Freetype is
> already used by Emacs on Posix systems to access font capabilities.
> But on Windows Emacs uses native Windows interfaces to access and
> utilize font and text metrics data, so going through Freetype would
> probably add interfaces whose equivalents already exist.  The question
> is how to use those equivalents to give HarfBuzz what it needs.
> 
> TIA
> _______________________________________________
> HarfBuzz mailing list
> HarfBuzz at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/harfbuzz
> 



More information about the HarfBuzz mailing list