From c076c7b85ce4d069ae8b2b04143aca4c4f052ae9 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 19 Nov 2018 11:30:40 -0500 Subject: [PATCH 01/15] [ot-var] Use hb_ot_name_id_t --- src/hb-ot-var.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-ot-var.h b/src/hb-ot-var.h index a2c0c5f2b..0c0f61dd3 100644 --- a/src/hb-ot-var.h +++ b/src/hb-ot-var.h @@ -54,7 +54,7 @@ HB_BEGIN_DECLS */ typedef struct hb_ot_var_axis_t { hb_tag_t tag; - unsigned int name_id; + hb_ot_name_id_t name_id; float min_value; float default_value; float max_value; From bd6b2ba1d3910cc259db7abeb6c9bd7ed9494857 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 19 Nov 2018 11:34:56 -0500 Subject: [PATCH 02/15] [ot-var] Add flags Unfortunate that we don't have room in hb_ot_var_axis_t to expose flags :(. --- src/hb-ot-var-fvar-table.hh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index 6d229c386..659eb1b6d 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -52,7 +52,7 @@ struct InstanceRecord protected: NameID subfamilyNameID;/* The name ID for entries in the 'name' table * that provide subfamily names for this instance. */ - HBUINT16 reserved; /* Reserved for future use — set to 0. */ + HBUINT16 flags; /* Reserved for future use — set to 0. */ UnsizedArrayOf coordinatesZ; /* The coordinates array for this instance. */ //NameID postScriptNameIDX;/*Optional. The name ID for entries in the 'name' @@ -65,6 +65,11 @@ struct InstanceRecord struct AxisRecord { + enum + { + AXIS_FLAG_HIDDEN = 0x0001, + }; + inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); @@ -76,7 +81,7 @@ struct AxisRecord Fixed minValue; /* The minimum coordinate value for the axis. */ Fixed defaultValue; /* The default coordinate value for the axis. */ Fixed maxValue; /* The maximum coordinate value for the axis. */ - HBUINT16 reserved; /* Reserved for future use — set to 0. */ + HBUINT16 flags; /* Axis flags. */ NameID axisNameID; /* The name ID for entries in the 'name' table that * provide a display name for this axis. */ From 1a2eb108b857de9c5e84cc5de0c12c7657e04498 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 19 Nov 2018 12:36:56 -0500 Subject: [PATCH 03/15] [ot-var] Add hb_ot_var_axis_get_flags() Part of https://github.com/harfbuzz/harfbuzz/issues/1241 New API: +hb_ot_var_axis_flags_t +hb_ot_var_axis_get_flags --- docs/harfbuzz-sections.txt | 2 ++ src/hb-buffer.h | 2 ++ src/hb-ot-var-fvar-table.hh | 9 +++++++++ src/hb-ot-var.cc | 12 ++++++++++++ src/hb-ot-var.h | 13 +++++++++++++ 5 files changed, 38 insertions(+) diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt index 6a498e940..63594cfcd 100644 --- a/docs/harfbuzz-sections.txt +++ b/docs/harfbuzz-sections.txt @@ -587,6 +587,8 @@ hb_ot_var_has_data hb_ot_var_find_axis hb_ot_var_get_axis_count hb_ot_var_get_axes +hb_ot_var_axis_flags_t +hb_ot_var_axis_get_flags hb_ot_var_normalize_variations hb_ot_var_normalize_coords diff --git a/src/hb-buffer.h b/src/hb-buffer.h index 99e01716f..f989d25d6 100644 --- a/src/hb-buffer.h +++ b/src/hb-buffer.h @@ -90,6 +90,8 @@ typedef struct hb_glyph_info_t * the reshaping to a small piece around the * breaking point only. * @HB_GLYPH_FLAG_DEFINED: All the currently defined flags. + * + * Since: 1.5.0 */ typedef enum { /*< flags >*/ HB_GLYPH_FLAG_UNSAFE_TO_BREAK = 0x00000001, diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index 659eb1b6d..3c8a3da4a 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -131,6 +131,15 @@ struct fvar return true; } + inline hb_ot_var_axis_flags_t get_axis_flags (unsigned int index) const + { + if (unlikely (index >= axisCount)) + return (hb_ot_var_axis_flags_t) 0; + + const AxisRecord &axis = get_axes ()[index]; + return (hb_ot_var_axis_flags_t) (unsigned int) axis.flags; + } + inline unsigned int get_axis_infos (unsigned int start_offset, unsigned int *axes_count /* IN/OUT */, hb_ot_var_axis_t *axes_array /* OUT */) const diff --git a/src/hb-ot-var.cc b/src/hb-ot-var.cc index c97e9c494..14c73cfd8 100644 --- a/src/hb-ot-var.cc +++ b/src/hb-ot-var.cc @@ -104,6 +104,18 @@ hb_ot_var_find_axis (hb_face_t *face, return face->table.fvar->find_axis (axis_tag, axis_index, axis_info); } +/** + * hb_ot_var_axis_get_flags: + * + * Since: REPLACEME + **/ +hb_ot_var_axis_flags_t +hb_ot_var_axis_get_flags (hb_face_t *face, + unsigned int axis_index) +{ + return face->table.fvar->get_axis_flags (axis_index); +} + /** * hb_ot_var_normalize_variations: diff --git a/src/hb-ot-var.h b/src/hb-ot-var.h index 0c0f61dd3..d535a078b 100644 --- a/src/hb-ot-var.h +++ b/src/hb-ot-var.h @@ -85,6 +85,19 @@ hb_ot_var_find_axis (hb_face_t *face, unsigned int *axis_index, hb_ot_var_axis_t *axis_info); +/** + * hb_ot_var_axis_flags_t: + * @HB_OT_VAR_AXIS_FLAG_HIDDEN: The axis should not be exposed directly in user interfaces. + * + * Since: REPLACEME + */ +typedef enum { /*< flags >*/ + HB_OT_VAR_AXIS_FLAG_HIDDEN = 0x0001u, +} hb_ot_var_axis_flags_t; + +HB_EXTERN hb_ot_var_axis_flags_t +hb_ot_var_axis_get_flags (hb_face_t *face, + unsigned int axis_index); HB_EXTERN void hb_ot_var_normalize_variations (hb_face_t *face, From e0097396010c40cf62641cd12ceb12dd5d79c9c7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 19 Nov 2018 12:53:53 -0500 Subject: [PATCH 04/15] [fvar] Minor --- src/hb-ot-var-fvar-table.hh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index 3c8a3da4a..66618a5a1 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -104,8 +104,8 @@ struct fvar instanceSize >= axisCount * 4 + 4 && axisSize <= 1024 && /* Arbitrary, just to simplify overflow checks. */ instanceSize <= 1024 && /* Arbitrary, just to simplify overflow checks. */ - c->check_range (this, things) && - c->check_range (&StructAtOffset (this, things), + c->check_range (this, firstAxis) && + c->check_range (&StructAtOffset (this, firstAxis), axisCount * axisSize + instanceCount * instanceSize)); } @@ -196,7 +196,7 @@ struct fvar protected: inline const AxisRecord * get_axes (void) const - { return &StructAtOffset (this, things); } + { return &(this+firstAxis); } inline const InstanceRecord * get_instances (void) const { return &StructAtOffset (get_axes () + axisCount, 0); } @@ -204,7 +204,8 @@ struct fvar protected: FixedVersion<>version; /* Version of the fvar table * initially set to 0x00010000u */ - Offset16 things; /* Offset in bytes from the beginning of the table + OffsetTo + firstAxis; /* Offset in bytes from the beginning of the table * to the start of the AxisRecord array. */ HBUINT16 reserved; /* This field is permanently reserved. Set to 2. */ HBUINT16 axisCount; /* The number of variation axes in the font (the From 4a6a692e3ea4fab632a0162c6d513dc151054d8f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 19 Nov 2018 13:04:43 -0500 Subject: [PATCH 05/15] [fvar] Use hb_array_t for axes --- src/hb-dsalgs.hh | 6 ++++++ src/hb-ot-var-fvar-table.hh | 14 ++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index 7a207f5d2..8e59fdee4 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -573,6 +573,10 @@ struct hb_array_t inline unsigned int get_size (void) const { return len * sizeof (Type); } + template + inline bool sanitize (hb_sanitize_context_t *c) const + { return c->check_array (arrayZ, len); } + template inline operator T * (void) const { return arrayZ; } inline Type * operator & (void) const { return arrayZ; } @@ -598,6 +602,8 @@ struct hb_array_t Type *arrayZ; unsigned int len; }; +template +hb_array_t hb_array (T *array, unsigned int len) { return hb_array_t (array, len); } struct HbOpOr diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index 66618a5a1..b4fdd5fad 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -114,9 +114,6 @@ struct fvar inline bool get_axis (unsigned int index, hb_ot_var_axis_t *info) const { - if (unlikely (index >= axisCount)) - return false; - if (info) { const AxisRecord &axis = get_axes ()[index]; @@ -133,9 +130,6 @@ struct fvar inline hb_ot_var_axis_flags_t get_axis_flags (unsigned int index) const { - if (unlikely (index >= axisCount)) - return (hb_ot_var_axis_flags_t) 0; - const AxisRecord &axis = get_axes ()[index]; return (hb_ot_var_axis_flags_t) (unsigned int) axis.flags; } @@ -195,11 +189,11 @@ struct fvar } protected: - inline const AxisRecord * get_axes (void) const - { return &(this+firstAxis); } + inline hb_array_t get_axes (void) const + { return hb_array (&(this+firstAxis), axisCount); } - inline const InstanceRecord * get_instances (void) const - { return &StructAtOffset (get_axes () + axisCount, 0); } + inline const InstanceRecord * get_first_instance (void) const + { return &StructAfter (get_axes ()); } protected: FixedVersion<>version; /* Version of the fvar table From 56c9238d3da8c034336cf80ba37e03e33c493718 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 19 Nov 2018 13:09:53 -0500 Subject: [PATCH 06/15] [fvar] Rewrite sanitize --- src/hb-ot-var-fvar-table.hh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index b4fdd5fad..99d2fd5cd 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -101,12 +101,10 @@ struct fvar return_trace (version.sanitize (c) && likely (version.major == 1) && c->check_struct (this) && + axisSize == 20 && /* Assumed in our code. */ instanceSize >= axisCount * 4 + 4 && - axisSize <= 1024 && /* Arbitrary, just to simplify overflow checks. */ - instanceSize <= 1024 && /* Arbitrary, just to simplify overflow checks. */ - c->check_range (this, firstAxis) && - c->check_range (&StructAtOffset (this, firstAxis), - axisCount * axisSize + instanceCount * instanceSize)); + get_axes ().sanitize (c) && + c->check_range (get_first_instance (), instanceCount, instanceSize)); } inline unsigned int get_axis_count (void) const From 46c0da820fc313bad8afaf019d2cd9065fa5f514 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 19 Nov 2018 13:32:48 -0500 Subject: [PATCH 07/15] Fix build --- src/hb-dsalgs.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index 8e59fdee4..da8aad013 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -603,7 +603,7 @@ struct hb_array_t unsigned int len; }; template -hb_array_t hb_array (T *array, unsigned int len) { return hb_array_t (array, len); } +inline hb_array_t hb_array (T *array, unsigned int len) { return hb_array_t (array, len); } struct HbOpOr From 587d49fc657c10c8a20f2409a04d72bf80bb361e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 19 Nov 2018 14:27:19 -0500 Subject: [PATCH 08/15] [fvar] Add named-instance API Fixes https://github.com/harfbuzz/harfbuzz/issues/1241 --- docs/harfbuzz-sections.txt | 4 +++ src/hb-ot-var-fvar-table.hh | 55 +++++++++++++++++++++++++++++++++++-- src/hb-ot-var.cc | 33 ++++++++++++++++++++++ src/hb-ot-var.h | 32 +++++++++++++++++++++ 4 files changed, 121 insertions(+), 3 deletions(-) diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt index 63594cfcd..63d5f6cef 100644 --- a/docs/harfbuzz-sections.txt +++ b/docs/harfbuzz-sections.txt @@ -589,6 +589,10 @@ hb_ot_var_get_axis_count hb_ot_var_get_axes hb_ot_var_axis_flags_t hb_ot_var_axis_get_flags +hb_ot_var_get_named_instance_count +hb_ot_var_named_instance_get_subfamily_name_id +hb_ot_var_named_instance_get_postscript_name_id +hb_ot_var_named_instance_get_design_coords hb_ot_var_normalize_variations hb_ot_var_normalize_coords diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index 99d2fd5cd..f61296d1b 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -42,6 +42,11 @@ namespace OT { struct InstanceRecord { + friend struct fvar; + + inline hb_array_t get_coordinates (unsigned int axis_count) const + { return coordinatesZ.as_array (axis_count); } + inline bool sanitize (hb_sanitize_context_t *c, unsigned int axis_count) const { TRACE_SANITIZE (this); @@ -104,7 +109,7 @@ struct fvar axisSize == 20 && /* Assumed in our code. */ instanceSize >= axisCount * 4 + 4 && get_axes ().sanitize (c) && - c->check_range (get_first_instance (), instanceCount, instanceSize)); + c->check_range (&get_instance (0), instanceCount, instanceSize)); } inline unsigned int get_axis_count (void) const @@ -186,12 +191,56 @@ struct fvar return (int) (v * 16384.f + (v >= 0.f ? .5f : -.5f)); } + inline unsigned int get_instance_count (void) const + { return instanceCount; } + + inline hb_ot_name_id_t get_instance_subfamily_name_id (unsigned int index) const + { + const InstanceRecord &instance = get_instance (index); + return instance.subfamilyNameID; + } + + inline hb_ot_name_id_t get_instance_postscript_name_id (unsigned int index) const + { + const InstanceRecord &instance = get_instance (index); + if (instanceSize >= axisCount * 4 + 6) + return StructAfter (instance.get_coordinates (axisCount)); + return HB_OT_NAME_ID_INVALID; + } + + inline unsigned int get_instance_coords (unsigned int index, + unsigned int *coords_length, /* IN/OUT */ + int *coords /* OUT */) const + { + if (unlikely (index >= instanceCount)) + { + if (coords_length) + *coords_length = 0; + return 0; + } + + if (coords_length && *coords_length) + { + const InstanceRecord &instance = get_instance (index); + hb_array_t instanceCoords = instance.get_coordinates (axisCount) + .sub_array (0, *coords_length); + for (unsigned int i = 0; i < instanceCoords.len; i++) + coords[i] = instanceCoords.arrayZ[i].to_float (); + } + return axisCount; + } + protected: inline hb_array_t get_axes (void) const { return hb_array (&(this+firstAxis), axisCount); } - inline const InstanceRecord * get_first_instance (void) const - { return &StructAfter (get_axes ()); } + inline const InstanceRecord &get_instance (unsigned int i) const + { + if (unlikely (i >= instanceCount)) return Null (InstanceRecord); + + return StructAtOffset (&StructAfter (get_axes ()), + i * instanceSize); + } protected: FixedVersion<>version; /* Version of the fvar table diff --git a/src/hb-ot-var.cc b/src/hb-ot-var.cc index 14c73cfd8..bb8d26490 100644 --- a/src/hb-ot-var.cc +++ b/src/hb-ot-var.cc @@ -116,6 +116,39 @@ hb_ot_var_axis_get_flags (hb_face_t *face, return face->table.fvar->get_axis_flags (axis_index); } +/* + * Named instances. + */ + +unsigned int +hb_ot_var_get_named_instance_count (hb_face_t *face) +{ + return face->table.fvar->get_instance_count (); +} + +hb_ot_name_id_t +hb_ot_var_named_instance_get_subfamily_name_id (hb_face_t *face, + unsigned int instance_index) +{ + return face->table.fvar->get_instance_subfamily_name_id (instance_index); +} + +hb_ot_name_id_t +hb_ot_var_named_instance_get_postscript_name_id (hb_face_t *face, + unsigned int instance_index) +{ + return face->table.fvar->get_instance_postscript_name_id (instance_index); +} + +unsigned int +hb_ot_var_named_instance_get_design_coords (hb_face_t *face, + unsigned int instance_index, + unsigned int *coords_length, /* IN/OUT */ + int *coords /* OUT */) +{ + return face->table.fvar->get_instance_coords (instance_index, coords_length, coords); +} + /** * hb_ot_var_normalize_variations: diff --git a/src/hb-ot-var.h b/src/hb-ot-var.h index d535a078b..e0ac5c4a2 100644 --- a/src/hb-ot-var.h +++ b/src/hb-ot-var.h @@ -63,6 +63,11 @@ typedef struct hb_ot_var_axis_t { HB_EXTERN hb_bool_t hb_ot_var_has_data (hb_face_t *face); + +/* + * Variation axes. + */ + /** * HB_OT_VAR_NO_AXIS_INDEX: * @@ -99,6 +104,33 @@ HB_EXTERN hb_ot_var_axis_flags_t hb_ot_var_axis_get_flags (hb_face_t *face, unsigned int axis_index); + +/* + * Named instances. + */ + +HB_EXTERN unsigned int +hb_ot_var_get_named_instance_count (hb_face_t *face); + +HB_EXTERN hb_ot_name_id_t +hb_ot_var_named_instance_get_subfamily_name_id (hb_face_t *face, + unsigned int instance_index); + +HB_EXTERN hb_ot_name_id_t +hb_ot_var_named_instance_get_postscript_name_id (hb_face_t *face, + unsigned int instance_index); + +HB_EXTERN unsigned int +hb_ot_var_named_instance_get_design_coords (hb_face_t *face, + unsigned int instance_index, + unsigned int *coords_length, /* IN/OUT */ + int *coords /* OUT */); + + +/* + * Conversions. + */ + HB_EXTERN void hb_ot_var_normalize_variations (hb_face_t *face, const hb_variation_t *variations, /* IN */ From 96b24c5124a085b7601215360eed847ce5302699 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 20 Nov 2018 01:03:42 -0500 Subject: [PATCH 09/15] [travis] Add codecov.io --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index eadfa7679..7f4bb47f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,7 @@ matrix: - rm -rf freetype-2.9 after_success: - bash .ci/run-coveralls.sh # for coveralls.io code coverage tracking + - bash <(curl -s https://codecov.io/bash) - bash .ci/deploy-docs.sh - bash .ci/trigger-coverity.sh From c49e43c1ffee0e9664da6202ace493d932b725a1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 20 Nov 2018 01:06:50 -0500 Subject: [PATCH 10/15] [travis] Another push for codecov.io after setting token --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7f4bb47f7..ef8b01d02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,8 +28,8 @@ matrix: - make check || .ci/fail.sh - rm -rf freetype-2.9 after_success: - - bash .ci/run-coveralls.sh # for coveralls.io code coverage tracking - - bash <(curl -s https://codecov.io/bash) + - bash .ci/run-coveralls.sh # coveralls.io code coverage + - bash <(curl -s https://codecov.io/bash) # codecov.io code coverage - bash .ci/deploy-docs.sh - bash .ci/trigger-coverity.sh From 831ba74382e35f110006539f22bebce4d57c8502 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 20 Nov 2018 01:16:08 -0500 Subject: [PATCH 11/15] Fix Codacy "issues" --- src/test-name-table.cc | 2 +- src/test-ot-color.cc | 14 +++++++------- test/api/test-buffer.c | 5 +++-- test/api/test-object.c | 2 +- test/api/test-ot-name.c | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/test-name-table.cc b/src/test-name-table.cc index 333052729..58c98f07a 100644 --- a/src/test-name-table.cc +++ b/src/test-name-table.cc @@ -48,7 +48,7 @@ main (int argc, char **argv) for (unsigned int i = 0; i < count; i++) { - printf ("%d %s ", + printf ("%u %s ", entries[i].name_id, hb_language_to_string (entries[i].language)); diff --git a/src/test-ot-color.cc b/src/test-ot-color.cc index 4b10e0177..4050a664d 100644 --- a/src/test-ot-color.cc +++ b/src/test-ot-color.cc @@ -54,7 +54,7 @@ svg_dump (hb_face_t *face, unsigned int face_index) const char *data = hb_blob_get_data (blob, &length); char output_path[255]; - sprintf (output_path, "out/svg-%d-%d.svg%s", + sprintf (output_path, "out/svg-%u-%u.svg%s", glyph_id, face_index, // append "z" if the content is gzipped, https://stackoverflow.com/a/6059405 @@ -108,7 +108,7 @@ png_dump (hb_face_t *face, unsigned int face_index) const char *data = hb_blob_get_data (blob, &length); char output_path[255]; - sprintf (output_path, "out/png-%d-%d-%d.png", glyph_id, strike, face_index); + sprintf (output_path, "out/png-%u-%u-%u.png", glyph_id, strike, face_index); FILE *f = fopen (output_path, "wb"); fwrite (data, 1, length, f); @@ -167,9 +167,8 @@ layered_glyph_dump (hb_face_t *face, cairo_font_face_t *cairo_face, unsigned int // Render unsigned int palette_count = hb_ot_color_palette_get_count (face); - for (unsigned int palette = 0; palette < palette_count; palette++) { - char output_path[255]; - + for (unsigned int palette = 0; palette < palette_count; palette++) + { unsigned int num_colors = hb_ot_color_palette_get_colors (face, palette, 0, NULL, NULL); if (!num_colors) continue; @@ -178,7 +177,8 @@ layered_glyph_dump (hb_face_t *face, cairo_font_face_t *cairo_face, unsigned int hb_ot_color_palette_get_colors (face, palette, 0, &num_colors, colors); if (num_colors) { - sprintf (output_path, "out/colr-%d-%d-%d.svg", gid, palette, face_index); + char output_path[255]; + sprintf (output_path, "out/colr-%u-%u-%u.svg", gid, palette, face_index); cairo_surface_t *surface = cairo_svg_surface_create (output_path, extents.width, extents.height); cairo_t *cr = cairo_create (surface); @@ -245,7 +245,7 @@ dump_glyphs (cairo_font_face_t *cairo_face, unsigned int upem, // Render { char output_path[255]; - sprintf (output_path, "out/%d-%d.svg", face_index, i); + sprintf (output_path, "out/%u-%u.svg", face_index, i); cairo_surface_t *surface = cairo_svg_surface_create (output_path, extents.width, extents.height); cairo_t *cr = cairo_create (surface); cairo_set_font_face (cr, cairo_face); diff --git a/test/api/test-buffer.c b/test/api/test-buffer.c index 5fba3b228..64ab3db99 100644 --- a/test/api/test-buffer.c +++ b/test/api/test-buffer.c @@ -379,14 +379,15 @@ static void test_buffer_utf8_conversion (void) { hb_buffer_t *b; - hb_glyph_info_t *glyphs; - unsigned int bytes, chars, i, j, len; + unsigned int chars, i, j, len; b = hb_buffer_create (); hb_buffer_set_replacement_codepoint (b, (hb_codepoint_t) -1); for (i = 0; i < G_N_ELEMENTS (utf8_conversion_tests); i++) { + unsigned int bytes; + hb_glyph_info_t *glyphs; const utf8_conversion_test_t *test = &utf8_conversion_tests[i]; char *escaped; diff --git a/test/api/test-object.c b/test/api/test-object.c index 02b9760d5..093615e8c 100644 --- a/test/api/test-object.c +++ b/test/api/test-object.c @@ -235,7 +235,7 @@ test_object (void) { unsigned int j; - data_t data[2] = {{MAGIC0, FALSE}, {MAGIC1, FALSE}}; + data_t data[1000] = {{MAGIC0, FALSE}, {MAGIC1, FALSE}}; deadlock_test_t deadlock_test; g_test_message ("Testing object %s", o->name); diff --git a/test/api/test-ot-name.c b/test/api/test-ot-name.c index 71a8727b5..9e88015f5 100644 --- a/test/api/test-ot-name.c +++ b/test/api/test-ot-name.c @@ -81,7 +81,7 @@ test_ot_name (void) hb_ot_name_id_t name_id = entries[3].name_id; g_assert_cmpuint (3, ==, name_id); hb_language_t lang = entries[3].language; - g_assert_cmpstr ("en", ==, hb_language_to_string (lang)); + g_assert_cmpstr (hb_language_to_string (lang), ==, "en"); char text[10]; unsigned int text_size = 10; g_assert_cmpuint (27, ==, hb_ot_name_get_utf8 (face, name_id, lang, &text_size, text)); From f9552362986efd0973b2637d21b787edbc8479f2 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 20 Nov 2018 01:21:36 -0500 Subject: [PATCH 12/15] Add codecov.io badge --- README | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README b/README index 55775c8bf..e50f8f06e 100644 --- a/README +++ b/README @@ -1,9 +1,10 @@ -[![Build Status](https://travis-ci.org/harfbuzz/harfbuzz.svg)](https://travis-ci.org/harfbuzz/harfbuzz) -[![Build status](https://ci.appveyor.com/api/projects/status/0t0flrxpstj9lb9w?svg=true)](https://ci.appveyor.com/project/harfbuzz/harfbuzz) -[![CircleCI](https://circleci.com/gh/harfbuzz/harfbuzz.svg?style=svg)](https://circleci.com/gh/harfbuzz/harfbuzz) -[![Coverity](https://img.shields.io/coverity/scan/5450.svg)](https://scan.coverity.com/projects/behdad-harfbuzz) -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f17f1708783c447488bc8dd317150eaa)](https://app.codacy.com/app/behdad/harfbuzz) -[![Coverage Status](https://img.shields.io/coveralls/harfbuzz/harfbuzz.svg)](https://coveralls.io/r/harfbuzz/harfbuzz) +[![Travis Build Status](https://travis-ci.org/harfbuzz/harfbuzz.svg)](https://travis-ci.org/harfbuzz/harfbuzz) +[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/0t0flrxpstj9lb9w?svg=true)](https://ci.appveyor.com/project/harfbuzz/harfbuzz) +[![CircleCI Build Status](https://circleci.com/gh/harfbuzz/harfbuzz.svg?style=svg)](https://circleci.com/gh/harfbuzz/harfbuzz) +[![Coverity Code Health](https://img.shields.io/coverity/scan/5450.svg)](https://scan.coverity.com/projects/behdad-harfbuzz) +[![Codacy Code Health](https://api.codacy.com/project/badge/Grade/f17f1708783c447488bc8dd317150eaa)](https://app.codacy.com/app/behdad/harfbuzz) +[![Codecov Code Coverage](https://codecov.io/gh/harfbuzz/harfbuzz/branch/master/graph/badge.svg)](https://codecov.io/gh/harfbuzz/harfbuzz) +[![Coverals Code Coverage](https://img.shields.io/coveralls/harfbuzz/harfbuzz.svg)](https://coveralls.io/r/harfbuzz/harfbuzz) [ABI Tracker](http://abi-laboratory.pro/tracker/timeline/harfbuzz/) This is HarfBuzz, a text shaping library. From 8f3ee17ae468950a34439785d2e6ac4182efb65c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 20 Nov 2018 01:38:23 -0500 Subject: [PATCH 13/15] [travis] Update Coverity token --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ef8b01d02..c2db4ff01 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ env: - CONFIGURE_OPTS="--with-freetype --with-glib --with-gobject --with-cairo --with-icu --with-graphite2" - NOCONFIGURE=1 # COVERITY_SCAN_TOKEN - - secure: "MRJtVu/fQoWNwMAamvIJBCX/1SMvEuEUk/ljAif/y2/3syyWgxFGp17UGnDILdoZYyCqTM+jQciY2P0nVqbjjOAUlML4QOAalqw8kPp8iTsnHUe+KOMVrOVP6p6qAQxk1im1O41cCMkmVKvk+NXe/on5euz6LGF2laHZaOAMoes=" + - secure: "k6l/18dpsoPAf0E5RQWCr+rgjbHns0H3k0WzSYovCoVg0B7RVlV8x8OjyEOBzEvXI4aaHRdH6MHCPDFnX4fa7ysImlT6LxxIG8YhDdLkJWyS0hHbcJiGxko9AhAGzOZcDl8fZi13d697wagMqqXpjN5v2T/AQm8t4X9z2otJosY=" matrix: include: From be1828daaa1e1a72d971aed8d34fff54688d0f41 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 20 Nov 2018 11:16:23 -0500 Subject: [PATCH 14/15] [var] Fix type of coords returned Ouch. Wonder how none of the bots caught the float->int truncation. --- src/hb-ot-var-fvar-table.hh | 2 +- src/hb-ot-var.cc | 2 +- src/hb-ot-var.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index f61296d1b..47c2516f3 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -210,7 +210,7 @@ struct fvar inline unsigned int get_instance_coords (unsigned int index, unsigned int *coords_length, /* IN/OUT */ - int *coords /* OUT */) const + float *coords /* OUT */) const { if (unlikely (index >= instanceCount)) { diff --git a/src/hb-ot-var.cc b/src/hb-ot-var.cc index bb8d26490..9ad2f861e 100644 --- a/src/hb-ot-var.cc +++ b/src/hb-ot-var.cc @@ -144,7 +144,7 @@ unsigned int hb_ot_var_named_instance_get_design_coords (hb_face_t *face, unsigned int instance_index, unsigned int *coords_length, /* IN/OUT */ - int *coords /* OUT */) + float *coords /* OUT */) { return face->table.fvar->get_instance_coords (instance_index, coords_length, coords); } diff --git a/src/hb-ot-var.h b/src/hb-ot-var.h index e0ac5c4a2..79ce7d72b 100644 --- a/src/hb-ot-var.h +++ b/src/hb-ot-var.h @@ -124,7 +124,7 @@ HB_EXTERN unsigned int hb_ot_var_named_instance_get_design_coords (hb_face_t *face, unsigned int instance_index, unsigned int *coords_length, /* IN/OUT */ - int *coords /* OUT */); + float *coords /* OUT */); /* From 82951182799772a642d32195dd87e6f0c116f545 Mon Sep 17 00:00:00 2001 From: David Corbett Date: Tue, 20 Nov 2018 15:41:45 -0500 Subject: [PATCH 15/15] Shrink the emoji table by merging adjacent ranges --- src/gen-emoji-table.py | 13 ++- src/hb-unicode-emoji-table.hh | 189 +++------------------------------- 2 files changed, 23 insertions(+), 179 deletions(-) diff --git a/src/gen-emoji-table.py b/src/gen-emoji-table.py index 278e0b2d4..9afe747dd 100755 --- a/src/gen-emoji-table.py +++ b/src/gen-emoji-table.py @@ -12,7 +12,7 @@ if len (sys.argv) != 2: f = open(sys.argv[1]) header = [f.readline () for _ in range(10)] -sets = OrderedDict() +ranges = OrderedDict() for line in f.readlines(): line = line.strip() if not line or line[0] == '#': @@ -25,9 +25,12 @@ for line in f.readlines(): else: start = end = rang[0] - if typ not in sets: - sets[typ] = set() - sets[typ].add((start, end)) + if typ not in ranges: + ranges[typ] = [] + if ranges[typ] and ranges[typ][-1][1] == start - 1: + ranges[typ][-1] = (ranges[typ][-1][0], end) + else: + ranges[typ].append((start, end)) @@ -49,7 +52,7 @@ print () print ('#include "hb-unicode.hh"') print () -for typ,s in sets.items(): +for typ,s in ranges.items(): if typ != "Extended_Pictographic": continue print() print("static const struct hb_unicode_range_t _hb_unicode_emoji_%s_table[] =" % typ) diff --git a/src/hb-unicode-emoji-table.hh b/src/hb-unicode-emoji-table.hh index 41199de53..1dd0b3211 100644 --- a/src/hb-unicode-emoji-table.hh +++ b/src/hb-unicode-emoji-table.hh @@ -47,38 +47,9 @@ static const struct hb_unicode_range_t _hb_unicode_emoji_Extended_Pictographic_t {0x25FB, 0x25FE}, {0x2600, 0x2605}, {0x2607, 0x2612}, - {0x2614, 0x2615}, - {0x2616, 0x2617}, - {0x2618, 0x2618}, - {0x2619, 0x2619}, - {0x261A, 0x266F}, - {0x2670, 0x2671}, - {0x2672, 0x267D}, - {0x267E, 0x267F}, - {0x2680, 0x2685}, - {0x2690, 0x2691}, - {0x2692, 0x269C}, - {0x269D, 0x269D}, - {0x269E, 0x269F}, - {0x26A0, 0x26A1}, - {0x26A2, 0x26B1}, - {0x26B2, 0x26B2}, - {0x26B3, 0x26BC}, - {0x26BD, 0x26BF}, - {0x26C0, 0x26C3}, - {0x26C4, 0x26CD}, - {0x26CE, 0x26CE}, - {0x26CF, 0x26E1}, - {0x26E2, 0x26E2}, - {0x26E3, 0x26E3}, - {0x26E4, 0x26E7}, - {0x26E8, 0x26FF}, - {0x2700, 0x2700}, - {0x2701, 0x2704}, - {0x2705, 0x2705}, - {0x2708, 0x2709}, - {0x270A, 0x270B}, - {0x270C, 0x2712}, + {0x2614, 0x2685}, + {0x2690, 0x2705}, + {0x2708, 0x2712}, {0x2714, 0x2714}, {0x2716, 0x2716}, {0x271D, 0x271D}, @@ -105,163 +76,33 @@ static const struct hb_unicode_range_t _hb_unicode_emoji_Extended_Pictographic_t {0x303D, 0x303D}, {0x3297, 0x3297}, {0x3299, 0x3299}, - {0x1F000, 0x1F02B}, - {0x1F02C, 0x1F02F}, - {0x1F030, 0x1F093}, - {0x1F094, 0x1F09F}, - {0x1F0A0, 0x1F0AE}, - {0x1F0AF, 0x1F0B0}, - {0x1F0B1, 0x1F0BE}, - {0x1F0BF, 0x1F0BF}, - {0x1F0C0, 0x1F0C0}, - {0x1F0C1, 0x1F0CF}, - {0x1F0D0, 0x1F0D0}, - {0x1F0D1, 0x1F0DF}, - {0x1F0E0, 0x1F0F5}, - {0x1F0F6, 0x1F0FF}, + {0x1F000, 0x1F0FF}, {0x1F10D, 0x1F10F}, {0x1F12F, 0x1F12F}, - {0x1F16C, 0x1F16F}, - {0x1F170, 0x1F171}, - {0x1F17E, 0x1F17E}, - {0x1F17F, 0x1F17F}, + {0x1F16C, 0x1F171}, + {0x1F17E, 0x1F17F}, {0x1F18E, 0x1F18E}, {0x1F191, 0x1F19A}, {0x1F1AD, 0x1F1E5}, - {0x1F201, 0x1F202}, - {0x1F203, 0x1F20F}, + {0x1F201, 0x1F20F}, {0x1F21A, 0x1F21A}, {0x1F22F, 0x1F22F}, {0x1F232, 0x1F23A}, {0x1F23C, 0x1F23F}, - {0x1F249, 0x1F24F}, - {0x1F250, 0x1F251}, - {0x1F252, 0x1F25F}, - {0x1F260, 0x1F265}, - {0x1F266, 0x1F2FF}, - {0x1F300, 0x1F320}, - {0x1F321, 0x1F32C}, - {0x1F32D, 0x1F32F}, - {0x1F330, 0x1F335}, - {0x1F336, 0x1F336}, - {0x1F337, 0x1F37C}, - {0x1F37D, 0x1F37D}, - {0x1F37E, 0x1F37F}, - {0x1F380, 0x1F393}, - {0x1F394, 0x1F39F}, - {0x1F3A0, 0x1F3C4}, - {0x1F3C5, 0x1F3C5}, - {0x1F3C6, 0x1F3CA}, - {0x1F3CB, 0x1F3CE}, - {0x1F3CF, 0x1F3D3}, - {0x1F3D4, 0x1F3DF}, - {0x1F3E0, 0x1F3F0}, - {0x1F3F1, 0x1F3F7}, - {0x1F3F8, 0x1F3FA}, - {0x1F400, 0x1F43E}, - {0x1F43F, 0x1F43F}, - {0x1F440, 0x1F440}, - {0x1F441, 0x1F441}, - {0x1F442, 0x1F4F7}, - {0x1F4F8, 0x1F4F8}, - {0x1F4F9, 0x1F4FC}, - {0x1F4FD, 0x1F4FE}, - {0x1F4FF, 0x1F4FF}, - {0x1F500, 0x1F53D}, - {0x1F546, 0x1F54A}, - {0x1F54B, 0x1F54F}, - {0x1F550, 0x1F567}, - {0x1F568, 0x1F579}, - {0x1F57A, 0x1F57A}, - {0x1F57B, 0x1F5A3}, - {0x1F5A4, 0x1F5A4}, - {0x1F5A5, 0x1F5FA}, - {0x1F5FB, 0x1F5FF}, - {0x1F600, 0x1F600}, - {0x1F601, 0x1F610}, - {0x1F611, 0x1F611}, - {0x1F612, 0x1F614}, - {0x1F615, 0x1F615}, - {0x1F616, 0x1F616}, - {0x1F617, 0x1F617}, - {0x1F618, 0x1F618}, - {0x1F619, 0x1F619}, - {0x1F61A, 0x1F61A}, - {0x1F61B, 0x1F61B}, - {0x1F61C, 0x1F61E}, - {0x1F61F, 0x1F61F}, - {0x1F620, 0x1F625}, - {0x1F626, 0x1F627}, - {0x1F628, 0x1F62B}, - {0x1F62C, 0x1F62C}, - {0x1F62D, 0x1F62D}, - {0x1F62E, 0x1F62F}, - {0x1F630, 0x1F633}, - {0x1F634, 0x1F634}, - {0x1F635, 0x1F640}, - {0x1F641, 0x1F642}, - {0x1F643, 0x1F644}, - {0x1F645, 0x1F64F}, - {0x1F680, 0x1F6C5}, - {0x1F6C6, 0x1F6CF}, - {0x1F6D0, 0x1F6D0}, - {0x1F6D1, 0x1F6D2}, - {0x1F6D3, 0x1F6D4}, - {0x1F6D5, 0x1F6DF}, - {0x1F6E0, 0x1F6EC}, - {0x1F6ED, 0x1F6EF}, - {0x1F6F0, 0x1F6F3}, - {0x1F6F4, 0x1F6F6}, - {0x1F6F7, 0x1F6F8}, - {0x1F6F9, 0x1F6F9}, - {0x1F6FA, 0x1F6FF}, + {0x1F249, 0x1F3FA}, + {0x1F400, 0x1F53D}, + {0x1F546, 0x1F64F}, + {0x1F680, 0x1F6FF}, {0x1F774, 0x1F77F}, - {0x1F7D5, 0x1F7D8}, - {0x1F7D9, 0x1F7FF}, + {0x1F7D5, 0x1F7FF}, {0x1F80C, 0x1F80F}, {0x1F848, 0x1F84F}, {0x1F85A, 0x1F85F}, {0x1F888, 0x1F88F}, {0x1F8AE, 0x1F8FF}, - {0x1F90C, 0x1F90F}, - {0x1F910, 0x1F918}, - {0x1F919, 0x1F91E}, - {0x1F91F, 0x1F91F}, - {0x1F920, 0x1F927}, - {0x1F928, 0x1F92F}, - {0x1F930, 0x1F930}, - {0x1F931, 0x1F932}, - {0x1F933, 0x1F93A}, - {0x1F93C, 0x1F93E}, - {0x1F93F, 0x1F93F}, - {0x1F940, 0x1F945}, - {0x1F947, 0x1F94B}, - {0x1F94C, 0x1F94C}, - {0x1F94D, 0x1F94F}, - {0x1F950, 0x1F95E}, - {0x1F95F, 0x1F96B}, - {0x1F96C, 0x1F970}, - {0x1F971, 0x1F972}, - {0x1F973, 0x1F976}, - {0x1F977, 0x1F979}, - {0x1F97A, 0x1F97A}, - {0x1F97B, 0x1F97B}, - {0x1F97C, 0x1F97F}, - {0x1F980, 0x1F984}, - {0x1F985, 0x1F991}, - {0x1F992, 0x1F997}, - {0x1F998, 0x1F9A2}, - {0x1F9A3, 0x1F9AF}, - {0x1F9B0, 0x1F9B9}, - {0x1F9BA, 0x1F9BF}, - {0x1F9C0, 0x1F9C0}, - {0x1F9C1, 0x1F9C2}, - {0x1F9C3, 0x1F9CF}, - {0x1F9D0, 0x1F9E6}, - {0x1F9E7, 0x1F9FF}, - {0x1FA00, 0x1FA5F}, - {0x1FA60, 0x1FA6D}, - {0x1FA6E, 0x1FFFD}, + {0x1F90C, 0x1F93A}, + {0x1F93C, 0x1F945}, + {0x1F947, 0x1FFFD}, }; #endif /* HB_UNICODE_EMOJI_TABLE_HH */