[face] Clarify face_index handling

Fixes https://github.com/harfbuzz/harfbuzz/issues/3347
This commit is contained in:
Behdad Esfahbod 2022-01-01 11:20:20 -07:00
parent 6da4b80e5f
commit da7dba0002
1 changed files with 13 additions and 6 deletions

View File

@ -143,7 +143,7 @@ hb_face_create_for_tables (hb_reference_table_func_t reference_table_func,
typedef struct hb_face_for_data_closure_t {
hb_blob_t *blob;
unsigned int index;
uint16_t index;
} hb_face_for_data_closure_t;
static hb_face_for_data_closure_t *
@ -156,7 +156,7 @@ _hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index)
return nullptr;
closure->blob = blob;
closure->index = index;
closure->index = (uint16_t) (index & 0xFFFFu);
return closure;
}
@ -195,9 +195,15 @@ _hb_face_for_data_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void
* @index: The index of the face within @blob
*
* Constructs a new face object from the specified blob and
* a face index into that blob. This is used for blobs of
* file formats such as Dfont and TTC that can contain more
* than one face.
* a face index into that blob.
*
* The face index is used for blobs of file formats such as TTC and
* and DFont that can contain more than one face. Face indices within
* such collections are zero-based.
*
* <note>Note: If the blob font format is not a collection, @index
* is ignored. Otherwise, only the lower 16-bits of @index are used.
* The unmodified @index can be accessed via hb_face_get_index().</note>
*
* Return value: (transfer full): The new face object
*
@ -420,7 +426,8 @@ hb_face_reference_blob (hb_face_t *face)
* Assigns the specified face-index to @face. Fails if the
* face is immutable.
*
* <note>Note: face indices within a collection are zero-based.</note>
* <note>Note: changing the index has no effect on the face itself
* This only changes the value returned by hb_face_get_index().</note>
*
* Since: 0.9.2
**/