[font] Load named-instance if face index top bits are set
This matches FreeType behavior. Fixes https://github.com/harfbuzz/harfbuzz/issues/3348
This commit is contained in:
parent
da7dba0002
commit
2d42fc9fbb
|
@ -205,6 +205,10 @@ _hb_face_for_data_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void
|
|||
* is ignored. Otherwise, only the lower 16-bits of @index are used.
|
||||
* The unmodified @index can be accessed via hb_face_get_index().</note>
|
||||
*
|
||||
* <note>Note: The high 16-bits of @index, if non-zero, are used by
|
||||
* hb_font_create() to load named-instances in variable fonts. See
|
||||
* hb_font_create() for details.</note>
|
||||
*
|
||||
* Return value: (transfer full): The new face object
|
||||
*
|
||||
* Since: 0.9.2
|
||||
|
|
|
@ -1521,6 +1521,13 @@ _hb_font_create (hb_face_t *face)
|
|||
*
|
||||
* Constructs a new font object from the specified face.
|
||||
*
|
||||
* <note>Note: If @face's index value (as passed to hb_face_create()
|
||||
* has non-zero top 16-bits, those bits minus one are passed to
|
||||
* hb_font_set_var_named_instance(), effectively loading a named-instance
|
||||
* of a variable font, instead of the default-instance. This allows
|
||||
* specifying which named-instance to load by default when creating the
|
||||
* face.</note>
|
||||
*
|
||||
* Return value: (transfer full): The new font object
|
||||
*
|
||||
* Since: 0.9.2
|
||||
|
@ -1535,6 +1542,9 @@ hb_font_create (hb_face_t *face)
|
|||
hb_ot_font_set_funcs (font);
|
||||
#endif
|
||||
|
||||
if (face && face->index >> 16)
|
||||
hb_font_set_var_named_instance (font, (face->index >> 16) - 1);
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue