struct MATH
{
- static const hb_tag_t tableTag = HB_OT_TAG_MATH;
+ static const hb_tag_t tableTag = HB_OT_TAG_MATH;
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
return_trace (version.sanitize (c) &&
- likely (version.major == 1));
+ likely (version.major == 1));
}
protected:
- FixedVersion<>version; /* Version of the MATH table
- initially set to 0x00010000u */
+ FixedVersion<>version; /* Version of the MATH table
+ * initially set to 0x00010000u */
public:
DEFINE_SIZE_STATIC (4);
};
layout->gpos_blob = OT::Sanitizer<OT::GPOS>::sanitize (face->reference_table (HB_OT_TAG_GPOS));
layout->gpos = OT::Sanitizer<OT::GPOS>::lock_instance (layout->gpos_blob);
- // The MATH table is rarer so we only try and load it in _get_math
+ /* The MATH table is rarely used, so only try and load it in _get_math. */
layout->math_blob = NULL;
layout->math = NULL;
hb_blob_destroy (layout->gdef_blob);
hb_blob_destroy (layout->gsub_blob);
hb_blob_destroy (layout->gpos_blob);
-
- if (layout->math_blob) hb_blob_destroy (layout->math_blob);
+ hb_blob_destroy (layout->math_blob);
free (layout);
}
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
- // If the MATH table is not loaded yet, do it now.
- if (!layout->math_blob) {
- layout->math_blob = OT::Sanitizer<OT::MATH>::sanitize (face->reference_table (HB_OT_TAG_MATH));
- layout->math = OT::Sanitizer<OT::MATH>::lock_instance (layout->math_blob);
+retry:
+ const OT::MATH *math = (const OT::MATH *) hb_atomic_ptr_get (&layout->math);
+
+ if (unlikely (!math))
+ {
+ hb_blob_t *blob = OT::Sanitizer<OT::MATH>::sanitize (face->reference_table (HB_OT_TAG_MATH));
+ math = OT::Sanitizer<OT::MATH>::lock_instance (blob);
+ if (!hb_atomic_ptr_cmpexch (&layout->math, NULL, math))
+ {
+ hb_blob_destroy (blob);
+ goto retry;
+ }
+ layout->math_blob = blob;
}
- return *layout->math;
+ return *math;
}
apply_string<GSUBProxy> (c, lookup, accel);
}
+
/*
- * OT::MATH
+ * MATH
*/
/**
*
* Return value: #TRUE if face has a MATH table and #FALSE otherwise
*
- * Since: ????
+ * Since: 1.4
**/
hb_bool_t
hb_ot_layout_has_math_data (hb_face_t *face)
HB_EXTERN hb_bool_t
hb_ot_layout_has_math_data (hb_face_t *face);
+
+
HB_END_DECLS
#endif /* HB_OT_LAYOUT_H */
TEST_PROGS += \
test-ot-layout-math \
$(NULL)
-test_ot_layout_math_LDADD = $(LDADD)
-test_ot_layout_math_CPPFLAGS = $(AM_CPPFLAGS)
-test_ot_layout_math_CPPFLAGS += $(FREETYPE_CFLAGS)
-test_ot_layout_math_LDADD += $(FREETYPE_LIBS)
+test_ot_layout_math_LDADD = $(LDADD) $(FREETYPE_LIBS)
+test_ot_layout_math_CPPFLAGS = $(AM_CPPFLAGS) $(FREETYPE_CFLAGS)
endif # HAVE_FREETYPE
endif # HAVE_OT
static hb_font_t *hb_font;
static hb_face_t *hb_face;
-static void
-initFreeType()
+static inline void
+initFreeType (void)
{
FT_Error ft_error;
if ((ft_error = FT_Init_FreeType (&ft_library)))
abort();
}
-static void
-cleanupFreeType()
+static inline void
+cleanupFreeType (void)
{
FT_Done_FreeType (ft_library);
}
FT_Error ft_error;
if ((ft_error = FT_New_Face (ft_library, fontFile, 0, &ft_face)))
abort();
- unsigned int fontSize = 1000;
+
+#define fontSize 1000
+
if ((ft_error = FT_Set_Char_Size (ft_face, fontSize, fontSize, 0, 0)))
abort();
hb_font = hb_ft_font_create (ft_face, NULL);
hb_face = hb_ft_face_create_cached(ft_face);
}
-static void
-closeFont()
+static inline void
+closeFont (void)
{
hb_font_destroy (hb_font);
FT_Done_Face (ft_face);