[MATH] Fixups for previous commit
This commit is contained in:
parent
5fbcb992bd
commit
4d3892e9b0
|
@ -38,18 +38,18 @@ namespace OT {
|
||||||
|
|
||||||
struct MATH
|
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
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||||
{
|
{
|
||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
return_trace (version.sanitize (c) &&
|
return_trace (version.sanitize (c) &&
|
||||||
likely (version.major == 1));
|
likely (version.major == 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FixedVersion<>version; /* Version of the MATH table
|
FixedVersion<>version; /* Version of the MATH table
|
||||||
initially set to 0x00010000u */
|
* initially set to 0x00010000u */
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_STATIC (4);
|
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_blob = OT::Sanitizer<OT::GPOS>::sanitize (face->reference_table (HB_OT_TAG_GPOS));
|
||||||
layout->gpos = OT::Sanitizer<OT::GPOS>::lock_instance (layout->gpos_blob);
|
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_blob = NULL;
|
||||||
layout->math = 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->gdef_blob);
|
||||||
hb_blob_destroy (layout->gsub_blob);
|
hb_blob_destroy (layout->gsub_blob);
|
||||||
hb_blob_destroy (layout->gpos_blob);
|
hb_blob_destroy (layout->gpos_blob);
|
||||||
|
hb_blob_destroy (layout->math_blob);
|
||||||
if (layout->math_blob) hb_blob_destroy (layout->math_blob);
|
|
||||||
|
|
||||||
free (layout);
|
free (layout);
|
||||||
}
|
}
|
||||||
|
@ -213,13 +212,22 @@ _get_math (hb_face_t *face)
|
||||||
|
|
||||||
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
|
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
|
||||||
|
|
||||||
// If the MATH table is not loaded yet, do it now.
|
retry:
|
||||||
if (!layout->math_blob) {
|
const OT::MATH *math = (const OT::MATH *) hb_atomic_ptr_get (&layout->math);
|
||||||
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);
|
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);
|
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
|
* Return value: #TRUE if face has a MATH table and #FALSE otherwise
|
||||||
*
|
*
|
||||||
* Since: ????
|
* Since: 1.4
|
||||||
**/
|
**/
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
hb_ot_layout_has_math_data (hb_face_t *face)
|
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_EXTERN hb_bool_t
|
||||||
hb_ot_layout_has_math_data (hb_face_t *face);
|
hb_ot_layout_has_math_data (hb_face_t *face);
|
||||||
|
|
||||||
|
|
||||||
HB_END_DECLS
|
HB_END_DECLS
|
||||||
|
|
||||||
#endif /* HB_OT_LAYOUT_H */
|
#endif /* HB_OT_LAYOUT_H */
|
||||||
|
|
|
@ -52,10 +52,8 @@ if HAVE_FREETYPE
|
||||||
TEST_PROGS += \
|
TEST_PROGS += \
|
||||||
test-ot-layout-math \
|
test-ot-layout-math \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
test_ot_layout_math_LDADD = $(LDADD)
|
test_ot_layout_math_LDADD = $(LDADD) $(FREETYPE_LIBS)
|
||||||
test_ot_layout_math_CPPFLAGS = $(AM_CPPFLAGS)
|
test_ot_layout_math_CPPFLAGS = $(AM_CPPFLAGS) $(FREETYPE_CFLAGS)
|
||||||
test_ot_layout_math_CPPFLAGS += $(FREETYPE_CFLAGS)
|
|
||||||
test_ot_layout_math_LDADD += $(FREETYPE_LIBS)
|
|
||||||
endif # HAVE_FREETYPE
|
endif # HAVE_FREETYPE
|
||||||
|
|
||||||
endif # HAVE_OT
|
endif # HAVE_OT
|
||||||
|
|
|
@ -37,16 +37,16 @@ static FT_Face ft_face;
|
||||||
static hb_font_t *hb_font;
|
static hb_font_t *hb_font;
|
||||||
static hb_face_t *hb_face;
|
static hb_face_t *hb_face;
|
||||||
|
|
||||||
static void
|
static inline void
|
||||||
initFreeType()
|
initFreeType (void)
|
||||||
{
|
{
|
||||||
FT_Error ft_error;
|
FT_Error ft_error;
|
||||||
if ((ft_error = FT_Init_FreeType (&ft_library)))
|
if ((ft_error = FT_Init_FreeType (&ft_library)))
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static inline void
|
||||||
cleanupFreeType()
|
cleanupFreeType (void)
|
||||||
{
|
{
|
||||||
FT_Done_FreeType (ft_library);
|
FT_Done_FreeType (ft_library);
|
||||||
}
|
}
|
||||||
|
@ -57,15 +57,17 @@ openFont(const char* fontFile)
|
||||||
FT_Error ft_error;
|
FT_Error ft_error;
|
||||||
if ((ft_error = FT_New_Face (ft_library, fontFile, 0, &ft_face)))
|
if ((ft_error = FT_New_Face (ft_library, fontFile, 0, &ft_face)))
|
||||||
abort();
|
abort();
|
||||||
unsigned int fontSize = 1000;
|
|
||||||
|
#define fontSize 1000
|
||||||
|
|
||||||
if ((ft_error = FT_Set_Char_Size (ft_face, fontSize, fontSize, 0, 0)))
|
if ((ft_error = FT_Set_Char_Size (ft_face, fontSize, fontSize, 0, 0)))
|
||||||
abort();
|
abort();
|
||||||
hb_font = hb_ft_font_create (ft_face, NULL);
|
hb_font = hb_ft_font_create (ft_face, NULL);
|
||||||
hb_face = hb_ft_face_create_cached(ft_face);
|
hb_face = hb_ft_face_create_cached(ft_face);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static inline void
|
||||||
closeFont()
|
closeFont (void)
|
||||||
{
|
{
|
||||||
hb_font_destroy (hb_font);
|
hb_font_destroy (hb_font);
|
||||||
FT_Done_Face (ft_face);
|
FT_Done_Face (ft_face);
|
||||||
|
|
Loading…
Reference in New Issue