diff options
author | Mattias Andrée <m@maandree.se> | 2024-10-13 11:17:48 +0200 |
---|---|---|
committer | Mattias Andrée <m@maandree.se> | 2024-10-13 11:17:48 +0200 |
commit | a81c96c0348af8caf6ae45e2d942a676792a2a31 (patch) | |
tree | 24cc725efa3eba381c98ebed7cb2cbf7e0e34f0c /libparsepcf_get_accelerators.c | |
parent | Update e-mail (diff) | |
download | libparsepcf-a81c96c0348af8caf6ae45e2d942a676792a2a31.tar.gz libparsepcf-a81c96c0348af8caf6ae45e2d942a676792a2a31.tar.bz2 libparsepcf-a81c96c0348af8caf6ae45e2d942a676792a2a31.tar.xz |
Documentation and minor improvements
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libparsepcf_get_accelerators.c')
-rw-r--r-- | libparsepcf_get_accelerators.c | 73 |
1 files changed, 37 insertions, 36 deletions
diff --git a/libparsepcf_get_accelerators.c b/libparsepcf_get_accelerators.c index b9688b7..66c8f2f 100644 --- a/libparsepcf_get_accelerators.c +++ b/libparsepcf_get_accelerators.c @@ -3,10 +3,11 @@ int -libparsepcf_get_accelerators(const char *file, size_t size, +libparsepcf_get_accelerators(const void *file, size_t size, const struct libparsepcf_table *table, struct libparsepcf_accelerators *out) { + const char *text = file; int msb = table->format & LIBPARSEPCF_BYTE; int with_ink_bounds = table->format & LIBPARSEPCF_ACCELERATOR_WITH_INK_BOUNDS; size_t pos; @@ -18,56 +19,56 @@ libparsepcf_get_accelerators(const char *file, size_t size, pos = table->offset; - if (table->format != libparsepcf_parse_lsb_uint32__(&file[pos])) + if (table->format != libparsepcf_parse_lsb_uint32__(&text[pos])) goto ebfont; pos += 4; - out->no_overlap = !!file[pos + 0]; - out->constant_metrics = !!file[pos + 1]; - out->terminal_font = !!file[pos + 2]; - out->constant_width = !!file[pos + 3]; - out->ink_inside = !!file[pos + 4]; - out->ink_metrics = !!file[pos + 5]; - out->draw_rtl = !!file[pos + 6]; + out->no_overlap = !!text[pos + 0]; + out->constant_metrics = !!text[pos + 1]; + out->terminal_font = !!text[pos + 2]; + out->constant_width = !!text[pos + 3]; + out->ink_inside = !!text[pos + 4]; + out->ink_metrics = !!text[pos + 5]; + out->draw_rtl = !!text[pos + 6]; out->have_ink_bounds = !!with_ink_bounds; pos += 8; - out->font_ascent = PARSE_INT32(&file[pos + 0], msb); - out->font_descent = PARSE_INT32(&file[pos + 4], msb); - out->max_overlap = PARSE_INT32(&file[pos + 8], msb); + out->font_ascent = PARSE_INT32(&text[pos + 0], msb); + out->font_descent = PARSE_INT32(&text[pos + 4], msb); + out->max_overlap = PARSE_INT32(&text[pos + 8], msb); pos += 12; - out->min_bounds.left_side_bearing = PARSE_INT16(&file[pos + 0], msb); - out->min_bounds.right_side_bearing = PARSE_INT16(&file[pos + 2], msb); - out->min_bounds.character_width = PARSE_INT16(&file[pos + 4], msb); - out->min_bounds.character_ascent = PARSE_INT16(&file[pos + 6], msb); - out->min_bounds.character_descent = PARSE_INT16(&file[pos + 8], msb); - out->min_bounds.character_attributes = PARSE_UINT16(&file[pos + 10], msb); + out->min_bounds.left_side_bearing = PARSE_INT16(&text[pos + 0], msb); + out->min_bounds.right_side_bearing = PARSE_INT16(&text[pos + 2], msb); + out->min_bounds.character_width = PARSE_INT16(&text[pos + 4], msb); + out->min_bounds.character_ascent = PARSE_INT16(&text[pos + 6], msb); + out->min_bounds.character_descent = PARSE_INT16(&text[pos + 8], msb); + out->min_bounds.character_attributes = PARSE_UINT16(&text[pos + 10], msb); pos += 12; - out->max_bounds.left_side_bearing = PARSE_INT16(&file[pos + 0], msb); - out->max_bounds.right_side_bearing = PARSE_INT16(&file[pos + 2], msb); - out->max_bounds.character_width = PARSE_INT16(&file[pos + 4], msb); - out->max_bounds.character_ascent = PARSE_INT16(&file[pos + 6], msb); - out->max_bounds.character_descent = PARSE_INT16(&file[pos + 8], msb); - out->max_bounds.character_attributes = PARSE_UINT16(&file[pos + 10], msb); + out->max_bounds.left_side_bearing = PARSE_INT16(&text[pos + 0], msb); + out->max_bounds.right_side_bearing = PARSE_INT16(&text[pos + 2], msb); + out->max_bounds.character_width = PARSE_INT16(&text[pos + 4], msb); + out->max_bounds.character_ascent = PARSE_INT16(&text[pos + 6], msb); + out->max_bounds.character_descent = PARSE_INT16(&text[pos + 8], msb); + out->max_bounds.character_attributes = PARSE_UINT16(&text[pos + 10], msb); pos += 12; if (with_ink_bounds) { - out->min_ink_bounds.left_side_bearing = PARSE_INT16(&file[pos + 0], msb); - out->min_ink_bounds.right_side_bearing = PARSE_INT16(&file[pos + 2], msb); - out->min_ink_bounds.character_width = PARSE_INT16(&file[pos + 4], msb); - out->min_ink_bounds.character_ascent = PARSE_INT16(&file[pos + 6], msb); - out->min_ink_bounds.character_descent = PARSE_INT16(&file[pos + 8], msb); - out->min_ink_bounds.character_attributes = PARSE_UINT16(&file[pos + 10], msb); + out->min_ink_bounds.left_side_bearing = PARSE_INT16(&text[pos + 0], msb); + out->min_ink_bounds.right_side_bearing = PARSE_INT16(&text[pos + 2], msb); + out->min_ink_bounds.character_width = PARSE_INT16(&text[pos + 4], msb); + out->min_ink_bounds.character_ascent = PARSE_INT16(&text[pos + 6], msb); + out->min_ink_bounds.character_descent = PARSE_INT16(&text[pos + 8], msb); + out->min_ink_bounds.character_attributes = PARSE_UINT16(&text[pos + 10], msb); pos += 12; - out->max_ink_bounds.left_side_bearing = PARSE_INT16(&file[pos + 0], msb); - out->max_ink_bounds.right_side_bearing = PARSE_INT16(&file[pos + 2], msb); - out->max_ink_bounds.character_width = PARSE_INT16(&file[pos + 4], msb); - out->max_ink_bounds.character_ascent = PARSE_INT16(&file[pos + 6], msb); - out->max_ink_bounds.character_descent = PARSE_INT16(&file[pos + 8], msb); - out->max_ink_bounds.character_attributes = PARSE_UINT16(&file[pos + 10], msb); + out->max_ink_bounds.left_side_bearing = PARSE_INT16(&text[pos + 0], msb); + out->max_ink_bounds.right_side_bearing = PARSE_INT16(&text[pos + 2], msb); + out->max_ink_bounds.character_width = PARSE_INT16(&text[pos + 4], msb); + out->max_ink_bounds.character_ascent = PARSE_INT16(&text[pos + 6], msb); + out->max_ink_bounds.character_descent = PARSE_INT16(&text[pos + 8], msb); + out->max_ink_bounds.character_attributes = PARSE_UINT16(&text[pos + 10], msb); pos += 12; } else { memcpy(&out->min_ink_bounds, &out->min_bounds, sizeof(out->min_bounds)); |