[API] Add hb_font_create_sub_font() and hb_font_get_parent()
Not quite useful just yet.
This commit is contained in:
parent
11bb8fe7b3
commit
defc45be6d
@ -82,6 +82,7 @@ struct _hb_font_t {
|
||||
|
||||
hb_bool_t immutable;
|
||||
|
||||
hb_font_t *parent;
|
||||
hb_face_t *face;
|
||||
|
||||
int x_scale;
|
||||
|
@ -83,7 +83,7 @@ hb_font_get_kerning_nil (hb_font_t *font HB_UNUSED,
|
||||
static hb_font_funcs_t _hb_font_funcs_nil = {
|
||||
HB_OBJECT_HEADER_STATIC,
|
||||
|
||||
TRUE, /* immutable */
|
||||
TRUE, /* immutable */
|
||||
{
|
||||
hb_font_get_glyph_nil,
|
||||
hb_font_get_glyph_advance_nil,
|
||||
@ -448,8 +448,9 @@ hb_face_get_upem (hb_face_t *face)
|
||||
static hb_font_t _hb_font_nil = {
|
||||
HB_OBJECT_HEADER_STATIC,
|
||||
|
||||
TRUE, /* immutable */
|
||||
TRUE, /* immutable */
|
||||
|
||||
NULL, /* parent */
|
||||
&_hb_face_nil,
|
||||
|
||||
0, /* x_scale */
|
||||
@ -458,7 +459,7 @@ static hb_font_t _hb_font_nil = {
|
||||
0, /* x_ppem */
|
||||
0, /* y_ppem */
|
||||
|
||||
NULL, /* klass */
|
||||
&_hb_font_funcs_nil, /* klass */
|
||||
NULL, /* user_data */
|
||||
NULL /* destroy */
|
||||
};
|
||||
@ -481,6 +482,34 @@ hb_font_create (hb_face_t *face)
|
||||
return font;
|
||||
}
|
||||
|
||||
hb_font_t *
|
||||
hb_font_create_sub_font (hb_font_t *parent)
|
||||
{
|
||||
if (unlikely (!parent))
|
||||
return &_hb_font_nil;
|
||||
|
||||
hb_font_t *font = hb_font_create (parent->face);
|
||||
|
||||
if (unlikely (hb_object_is_inert (font)))
|
||||
return font;
|
||||
|
||||
hb_font_make_immutable (parent);
|
||||
font->parent = hb_font_reference (parent);
|
||||
|
||||
font->x_scale = parent->x_scale;
|
||||
font->y_scale = parent->y_scale;
|
||||
font->x_ppem = parent->x_ppem;
|
||||
font->y_ppem = parent->y_ppem;
|
||||
|
||||
/* We can safely copy user_data from parent since we hold a reference
|
||||
* onto it and it's immutable. We should not copy the destroy notifiers
|
||||
* though. */
|
||||
font->klass = hb_font_funcs_reference (parent->klass);
|
||||
font->user_data = parent->user_data;
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
hb_font_t *
|
||||
hb_font_reference (hb_font_t *font)
|
||||
{
|
||||
@ -492,6 +521,7 @@ hb_font_destroy (hb_font_t *font)
|
||||
{
|
||||
if (!hb_object_destroy (font)) return;
|
||||
|
||||
hb_font_destroy (font->parent);
|
||||
hb_face_destroy (font->face);
|
||||
hb_font_funcs_destroy (font->klass);
|
||||
if (font->destroy)
|
||||
@ -531,6 +561,11 @@ hb_font_is_immutable (hb_font_t *font)
|
||||
return font->immutable;
|
||||
}
|
||||
|
||||
hb_font_t *
|
||||
hb_font_get_parent (hb_font_t *font)
|
||||
{
|
||||
return font->parent;
|
||||
}
|
||||
|
||||
hb_face_t *
|
||||
hb_font_get_face (hb_font_t *font)
|
||||
|
@ -208,6 +208,9 @@ hb_font_get_kerning (hb_font_t *font,
|
||||
hb_font_t *
|
||||
hb_font_create (hb_face_t *face);
|
||||
|
||||
hb_font_t *
|
||||
hb_font_create_sub_font (hb_font_t *parent);
|
||||
|
||||
hb_font_t *
|
||||
hb_font_reference (hb_font_t *font);
|
||||
|
||||
@ -231,6 +234,8 @@ hb_font_make_immutable (hb_font_t *font);
|
||||
hb_bool_t
|
||||
hb_font_is_immutable (hb_font_t *font);
|
||||
|
||||
hb_font_t *
|
||||
hb_font_get_parent (hb_font_t *font);
|
||||
|
||||
hb_face_t *
|
||||
hb_font_get_face (hb_font_t *font);
|
||||
|
@ -51,7 +51,7 @@ hb_unicode_funcs_get_default (void);
|
||||
|
||||
|
||||
hb_unicode_funcs_t *
|
||||
hb_unicode_funcs_create (hb_unicode_funcs_t *parent_funcs);
|
||||
hb_unicode_funcs_create (hb_unicode_funcs_t *parent);
|
||||
|
||||
hb_unicode_funcs_t *
|
||||
hb_unicode_funcs_reference (hb_unicode_funcs_t *ufuncs);
|
||||
|
Loading…
Reference in New Issue
Block a user