Add hb_ot_layout_ensure() and hb_uniscribe_font_ensure()
This commit is contained in:
parent
c5b668fb92
commit
cfe9882610
@ -38,6 +38,13 @@
|
||||
#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_create (hb_face_t *face)
|
||||
|
@ -42,6 +42,12 @@ HB_BEGIN_DECLS
|
||||
#define HB_OT_TAG_GSUB HB_TAG('G','S','U','B')
|
||||
#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
|
||||
*/
|
||||
|
@ -30,24 +30,6 @@
|
||||
#include "hb-shaper-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) \
|
||||
HB_SHAPER_DATA_ENSURE_DECLARE(shaper, face) \
|
||||
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) \
|
||||
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_CREATE_FUNC (shaper, shape_plan) (shape_plan, user_features, num_user_features); \
|
||||
if (data) { \
|
||||
@ -181,7 +163,7 @@ hb_shape_plan_execute (hb_shape_plan *shape_plan,
|
||||
|
||||
#define HB_SHAPER_EXECUTE(shaper) \
|
||||
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)) \
|
||||
return true; \
|
||||
else \
|
||||
|
@ -86,5 +86,23 @@ struct hb_shaper_data_t {
|
||||
object->shaper_data.shaper != HB_SHAPER_DATA_SUCCEEDED) \
|
||||
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 */
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -34,6 +34,10 @@
|
||||
|
||||
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 *
|
||||
hb_uniscribe_font_get_logfontw (hb_font_t *font);
|
||||
|
Loading…
Reference in New Issue
Block a user