[MATH] Fixups for previous commit
This commit is contained in:
parent
5fbcb992bd
commit
4d3892e9b0
|
@ -49,7 +49,7 @@ struct MATH
|
|||
|
||||
protected:
|
||||
FixedVersion<>version; /* Version of the MATH table
|
||||
initially set to 0x00010000u */
|
||||
* initially set to 0x00010000u */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (4);
|
||||
};
|
||||
|
|
|
@ -61,7 +61,7 @@ _hb_ot_layout_create (hb_face_t *face)
|
|||
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;
|
||||
|
||||
|
@ -182,8 +182,7 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout)
|
|||
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);
|
||||
}
|
||||
|
@ -213,13 +212,22 @@ _get_math (hb_face_t *face)
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1213,8 +1221,9 @@ hb_ot_layout_substitute_lookup (OT::hb_apply_context_t *c,
|
|||
apply_string<GSUBProxy> (c, lookup, accel);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* OT::MATH
|
||||
* MATH
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1228,7 +1237,7 @@ hb_ot_layout_substitute_lookup (OT::hb_apply_context_t *c,
|
|||
*
|
||||
* 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)
|
||||
|
|
|
@ -304,6 +304,8 @@ hb_ot_layout_get_size_params (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 */
|
||||
|
|
|
@ -52,10 +52,8 @@ if HAVE_FREETYPE
|
|||
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
|
||||
|
|
|
@ -37,16 +37,16 @@ static FT_Face ft_face;
|
|||
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);
|
||||
}
|
||||
|
@ -57,15 +57,17 @@ openFont(const char* fontFile)
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue