[font] Add serial API
New API: + hb_font_get_serial() + hb_font_changed() Fixes https://github.com/harfbuzz/harfbuzz/issues/2426 Unused internally as of now.
This commit is contained in:
parent
0fe1869228
commit
48db1c9583
|
@ -373,6 +373,8 @@ hb_font_glyph_from_string
|
|||
hb_font_glyph_to_string
|
||||
hb_font_is_immutable
|
||||
hb_font_make_immutable
|
||||
hb_font_get_serial
|
||||
hb_font_changed
|
||||
hb_font_reference
|
||||
hb_font_set_face
|
||||
hb_font_set_funcs
|
||||
|
|
|
@ -1623,6 +1623,8 @@ DEFINE_NULL_INSTANCE (hb_font_t) =
|
|||
{
|
||||
HB_OBJECT_HEADER_STATIC,
|
||||
|
||||
0, /* serial */
|
||||
|
||||
nullptr, /* parent */
|
||||
const_cast<hb_face_t *> (&_hb_Null_hb_face_t),
|
||||
|
||||
|
@ -1852,6 +1854,11 @@ hb_font_set_user_data (hb_font_t *font,
|
|||
hb_destroy_func_t destroy /* May be NULL. */,
|
||||
hb_bool_t replace)
|
||||
{
|
||||
if (hb_object_is_immutable (font))
|
||||
return false;
|
||||
|
||||
font->serial++;
|
||||
|
||||
return hb_object_set_user_data (font, key, data, destroy, replace);
|
||||
}
|
||||
|
||||
|
@ -1910,6 +1917,45 @@ hb_font_is_immutable (hb_font_t *font)
|
|||
return hb_object_is_immutable (font);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_font_get_serial:
|
||||
* @font: #hb_font_t to work upon
|
||||
*
|
||||
* Returns the internal serial number of the font. The serial
|
||||
* number is increased every time a setting on the font is
|
||||
* changed, using a setter function.
|
||||
*
|
||||
* Return value: serial number
|
||||
*
|
||||
* Since: REPLACEME.
|
||||
**/
|
||||
unsigned long
|
||||
hb_font_get_serial (hb_font_t *font)
|
||||
{
|
||||
return font->serial;
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_font_changed:
|
||||
* @font: #hb_font_t to work upon
|
||||
*
|
||||
* Notifies the @font that underlying font data has changed.
|
||||
* This has the effect of increasing the serial as returned
|
||||
* by hb_font_get_serial(), which invalidates internal caches.
|
||||
*
|
||||
* Since: REPLACEME.
|
||||
**/
|
||||
void
|
||||
hb_font_changed (hb_font_t *font)
|
||||
{
|
||||
if (hb_object_is_immutable (font))
|
||||
return;
|
||||
|
||||
font->serial++;
|
||||
|
||||
font->mults_changed ();
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_font_set_parent:
|
||||
* @font: #hb_font_t to work upon
|
||||
|
@ -1926,6 +1972,11 @@ hb_font_set_parent (hb_font_t *font,
|
|||
if (hb_object_is_immutable (font))
|
||||
return;
|
||||
|
||||
if (parent == font->parent)
|
||||
return;
|
||||
|
||||
font->serial++;
|
||||
|
||||
if (!parent)
|
||||
parent = hb_font_get_empty ();
|
||||
|
||||
|
@ -1968,6 +2019,11 @@ hb_font_set_face (hb_font_t *font,
|
|||
if (hb_object_is_immutable (font))
|
||||
return;
|
||||
|
||||
if (face == font->face)
|
||||
return;
|
||||
|
||||
font->serial++;
|
||||
|
||||
if (unlikely (!face))
|
||||
face = hb_face_get_empty ();
|
||||
|
||||
|
@ -2022,6 +2078,8 @@ hb_font_set_funcs (hb_font_t *font,
|
|||
return;
|
||||
}
|
||||
|
||||
font->serial++;
|
||||
|
||||
if (font->destroy)
|
||||
font->destroy (font->user_data);
|
||||
|
||||
|
@ -2059,6 +2117,8 @@ hb_font_set_funcs_data (hb_font_t *font,
|
|||
return;
|
||||
}
|
||||
|
||||
font->serial++;
|
||||
|
||||
if (font->destroy)
|
||||
font->destroy (font->user_data);
|
||||
|
||||
|
@ -2085,6 +2145,11 @@ hb_font_set_scale (hb_font_t *font,
|
|||
if (hb_object_is_immutable (font))
|
||||
return;
|
||||
|
||||
if (font->x_scale == x_scale && font->y_scale == y_scale)
|
||||
return;
|
||||
|
||||
font->serial++;
|
||||
|
||||
font->x_scale = x_scale;
|
||||
font->y_scale = y_scale;
|
||||
font->mults_changed ();
|
||||
|
@ -2127,6 +2192,11 @@ hb_font_set_ppem (hb_font_t *font,
|
|||
if (hb_object_is_immutable (font))
|
||||
return;
|
||||
|
||||
if (font->x_ppem == x_ppem && font->y_ppem == y_ppem)
|
||||
return;
|
||||
|
||||
font->serial++;
|
||||
|
||||
font->x_ppem = x_ppem;
|
||||
font->y_ppem = y_ppem;
|
||||
}
|
||||
|
@ -2169,6 +2239,11 @@ hb_font_set_ptem (hb_font_t *font,
|
|||
if (hb_object_is_immutable (font))
|
||||
return;
|
||||
|
||||
if (font->ptem == ptem)
|
||||
return;
|
||||
|
||||
font->serial++;
|
||||
|
||||
font->ptem = ptem;
|
||||
}
|
||||
|
||||
|
@ -2216,6 +2291,11 @@ hb_font_set_synthetic_slant (hb_font_t *font, float slant)
|
|||
if (hb_object_is_immutable (font))
|
||||
return;
|
||||
|
||||
if (font->slant == slant)
|
||||
return;
|
||||
|
||||
font->serial++;
|
||||
|
||||
font->slant = slant;
|
||||
font->mults_changed ();
|
||||
}
|
||||
|
@ -2263,6 +2343,8 @@ hb_font_set_variations (hb_font_t *font,
|
|||
if (hb_object_is_immutable (font))
|
||||
return;
|
||||
|
||||
font->serial++;
|
||||
|
||||
if (!variations_length)
|
||||
{
|
||||
hb_font_set_var_coords_normalized (font, nullptr, 0);
|
||||
|
@ -2322,6 +2404,8 @@ hb_font_set_var_coords_design (hb_font_t *font,
|
|||
if (hb_object_is_immutable (font))
|
||||
return;
|
||||
|
||||
font->serial++;
|
||||
|
||||
int *normalized = coords_length ? (int *) hb_calloc (coords_length, sizeof (int)) : nullptr;
|
||||
float *design_coords = coords_length ? (float *) hb_calloc (coords_length, sizeof (float)) : nullptr;
|
||||
|
||||
|
@ -2355,6 +2439,8 @@ hb_font_set_var_named_instance (hb_font_t *font,
|
|||
if (hb_object_is_immutable (font))
|
||||
return;
|
||||
|
||||
font->serial++;
|
||||
|
||||
unsigned int coords_length = hb_ot_var_named_instance_get_design_coords (font->face, instance_index, nullptr, nullptr);
|
||||
|
||||
float *coords = coords_length ? (float *) hb_calloc (coords_length, sizeof (float)) : nullptr;
|
||||
|
@ -2391,6 +2477,8 @@ hb_font_set_var_coords_normalized (hb_font_t *font,
|
|||
if (hb_object_is_immutable (font))
|
||||
return;
|
||||
|
||||
font->serial++;
|
||||
|
||||
int *copy = coords_length ? (int *) hb_calloc (coords_length, sizeof (coords[0])) : nullptr;
|
||||
int *unmapped = coords_length ? (int *) hb_calloc (coords_length, sizeof (coords[0])) : nullptr;
|
||||
float *design_coords = coords_length ? (float *) hb_calloc (coords_length, sizeof (design_coords[0])) : nullptr;
|
||||
|
|
|
@ -1002,6 +1002,12 @@ hb_font_make_immutable (hb_font_t *font);
|
|||
HB_EXTERN hb_bool_t
|
||||
hb_font_is_immutable (hb_font_t *font);
|
||||
|
||||
HB_EXTERN unsigned long
|
||||
hb_font_get_serial (hb_font_t *font);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_font_changed (hb_font_t *font);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_font_set_parent (hb_font_t *font,
|
||||
hb_font_t *parent);
|
||||
|
|
|
@ -104,6 +104,7 @@ DECLARE_NULL_INSTANCE (hb_font_funcs_t);
|
|||
struct hb_font_t
|
||||
{
|
||||
hb_object_header_t header;
|
||||
unsigned long serial;
|
||||
|
||||
hb_font_t *parent;
|
||||
hb_face_t *face;
|
||||
|
|
Loading…
Reference in New Issue