Add hb_ot_layout_ensure() and hb_uniscribe_font_ensure()

This commit is contained in:
Behdad Esfahbod 2012-07-27 03:06:30 -04:00
parent c5b668fb92
commit cfe9882610
6 changed files with 48 additions and 20 deletions

View File

@ -38,6 +38,13 @@
#include <string.h> #include <string.h>
HB_SHAPER_DATA_ENSURE_DECLARE(ot, face)
hb_bool_t
hb_ot_layout_ensure (hb_face_t *face)
{
return hb_ot_shaper_face_data_ensure (face);
}
hb_ot_layout_t * hb_ot_layout_t *
_hb_ot_layout_create (hb_face_t *face) _hb_ot_layout_create (hb_face_t *face)

View File

@ -42,6 +42,12 @@ HB_BEGIN_DECLS
#define HB_OT_TAG_GSUB HB_TAG('G','S','U','B') #define HB_OT_TAG_GSUB HB_TAG('G','S','U','B')
#define HB_OT_TAG_GPOS HB_TAG('G','P','O','S') #define HB_OT_TAG_GPOS HB_TAG('G','P','O','S')
/* Must call before all other funtions in this file. Idempotent. */
hb_bool_t
hb_ot_layout_ensure (hb_face_t *face);
/* /*
* GDEF * GDEF
*/ */

View File

@ -30,24 +30,6 @@
#include "hb-shaper-private.hh" #include "hb-shaper-private.hh"
#include "hb-font-private.hh" #include "hb-font-private.hh"
#define HB_SHAPER_DATA_ENSURE_DECLARE(shaper, object) \
static inline bool \
hb_##shaper##_##object##_data_ensure (hb_##object##_t *object) \
{\
retry: \
HB_SHAPER_DATA_TYPE (shaper, object) *data = (HB_SHAPER_DATA_TYPE (shaper, object) *) hb_atomic_ptr_get (&HB_SHAPER_DATA (shaper, object)); \
if (unlikely (!data)) { \
data = HB_SHAPER_DATA_CREATE_FUNC (shaper, object) (object); \
if (unlikely (!data)) \
data = (HB_SHAPER_DATA_TYPE (shaper, object) *) HB_SHAPER_DATA_INVALID; \
if (!hb_atomic_ptr_cmpexch (&HB_SHAPER_DATA (shaper, object), NULL, data)) { \
HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (data); \
goto retry; \
} \
} \
return data != NULL && !HB_SHAPER_DATA_IS_INVALID (data); \
}
#define HB_SHAPER_IMPLEMENT(shaper) \ #define HB_SHAPER_IMPLEMENT(shaper) \
HB_SHAPER_DATA_ENSURE_DECLARE(shaper, face) \ HB_SHAPER_DATA_ENSURE_DECLARE(shaper, face) \
HB_SHAPER_DATA_ENSURE_DECLARE(shaper, font) HB_SHAPER_DATA_ENSURE_DECLARE(shaper, font)
@ -65,7 +47,7 @@ hb_shape_plan_plan (hb_shape_plan_t *shape_plan,
#define HB_SHAPER_PLAN(shaper) \ #define HB_SHAPER_PLAN(shaper) \
HB_STMT_START { \ HB_STMT_START { \
if (hb_##shaper##_face_data_ensure (shape_plan->face)) { \ if (hb_##shaper##_shaper_face_data_ensure (shape_plan->face)) { \
HB_SHAPER_DATA_TYPE (shaper, shape_plan) *data= \ HB_SHAPER_DATA_TYPE (shaper, shape_plan) *data= \
HB_SHAPER_DATA_CREATE_FUNC (shaper, shape_plan) (shape_plan, user_features, num_user_features); \ HB_SHAPER_DATA_CREATE_FUNC (shaper, shape_plan) (shape_plan, user_features, num_user_features); \
if (data) { \ if (data) { \
@ -181,7 +163,7 @@ hb_shape_plan_execute (hb_shape_plan *shape_plan,
#define HB_SHAPER_EXECUTE(shaper) \ #define HB_SHAPER_EXECUTE(shaper) \
HB_STMT_START { \ HB_STMT_START { \
if (hb_##shaper##_font_data_ensure (font) && \ if (hb_##shaper##_shaper_font_data_ensure (font) && \
_hb_##shaper##_shape (shape_plan, font, buffer, features, num_features)) \ _hb_##shaper##_shape (shape_plan, font, buffer, features, num_features)) \
return true; \ return true; \
else \ else \

View File

@ -86,5 +86,23 @@ struct hb_shaper_data_t {
object->shaper_data.shaper != HB_SHAPER_DATA_SUCCEEDED) \ object->shaper_data.shaper != HB_SHAPER_DATA_SUCCEEDED) \
HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (HB_SHAPER_DATA (shaper, object)); HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (HB_SHAPER_DATA (shaper, object));
#define HB_SHAPER_DATA_ENSURE_DECLARE(shaper, object) \
static inline bool \
hb_##shaper##_shaper_##object##_data_ensure (hb_##object##_t *object) \
{\
retry: \
HB_SHAPER_DATA_TYPE (shaper, object) *data = (HB_SHAPER_DATA_TYPE (shaper, object) *) hb_atomic_ptr_get (&HB_SHAPER_DATA (shaper, object)); \
if (unlikely (!data)) { \
data = HB_SHAPER_DATA_CREATE_FUNC (shaper, object) (object); \
if (unlikely (!data)) \
data = (HB_SHAPER_DATA_TYPE (shaper, object) *) HB_SHAPER_DATA_INVALID; \
if (!hb_atomic_ptr_cmpexch (&HB_SHAPER_DATA (shaper, object), NULL, data)) { \
HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (data); \
goto retry; \
} \
} \
return data != NULL && !HB_SHAPER_DATA_IS_INVALID (data); \
}
#endif /* HB_SHAPER_PRIVATE_HH */ #endif /* HB_SHAPER_PRIVATE_HH */

View File

@ -56,6 +56,17 @@ DWORD GetFontData(
*/ */
HB_SHAPER_DATA_ENSURE_DECLARE(uniscribe, face)
HB_SHAPER_DATA_ENSURE_DECLARE(uniscribe, font)
hb_bool_t
hb_uniscribe_font_ensure (hb_font_t *font)
{
hb_face_t *face = font->face;
return hb_uniscribe_shaper_face_data_ensure (face) &&
hb_uniscribe_shaper_font_data_ensure (font);
}
/* /*
* shaper face data * shaper face data
*/ */

View File

@ -34,6 +34,10 @@
HB_BEGIN_DECLS HB_BEGIN_DECLS
/* Must call before all other funtions in this file. Idempotent. */
hb_bool_t
hb_uniscribe_font_ensure (hb_font_t *font);
LOGFONTW * LOGFONTW *
hb_uniscribe_font_get_logfontw (hb_font_t *font); hb_uniscribe_font_get_logfontw (hb_font_t *font);