[ot-face] Include hb-ot-face directly in hb_face_t

Simplifying access coming next.
This commit is contained in:
Behdad Esfahbod 2018-11-05 22:39:50 -05:00
parent 56ba998cdd
commit 914b595f25
7 changed files with 46 additions and 68 deletions

View File

@ -132,6 +132,8 @@ hb_face_create_for_tables (hb_reference_table_func_t reference_table_func,
face->upem = 0;
face->num_glyphs = (unsigned int) -1;
face->table.init0 (face);
return face;
}
@ -275,6 +277,8 @@ hb_face_destroy (hb_face_t *face)
#include "hb-shaper-list.hh"
#undef HB_SHAPER_IMPLEMENT
face->table.fini ();
if (face->destroy)
face->destroy (face->user_data);

View File

@ -33,6 +33,7 @@
#include "hb-shaper.hh"
#include "hb-shape-plan.hh"
#include "hb-ot-face.hh"
/*
@ -53,6 +54,8 @@ struct hb_face_t
struct hb_shaper_data_t shaper_data; /* Various shaper data. */
hb_ot_face_t table;
/* Cache */
struct plan_node_t
{

View File

@ -40,7 +40,7 @@
#include "hb-ot-layout-gpos-table.hh"
void hb_ot_face_data_t::init0 (hb_face_t *face)
void hb_ot_face_t::init0 (hb_face_t *face)
{
this->face = face;
#define HB_OT_TABLE(Namespace, Type) Type.init0 ();
@ -49,7 +49,7 @@ void hb_ot_face_data_t::init0 (hb_face_t *face)
#undef HB_OT_ACCELERATOR
#undef HB_OT_TABLE
}
void hb_ot_face_data_t::fini (void)
void hb_ot_face_t::fini (void)
{
#define HB_OT_TABLE(Namespace, Type) Type.fini ();
#define HB_OT_ACCELERATOR(Namespace, Type) HB_OT_TABLE (Namespace, Type)
@ -57,23 +57,3 @@ void hb_ot_face_data_t::fini (void)
#undef HB_OT_ACCELERATOR
#undef HB_OT_TABLE
}
hb_ot_face_data_t *
_hb_ot_face_data_create (hb_face_t *face)
{
hb_ot_face_data_t *data = (hb_ot_face_data_t *) calloc (1, sizeof (hb_ot_face_data_t));
if (unlikely (!data))
return nullptr;
data->init0 (face);
return data;
}
void
_hb_ot_face_data_destroy (hb_ot_face_data_t *data)
{
data->fini ();
free (data);
}

View File

@ -34,34 +34,14 @@
#include "hb-machinery.hh"
#define hb_ot_face_data(face) ((hb_ot_face_data_t *) face->shaper_data.ot.get_relaxed ())
#define hb_ot_face_data(face) (&face->table)
/*
* hb_ot_face_data_t
* hb_ot_face_t
*/
/* Most of these tables are NOT needed for shaping. But we need to hook them *somewhere*.
* This is as good as any place. */
#define HB_OT_TABLES \
/* OpenType shaping. */ \
HB_OT_ACCELERATOR(OT, GDEF) \
HB_OT_ACCELERATOR(OT, GSUB) \
HB_OT_ACCELERATOR(OT, GPOS) \
HB_OT_TABLE(OT, JSTF) \
HB_OT_TABLE(OT, BASE) \
/* AAT shaping. */ \
HB_OT_TABLE(AAT, morx) \
HB_OT_TABLE(AAT, mort) \
HB_OT_TABLE(AAT, kerx) \
HB_OT_TABLE(AAT, ankr) \
HB_OT_TABLE(AAT, trak) \
/* OpenType variations. */ \
HB_OT_TABLE(OT, fvar) \
HB_OT_TABLE(OT, avar) \
HB_OT_TABLE(OT, MVAR) \
/* OpenType math. */ \
HB_OT_TABLE(OT, MATH) \
/* OpenType fundamentals. */ \
HB_OT_ACCELERATOR(OT, cmap) \
HB_OT_ACCELERATOR(OT, hmtx) \
@ -71,7 +51,25 @@
HB_OT_ACCELERATOR(OT, glyf) \
HB_OT_TABLE(OT, VORG) \
HB_OT_ACCELERATOR(OT, name) \
/* OpenType shaping. */ \
HB_OT_ACCELERATOR(OT, GDEF) \
HB_OT_ACCELERATOR(OT, GSUB) \
HB_OT_ACCELERATOR(OT, GPOS) \
HB_OT_TABLE(OT, BASE) \
HB_OT_TABLE(OT, JSTF) \
/* AAT shaping. */ \
HB_OT_TABLE(AAT, mort) \
HB_OT_TABLE(AAT, morx) \
HB_OT_TABLE(AAT, kerx) \
HB_OT_TABLE(AAT, ankr) \
HB_OT_TABLE(AAT, trak) \
HB_OT_TABLE(AAT, ltag) \
/* OpenType variations. */ \
HB_OT_TABLE(OT, fvar) \
HB_OT_TABLE(OT, avar) \
HB_OT_TABLE(OT, MVAR) \
/* OpenType math. */ \
HB_OT_TABLE(OT, MATH) \
/* OpenType color fonts. */ \
HB_OT_TABLE(OT, COLR) \
HB_OT_TABLE(OT, CPAL) \
@ -87,7 +85,7 @@ HB_OT_TABLES
#undef HB_OT_ACCELERATOR
#undef HB_OT_TABLE
struct hb_ot_face_data_t
struct hb_ot_face_t
{
HB_INTERNAL void init0 (hb_face_t *face);
HB_INTERNAL void fini (void);
@ -115,11 +113,4 @@ struct hb_ot_face_data_t
};
HB_INTERNAL hb_ot_face_data_t *
_hb_ot_face_data_create (hb_face_t *face);
HB_INTERNAL void
_hb_ot_face_data_destroy (hb_ot_face_data_t *data);
#endif /* HB_OT_FACE_HH */

View File

@ -61,7 +61,7 @@ hb_ot_get_nominal_glyph (hb_font_t *font HB_UNUSED,
hb_codepoint_t *glyph,
void *user_data HB_UNUSED)
{
const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
return ot_face->cmap->get_nominal_glyph (unicode, glyph);
}
@ -75,7 +75,7 @@ hb_ot_get_nominal_glyphs (hb_font_t *font HB_UNUSED,
unsigned int glyph_stride,
void *user_data HB_UNUSED)
{
const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
return ot_face->cmap->get_nominal_glyphs (count,
first_unicode, unicode_stride,
first_glyph, glyph_stride);
@ -89,7 +89,7 @@ hb_ot_get_variation_glyph (hb_font_t *font HB_UNUSED,
hb_codepoint_t *glyph,
void *user_data HB_UNUSED)
{
const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
return ot_face->cmap->get_variation_glyph (unicode, variation_selector, glyph);
}
@ -102,7 +102,7 @@ hb_ot_get_glyph_h_advances (hb_font_t* font, void* font_data,
unsigned advance_stride,
void *user_data HB_UNUSED)
{
const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx;
for (unsigned int i = 0; i < count; i++)
@ -122,7 +122,7 @@ hb_ot_get_glyph_v_advances (hb_font_t* font, void* font_data,
unsigned advance_stride,
void *user_data HB_UNUSED)
{
const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx;
for (unsigned int i = 0; i < count; i++)
@ -141,7 +141,7 @@ hb_ot_get_glyph_v_origin (hb_font_t *font,
hb_position_t *y,
void *user_data HB_UNUSED)
{
const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
*x = font->get_glyph_h_advance (glyph) / 2;
@ -175,7 +175,7 @@ hb_ot_get_glyph_extents (hb_font_t *font,
hb_glyph_extents_t *extents,
void *user_data HB_UNUSED)
{
const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
bool ret = ot_face->sbix->get_extents (font, glyph, extents);
if (!ret)
ret = ot_face->glyf->get_extents (glyph, extents);
@ -196,7 +196,7 @@ hb_ot_get_glyph_name (hb_font_t *font HB_UNUSED,
char *name, unsigned int size,
void *user_data HB_UNUSED)
{
const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
return ot_face->post->get_glyph_name (glyph, name, size);
}
@ -207,7 +207,7 @@ hb_ot_get_glyph_from_name (hb_font_t *font HB_UNUSED,
hb_codepoint_t *glyph,
void *user_data HB_UNUSED)
{
const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
return ot_face->post->get_glyph_from_name (name, len, glyph);
}
@ -217,7 +217,7 @@ hb_ot_get_font_h_extents (hb_font_t *font,
hb_font_extents_t *metrics,
void *user_data HB_UNUSED)
{
const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx;
metrics->ascender = font->em_scale_y (hmtx.ascender);
metrics->descender = font->em_scale_y (hmtx.descender);
@ -232,7 +232,7 @@ hb_ot_get_font_v_extents (hb_font_t *font,
hb_font_extents_t *metrics,
void *user_data HB_UNUSED)
{
const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx;
metrics->ascender = font->em_scale_x (vmtx.ascender);
metrics->descender = font->em_scale_x (vmtx.descender);
@ -299,7 +299,7 @@ void
hb_ot_font_set_funcs (hb_font_t *font)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (font->face))) return;
hb_ot_face_data_t *ot_face = hb_ot_face_data (font->face);
hb_ot_face_t *ot_face = hb_ot_face_data (font->face);
hb_font_set_funcs (font,
_hb_ot_get_font_funcs (),

View File

@ -44,8 +44,7 @@ static inline const OT::MATH&
_get_math (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::MATH);
hb_ot_face_data_t * data = hb_ot_face_data (face);
return *(data->MATH);
return *(hb_ot_face_data (face)->MATH);
}
/*

View File

@ -258,16 +258,17 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner,
HB_SHAPER_DATA_ENSURE_DEFINE(ot, face)
struct hb_ot_face_data_t {};
hb_ot_face_data_t *
_hb_ot_shaper_face_data_create (hb_face_t *face)
{
return _hb_ot_face_data_create (face);
return (hb_ot_face_data_t *) HB_SHAPER_DATA_SUCCEEDED;
}
void
_hb_ot_shaper_face_data_destroy (hb_ot_face_data_t *data)
{
_hb_ot_face_data_destroy (data);
}