summaryrefslogtreecommitdiffstats
path: root/sbix.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-08-25 16:15:14 +0200
committerMattias Andrée <maandree@kth.se>2021-08-25 16:15:14 +0200
commitf7cb0e83cc7462741a04fac4e2e2f26be00cd9e1 (patch)
tree41fb1e5f8b41ced7abd14990acfab520a2a87713 /sbix.c
parentAdd post + fix indention in hdmx (diff)
downloadlibparsesfnt-f7cb0e83cc7462741a04fac4e2e2f26be00cd9e1.tar.gz
libparsesfnt-f7cb0e83cc7462741a04fac4e2e2f26be00cd9e1.tar.bz2
libparsesfnt-f7cb0e83cc7462741a04fac4e2e2f26be00cd9e1.tar.xz
Add cmpa, bloc, bdat, sbix, and EBSC + minor fix + add language and encoding IDs
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'sbix.c')
-rw-r--r--sbix.c132
1 files changed, 132 insertions, 0 deletions
diff --git a/sbix.c b/sbix.c
new file mode 100644
index 0000000..5bc67ca
--- /dev/null
+++ b/sbix.c
@@ -0,0 +1,132 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+
+int
+libparsesfnt_parse_sbix(
+ const char *data, size_t size,
+ struct libparsesfnt_sbix *infop,
+ const struct libparsesfnt_tabdir_entry *tag)
+{
+ return PARSE(LIBPARSESFNT_SBIX__, tag->offset, 0, 0, 0, 1, tag);
+}
+
+
+int
+libparsesfnt_parse_sbix_v1_strike_offset_entries(
+ const char *data, size_t size,
+ uint32_t *infop,
+ const struct libparsesfnt_tabdir_entry *tag,
+ size_t first, size_t count)
+{
+ return PARSE("4", tag->offset, 8, 0, first, count, tag);
+}
+
+
+int
+libparsesfnt_parse_sbix_v1_strike_entry(
+ const char *data, size_t size,
+ struct libparsesfnt_sbix_v1_strike_entry *infop,
+ const struct libparsesfnt_tabdir_entry *tag, size_t strike_offset)
+{
+ return PARSE(LIBPARSESFNT_SBIX_V1_STRIKE_ENTRY__, tag->offset, strike_offset, 0, 0, 1, tag);
+}
+
+
+int
+libparsesfnt_parse_sbix_v1_glyph_data_offset_entries(
+ const char *data, size_t size,
+ uint32_t *infop,
+ const struct libparsesfnt_tabdir_entry *tag, size_t strike_offset,
+ size_t first, size_t count)
+{
+ return PARSE("4", tag->offset, strike_offset, 4, first, count, tag);
+}
+
+
+int
+libparsesfnt_parse_sbix_v1_glyph_data_entry(
+ const char *data, size_t size,
+ struct libparsesfnt_sbix_v1_glyph_data_entry *infop,
+ const struct libparsesfnt_tabdir_entry *tag,
+ size_t strike_offset, size_t glyph_data_offset, size_t next_glyphs_data_offset)
+{
+ int ret;
+ size_t image_data_length;
+ if (next_glyphs_data_offset < glyph_data_offset)
+ goto ebfont;
+ image_data_length = next_glyphs_data_offset - glyph_data_offset;
+ if (!image_data_length) {
+ errno = EINVAL;
+ return -1;
+ } else if (image_data_length < 8) {
+ goto ebfont;
+ }
+ ret = PARSE(LIBPARSESFNT_SBIX_V1_GLYPH_DATA_ENTRY__, tag->offset, strike_offset, glyph_data_offset, 0, 1, tag);
+ if (!ret) {
+ infop->libparsesfnt_image_data_offset = (size_t)tag->offset + (size_t)strike_offset + (size_t)glyph_data_offset + 8;
+ infop->libparsesfnt_image_data_length = image_data_length - 8;
+ if (infop->libparsesfnt_image_data_length > size - infop->libparsesfnt_image_data_offset)
+ goto ebfont;
+ }
+ return ret;
+
+ebfont:
+ errno = EBFONT;
+ return -1;
+}
+
+
+int
+libparsesfnt_parse_sbix_v1_image_data_dupe(
+ const char *data, size_t size,
+ struct libparsesfnt_sbix_v1_image_data_dupe *infop,
+ const struct libparsesfnt_sbix_v1_glyph_data_entry *glyph_data)
+{
+ return PARSE(LIBPARSESFNT_SBIX_V1_IMAGE_DATA_DUPE__, glyph_data->libparsesfnt_image_data_offset, 0, 0, 0, 1, NULL);
+}
+
+
+int
+libparsesfnt_parse_sbix_v1_image_data_mask(
+ const char *data, size_t size,
+ struct libparsesfnt_sbix_v1_image_data_mask *infop,
+ const struct libparsesfnt_sbix_v1_glyph_data_entry *glyph_data)
+{
+ int ret;
+ if (glyph_data->libparsesfnt_image_data_length < 8 ||
+ glyph_data->libparsesfnt_image_data_offset > SIZE_MAX - 8)
+ goto ebfont;
+ ret = PARSE(LIBPARSESFNT_SBIX_V1_IMAGE_DATA_MASK__, glyph_data->libparsesfnt_image_data_offset, 0, 0, 0, 1, NULL);
+ if (!ret) {
+ infop->libparsesfnt_image_data_offset = glyph_data->libparsesfnt_image_data_offset + 8;
+ infop->libparsesfnt_image_data_length = glyph_data->libparsesfnt_image_data_length - 8;
+ if (infop->libparsesfnt_image_data_length > size - infop->libparsesfnt_image_data_offset)
+ goto ebfont;
+ }
+ return ret;
+
+ebfont:
+ errno = EBFONT;
+ return -1;
+}
+
+
+int
+libparsesfnt_parse_sbix_v1_mask(
+ const char *data, size_t size,
+ struct libparsesfnt_sbix_v1_mask *infop,
+ const struct libparsesfnt_tabdir_entry *tag,
+ const struct libparsesfnt_sbix_v1_image_data_mask *image_data)
+{
+ int ret;
+ ret = PARSE(LIBPARSESFNT_SBIX_V1_MASK__, tag->offset, image_data->mask_offset, 0, 0, 1, NULL);
+ if (!ret) {
+ infop->libparsesfnt_mask_offset = (size_t)tag->offset + (size_t)image_data->mask_offset + 16;
+ if ((size_t)infop->mask_length > size - infop->libparsesfnt_mask_offset) {
+ errno = EBFONT;
+ return -1;
+ }
+ }
+ return ret;
+}