[machinery] Add "core table" machinery

To be used in subsequent commit; or tried anyway.
This commit is contained in:
Behdad Esfahbod 2022-02-15 17:33:52 -06:00
parent 67eb9acf79
commit 2a430790ad
3 changed files with 22 additions and 5 deletions

View File

@ -273,14 +273,19 @@ struct hb_face_lazy_loader_t : hb_lazy_loader_t<T,
hb_face_lazy_loader_t<T, WheresFace>, hb_face_lazy_loader_t<T, WheresFace>,
hb_face_t, WheresFace> {}; hb_face_t, WheresFace> {};
template <typename T, unsigned int WheresFace> template <typename T, unsigned int WheresFace, bool core=false>
struct hb_table_lazy_loader_t : hb_lazy_loader_t<T, struct hb_table_lazy_loader_t : hb_lazy_loader_t<T,
hb_table_lazy_loader_t<T, WheresFace>, hb_table_lazy_loader_t<T, WheresFace, core>,
hb_face_t, WheresFace, hb_face_t, WheresFace,
hb_blob_t> hb_blob_t>
{ {
static hb_blob_t *create (hb_face_t *face) static hb_blob_t *create (hb_face_t *face)
{ return hb_sanitize_context_t ().reference_table<T> (face); } {
auto c = hb_sanitize_context_t ();
if (core)
c.set_num_glyphs (0); // So we don't recurse ad infinitum...
return c.reference_table<T> (face);
}
static void destroy (hb_blob_t *p) { hb_blob_destroy (p); } static void destroy (hb_blob_t *p) { hb_blob_destroy (p); }
static const hb_blob_t *get_null () static const hb_blob_t *get_null ()

View File

@ -32,6 +32,11 @@
#define HB_OT_FACE_TABLE_LIST_HH #define HB_OT_FACE_TABLE_LIST_HH
#endif /* HB_OT_FACE_TABLE_LIST_HH */ /* Dummy header guards */ #endif /* HB_OT_FACE_TABLE_LIST_HH */ /* Dummy header guards */
#ifndef HB_OT_CORE_TABLE
#define HB_OT_CORE_TABLE(Namespace, Type) HB_OT_TABLE (Namespace, Type)
#define _HB_OT_CORE_TABLE_UNDEF
#endif
#ifndef HB_OT_ACCELERATOR #ifndef HB_OT_ACCELERATOR
#define HB_OT_ACCELERATOR(Namespace, Type) HB_OT_TABLE (Namespace, Type) #define HB_OT_ACCELERATOR(Namespace, Type) HB_OT_TABLE (Namespace, Type)
#define _HB_OT_ACCELERATOR_UNDEF #define _HB_OT_ACCELERATOR_UNDEF
@ -46,8 +51,8 @@
/* OpenType fundamentals. */ /* OpenType fundamentals. */
HB_OT_TABLE (OT, head) HB_OT_CORE_TABLE (OT, head)
HB_OT_TABLE (OT, maxp) HB_OT_CORE_TABLE (OT, maxp)
#if !defined(HB_NO_FACE_COLLECT_UNICODES) || !defined(HB_NO_OT_FONT) #if !defined(HB_NO_FACE_COLLECT_UNICODES) || !defined(HB_NO_OT_FONT)
HB_OT_ACCELERATOR (OT, cmap) HB_OT_ACCELERATOR (OT, cmap)
#endif #endif
@ -139,3 +144,7 @@ HB_OT_TABLE (OT, MATH)
#ifdef _HB_OT_ACCELERATOR_UNDEF #ifdef _HB_OT_ACCELERATOR_UNDEF
#undef HB_OT_ACCELERATOR #undef HB_OT_ACCELERATOR
#endif #endif
#ifdef _HB_OT_CORE_TABLE_UNDEF
#undef HB_OT_CORE_TABLE
#endif

View File

@ -63,10 +63,13 @@ struct hb_ot_face_t
hb_face_t *face; /* MUST be JUST before the lazy loaders. */ hb_face_t *face; /* MUST be JUST before the lazy loaders. */
#define HB_OT_TABLE(Namespace, Type) \ #define HB_OT_TABLE(Namespace, Type) \
hb_table_lazy_loader_t<Namespace::Type, HB_OT_TABLE_ORDER (Namespace, Type)> Type; hb_table_lazy_loader_t<Namespace::Type, HB_OT_TABLE_ORDER (Namespace, Type)> Type;
#define HB_OT_CORE_TABLE(Namespace, Type) \
hb_table_lazy_loader_t<Namespace::Type, HB_OT_TABLE_ORDER (Namespace, Type), true> Type;
#define HB_OT_ACCELERATOR(Namespace, Type) \ #define HB_OT_ACCELERATOR(Namespace, Type) \
hb_face_lazy_loader_t<Namespace::Type##_accelerator_t, HB_OT_TABLE_ORDER (Namespace, Type)> Type; hb_face_lazy_loader_t<Namespace::Type##_accelerator_t, HB_OT_TABLE_ORDER (Namespace, Type)> Type;
#include "hb-ot-face-table-list.hh" #include "hb-ot-face-table-list.hh"
#undef HB_OT_ACCELERATOR #undef HB_OT_ACCELERATOR
#undef HB_OT_CORE_TABLE
#undef HB_OT_TABLE #undef HB_OT_TABLE
}; };