Add hb_font_set_parent()

No reason to not have it.  Makes life easier later.
We (hb-ft, hb-ot-font, etc) can use this API to inject new
parent into a font...
This commit is contained in:
Behdad Esfahbod 2015-10-08 12:51:02 -04:00
parent edeb3dabf4
commit 3e905e396b
3 changed files with 42 additions and 0 deletions

View File

@ -1058,6 +1058,32 @@ hb_font_is_immutable (hb_font_t *font)
return font->immutable;
}
/**
* hb_font_set_parent:
* @font: a font.
* @parent: new parent.
*
* Sets parent font of @font.
*
* Since: 1.0.5
**/
void
hb_font_set_parent (hb_font_t *font,
hb_font_t *parent)
{
if (font->immutable)
return;
if (!parent)
parent = hb_font_get_empty ();
hb_font_t *old = font->parent;
font->parent = hb_font_reference (parent);
hb_font_destroy (old);
}
/**
* hb_font_get_parent:
* @font: a font.

View File

@ -459,6 +459,10 @@ hb_font_make_immutable (hb_font_t *font);
hb_bool_t
hb_font_is_immutable (hb_font_t *font);
void
hb_font_set_parent (hb_font_t *font,
hb_font_t *parent);
hb_font_t *
hb_font_get_parent (hb_font_t *font);

View File

@ -387,6 +387,18 @@ test_font_properties (void)
g_assert (hb_font_get_face (font) == face);
g_assert (hb_font_get_parent (font) == NULL);
subfont = hb_font_create_sub_font (font);
g_assert (hb_font_get_parent (subfont) == font);
hb_font_set_parent(subfont, NULL);
g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
hb_font_set_parent(subfont, font);
g_assert (hb_font_get_parent (subfont) == font);
hb_font_set_parent(subfont, NULL);
hb_font_make_immutable (subfont);
g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
hb_font_set_parent(subfont, font);
g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
hb_font_destroy (subfont);
/* Check scale */