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:
parent
edeb3dabf4
commit
3e905e396b
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue