From dd9a0ed3f0c0a8a94e107689318463d62414cf60 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Wed, 24 Jul 2019 00:47:19 +0430 Subject: [PATCH 01/30] Replace 0x7FFFFFFFu in enums with HB_TAG_MAX_SIGNED --- src/hb-aat-layout.h | 4 ++-- src/hb-ot-var.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hb-aat-layout.h b/src/hb-aat-layout.h index 760aaae40..b617e8b70 100644 --- a/src/hb-aat-layout.h +++ b/src/hb-aat-layout.h @@ -85,7 +85,7 @@ typedef enum HB_AAT_LAYOUT_FEATURE_TYPE_LANGUAGE_TAG_TYPE = 39, HB_AAT_LAYOUT_FEATURE_TYPE_CJK_ROMAN_SPACING_TYPE = 103, - _HB_AAT_LAYOUT_FEATURE_TYPE_MAX_VALUE= 0x7FFFFFFFu, /*< skip >*/ + _HB_AAT_LAYOUT_FEATURE_TYPE_MAX_VALUE = HB_TAG_MAX_SIGNED /*< skip >*/ } hb_aat_layout_feature_type_t; /** @@ -424,7 +424,7 @@ typedef enum HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_CJK_ROMAN = 2, HB_AAT_LAYOUT_FEATURE_SELECTOR_FULL_WIDTH_CJK_ROMAN = 3, - _HB_AAT_LAYOUT_FEATURE_SELECTOR_MAX_VALUE= 0x7FFFFFFFu, /*< skip >*/ + _HB_AAT_LAYOUT_FEATURE_SELECTOR_MAX_VALUE = HB_TAG_MAX_SIGNED /*< skip >*/ } hb_aat_layout_feature_selector_t; HB_EXTERN unsigned int diff --git a/src/hb-ot-var.h b/src/hb-ot-var.h index cf6f0c950..df89bc5a2 100644 --- a/src/hb-ot-var.h +++ b/src/hb-ot-var.h @@ -68,7 +68,7 @@ hb_ot_var_get_axis_count (hb_face_t *face); typedef enum { /*< flags >*/ HB_OT_VAR_AXIS_FLAG_HIDDEN = 0x00000001u, - _HB_OT_VAR_AXIS_FLAG_MAX_VALUE= 0x7FFFFFFFu /*< skip >*/ + _HB_OT_VAR_AXIS_FLAG_MAX_VALUE= HB_TAG_MAX_SIGNED /*< skip >*/ } hb_ot_var_axis_flags_t; /** From 737eb85a4ec8861791157d83dd170ac48fa2cfc7 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Thu, 25 Jul 2019 14:26:30 +0430 Subject: [PATCH 02/30] Add _MAX_VALUE to disabled baseline types enum --- src/hb-ot-layout.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index f493005bc..665dd028f 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -1980,7 +1980,9 @@ typedef enum { HB_OT_LAYOUT_BASELINE_IDEO = HB_TAG('i','d','e','o'), HB_OT_LAYOUT_BASELINE_IDTB = HB_TAG('i','d','t','b'), HB_OT_LAYOUT_BASELINE_MATH = HB_TAG('m','a','t','h'), - HB_OT_LAYOUT_BASELINE_ROMN = HB_TAG('r','o','m','n') + HB_OT_LAYOUT_BASELINE_ROMN = HB_TAG('r','o','m','n'), + + _HB_OT_LAYOUT_BASELINE_MAX_VALUE= HB_TAG_MAX_SIGNED /*< skip >*/ } hb_ot_layout_baseline_t; From 069872c51b31fe1a618e3ca5c3b0ab8ccba0cf81 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Thu, 25 Jul 2019 14:27:43 +0430 Subject: [PATCH 03/30] minor --- src/hb-ot-layout.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 665dd028f..dcd50a25e 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -1982,7 +1982,7 @@ typedef enum { HB_OT_LAYOUT_BASELINE_MATH = HB_TAG('m','a','t','h'), HB_OT_LAYOUT_BASELINE_ROMN = HB_TAG('r','o','m','n'), - _HB_OT_LAYOUT_BASELINE_MAX_VALUE= HB_TAG_MAX_SIGNED /*< skip >*/ + _HB_OT_LAYOUT_BASELINE_MAX_VALUE = HB_TAG_MAX_SIGNED /*< skip >*/ } hb_ot_layout_baseline_t; From a744fdc6c8217d0d4bfce30e638ed2e5200cf380 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Thu, 25 Jul 2019 14:49:02 +0430 Subject: [PATCH 04/30] Add _MAX_VALUE to hb_ot_metrics_t (#1861) --- src/hb-ot-metrics.cc | 4 ++-- src/hb-ot-metrics.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-metrics.cc b/src/hb-ot-metrics.cc index 910d826b9..d0694bb51 100644 --- a/src/hb-ot-metrics.cc +++ b/src/hb-ot-metrics.cc @@ -53,7 +53,7 @@ _hb_ot_metrics_get_position_common (hb_font_t *font, hb_position_t *position /* OUT. May be NULL. */) { hb_face_t *face = font->face; - switch ((unsigned int) metrics_tag) + switch ((unsigned) metrics_tag) { #ifndef HB_NO_VAR #define GET_VAR face->table.MVAR->get_var (metrics_tag, font->coords, font->num_coords) @@ -117,7 +117,7 @@ hb_ot_metrics_get_position (hb_font_t *font, hb_position_t *position /* OUT. May be NULL. */) { hb_face_t *face = font->face; - switch (metrics_tag) + switch ((unsigned) metrics_tag) { case HB_OT_METRICS_HORIZONTAL_ASCENDER: case HB_OT_METRICS_HORIZONTAL_DESCENDER: diff --git a/src/hb-ot-metrics.h b/src/hb-ot-metrics.h index 4d22837f2..c60ee739c 100644 --- a/src/hb-ot-metrics.h +++ b/src/hb-ot-metrics.h @@ -70,7 +70,9 @@ typedef enum { HB_OT_METRICS_STRIKEOUT_SIZE = HB_TAG ('s','t','r','s'), HB_OT_METRICS_STRIKEOUT_OFFSET = HB_TAG ('s','t','r','o'), HB_OT_METRICS_UNDERLINE_SIZE = HB_TAG ('u','n','d','s'), - HB_OT_METRICS_UNDERLINE_OFFSET = HB_TAG ('u','n','d','o') + HB_OT_METRICS_UNDERLINE_OFFSET = HB_TAG ('u','n','d','o'), + + _HB_OT_METRICS_MAX_VALUE = HB_TAG_MAX_SIGNED /*< skip >*/ } hb_ot_metrics_t; HB_EXTERN hb_bool_t From 356b68a00afaf972908cb2a478170e3933eaf974 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Thu, 25 Jul 2019 23:22:00 +0430 Subject: [PATCH 05/30] [metrics] Add a test that actually practices variation (#1858) --- test/api/fonts/TestCFF2VF.otf | Bin 0 -> 3636 bytes test/api/test-ot-metrics.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 test/api/fonts/TestCFF2VF.otf diff --git a/test/api/fonts/TestCFF2VF.otf b/test/api/fonts/TestCFF2VF.otf new file mode 100644 index 0000000000000000000000000000000000000000..a9e48e396372d41d6615e429d54c5a1ab610ea61 GIT binary patch literal 3636 zcmbVP4Nz3q6+ZXv56iOBhek2z=%UonRw!U_O0`iJ#l)XtTtrNxxUf%_x<9z=5~7HL z5Eph~7toLpNz|$_YGaeeVhoNrI{h^|O_*qB+QgVi>P)L``nNcXrQdz~6f|mW-_CpY zJKs6yyXW2a?tORj3kvdSG$T@z(KOGzK$^7rB$4hc5#{CPMX`(drg1%QyGj{6!v-VK(fU3(YG`e|~JyBd|TNUwE=`-f|jCGhh#L|5Dgr-25P$ zXw>7d^YYE#&RVsoa4{r9u-BRk<`q;|*jnJPfj!YuWpPh6Og|6%CD_wS9hM3Tv3|sJ zz2ocPZ#n1fhQAN?4{eggI{IDnA^3THGi@NWSI%{< z17tp2v`&jd`cdx01w_I-M4Iaru1e3)abCY}AN)ps=fs5Izh=KVqxfsH|4AyaQD5|m2-Km0p%RKP8bCrb zqKOtqTegO>*i^7_npl-uB?#(~=^W3SZ_1~+ltKl<^&u_qktKlUH52Wk4(Ic>44qK0X1E5X#oPbB!pA`Kih^~h=cosLkambvdiJm7bZAGs|IF zFS$JHq-x2Sm7bkGGdnwH=KYjpxs_6Rna#7H+T*q?;iy2W^zh|WcBT#U_i)~WQf_0Z zWG(kP?v#phX30@r;<8)s^xa}jU-59pWVe*AzcWFm$V@KslAB6NA|vI(vdXBCEMUuV zEx}xuXgSU@MA~IOlhUzbWa6BKwPHS*C?9B~)-9#Gb<&{ZA_r8QR0vHsRiYOcEF<)W zRc+ursET{4Zu`>ZK6B6)S6GjH9<>f_HBKXDdpc#~oQZ2T<)HmvYZ|U@B^1kX&o=b1 z0Qw%(YM~{!xdQkr!RAsPepw^#EA5`~5109HQFlI#rKrS;y1W>b2URsP&Ws!fa!N3Q zc4R*&@9tRBL*(3wG0AUCDW27XdKiw1exb0)4;{mp-dgJcZXXOthf_`QB$Qhvm)qrV zl6rpLk^)L9eco-Sq%ya(o|5bqkCT$H67z%M%cdg(v7y4~dMaQ^*A2XDNI9FZYrGsX zO?Dsz7XL&FebgsA=Hg2$AN*s)y&3_{>udshf^A~I|J5ETAdVZTD83jFZ=?=Z^vp@t zhuPq@@Bgjh_!NDAIPvtC2cJDYcjxoL#-OMPYEON=Ka#j})AqIl&#w6hOr-CW<-@vH zrsxMOA4L)ZVoZ2Uq~^dH={GH+rsqBHQSZ?y`c+q-3dc3>Y;JYE*ZUphgljKEw8{EK zk+^5lohP38_=Oz-ALyPRc#rNWo1zbo4%h52erqul1}$^LT=dYZc2xQ4iqBD8%z&`B zfA@#GFYdFvu_{#GzO{Ax_O{lBwz>}S(V+IVIeT*Vn!=hvA=ucsv&9!|4AnQhxUbZ4 zvO^sIx%rRD`pAYGDK-0ojgbG=g@`&?KXq`mqxVPwIzD|Na(Y`=>A8-YR#6*%aepy7 z{bb+|VaEr9UGu|^m7krMz00w-zuWaQ(=JE5s5R<$+m1dBp|z(zDf>9Iwc(|$yS8_9 z)P}?fMUls<4+ne@opIxuxji!D=Jn=4t8ag?FBE8Q3bu(FqrQIweidB8wQY;b|N7>p zZr_0exQ)tzU$<5H%ctniY&eswKk45Q5dA07_; zAgUv&XTqueg&WTJFSLp={CP8`=^r>ddQ0cP#?FhKr#jm@dpi9%w!Q542ejkof{8=NsO7ayQJ6<>o>%mx1J9q>Ms{v2_(k#kAbF&u>)@$37>7>5)gkp zHk|P3xj%W|YVp-~H3fs>#oBqf@0FiV~5XQI9gS9qTAV3*;&yg|I(!Al-;?DzS9Bc^7!7aqg346ii%2TmPBP1ySp)3Z1r{y)jUMn!d4JlB$IrT+k8JQsfe literal 0 HcmV?d00001 diff --git a/test/api/test-ot-metrics.c b/test/api/test-ot-metrics.c index 91dd7f5e1..9712c932a 100644 --- a/test/api/test-ot-metrics.c +++ b/test/api/test-ot-metrics.c @@ -31,7 +31,7 @@ /* Unit tests for hb-ot-metrics.h */ static void -test_ot_metrics_get (void) +test_ot_metrics_get_no_var (void) { hb_face_t *face = hb_test_open_font_file ("fonts/cpal-v0.ttf"); hb_font_t *font = hb_font_create (face); @@ -40,15 +40,39 @@ test_ot_metrics_get (void) g_assert_cmpint (value, ==, 1000); g_assert_cmpint (hb_ot_metrics_get_x_variation (font, HB_OT_METRICS_HORIZONTAL_ASCENDER), ==, 0); g_assert_cmpint (hb_ot_metrics_get_y_variation (font, HB_OT_METRICS_HORIZONTAL_ASCENDER), ==, 0); + g_assert_cmpint (hb_ot_metrics_get_x_variation (font, HB_OT_METRICS_X_HEIGHT), ==, 0); // g_assert_cmpint ((int) hb_ot_metrics_get_variation (font, HB_OT_METRICS_HORIZONTAL_ASCENDER), ==, 0); hb_font_destroy (font); hb_face_destroy (face); } +static void +test_ot_metrics_get_var (void) +{ + hb_face_t *face = hb_test_open_font_file ("fonts/TestCFF2VF.otf"); + hb_font_t *font = hb_font_create (face); + hb_position_t value; + g_assert (hb_ot_metrics_get_position (font, HB_OT_METRICS_X_HEIGHT, &value)); + g_assert_cmpint (value, ==, 486); + g_assert_cmpint (hb_ot_metrics_get_x_variation (font, HB_OT_METRICS_HORIZONTAL_ASCENDER), ==, 0); + g_assert_cmpint (hb_ot_metrics_get_y_variation (font, HB_OT_METRICS_HORIZONTAL_ASCENDER), ==, 0); + g_assert_cmpint (hb_ot_metrics_get_x_variation (font, HB_OT_METRICS_X_HEIGHT), ==, 0); + float coords[] = {100.f}; + hb_font_set_var_coords_design (font, coords, 1); + g_assert (hb_ot_metrics_get_position (font, HB_OT_METRICS_X_HEIGHT, &value)); + g_assert_cmpint (value, ==, 478); + g_assert_cmpint (hb_ot_metrics_get_x_variation (font, HB_OT_METRICS_HORIZONTAL_ASCENDER), ==, 0); + g_assert_cmpint (hb_ot_metrics_get_y_variation (font, HB_OT_METRICS_HORIZONTAL_ASCENDER), ==, 0); + g_assert_cmpint (hb_ot_metrics_get_x_variation (font, HB_OT_METRICS_X_HEIGHT), ==, -8); + hb_font_destroy (font); + hb_face_destroy (face); +} + int main (int argc, char **argv) { hb_test_init (&argc, &argv); - hb_test_add (test_ot_metrics_get); + hb_test_add (test_ot_metrics_get_no_var); + hb_test_add (test_ot_metrics_get_var); return hb_test_run (); } From d791446a930f8e2009c5ab5ea389da98d1ed9b95 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Fri, 26 Jul 2019 02:12:06 +0430 Subject: [PATCH 06/30] [feat] minor --- src/hb-aat-layout-feat-table.hh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/hb-aat-layout-feat-table.hh b/src/hb-aat-layout-feat-table.hh index a20ef8640..2345f2198 100644 --- a/src/hb-aat-layout-feat-table.hh +++ b/src/hb-aat-layout-feat-table.hh @@ -174,9 +174,7 @@ struct feat } const FeatureName& get_feature (hb_aat_layout_feature_type_t feature_type) const - { - return namesZ.bsearch (featureNameCount, feature_type); - } + { return namesZ.bsearch (featureNameCount, feature_type); } hb_ot_name_id_t get_feature_name_id (hb_aat_layout_feature_type_t feature) const { return get_feature (feature).get_feature_name_id (); } From aab8e084873eb098c55ed2569c15bb308c59e436 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Fri, 26 Jul 2019 02:19:22 +0430 Subject: [PATCH 07/30] minor spacing fix (#1869) --- src/hb-open-type.hh | 16 ++++++++-------- src/hb-ot-vorg-table.hh | 2 +- src/hb-vector.hh | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index e235a97c3..ad995750b 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -576,13 +576,13 @@ struct ArrayOf operator writer_t () { return writer (); } hb_array_t sub_array (unsigned int start_offset, unsigned int count) const - { return as_array ().sub_array (start_offset, count);} + { return as_array ().sub_array (start_offset, count); } hb_array_t sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) const - { return as_array ().sub_array (start_offset, count);} + { return as_array ().sub_array (start_offset, count); } hb_array_t sub_array (unsigned int start_offset, unsigned int count) - { return as_array ().sub_array (start_offset, count);} + { return as_array ().sub_array (start_offset, count); } hb_array_t sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) - { return as_array ().sub_array (start_offset, count);} + { return as_array ().sub_array (start_offset, count); } bool serialize (hb_serialize_context_t *c, unsigned int items_len) { @@ -826,13 +826,13 @@ struct SortedArrayOf : ArrayOf operator writer_t () { return writer (); } hb_sorted_array_t sub_array (unsigned int start_offset, unsigned int count) const - { return as_array ().sub_array (start_offset, count);} + { return as_array ().sub_array (start_offset, count); } hb_sorted_array_t sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) const - { return as_array ().sub_array (start_offset, count);} + { return as_array ().sub_array (start_offset, count); } hb_sorted_array_t sub_array (unsigned int start_offset, unsigned int count) - { return as_array ().sub_array (start_offset, count);} + { return as_array ().sub_array (start_offset, count); } hb_sorted_array_t sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) - { return as_array ().sub_array (start_offset, count);} + { return as_array ().sub_array (start_offset, count); } bool serialize (hb_serialize_context_t *c, unsigned int items_len) { diff --git a/src/hb-ot-vorg-table.hh b/src/hb-ot-vorg-table.hh index 19e08ebb5..d9002f3d6 100644 --- a/src/hb-ot-vorg-table.hh +++ b/src/hb-ot-vorg-table.hh @@ -85,7 +85,7 @@ struct VORG this->vertYOrigins.len = it.len (); + it - | hb_apply ([c] (const VertOriginMetric& _) { c->copy (_);}) + | hb_apply ([c] (const VertOriginMetric& _) { c->copy (_); }) ; } diff --git a/src/hb-vector.hh b/src/hb-vector.hh index de16c97dd..035c6d0a8 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -143,13 +143,13 @@ struct hb_vector_t operator writer_t () { return writer (); } hb_array_t sub_array (unsigned int start_offset, unsigned int count) const - { return as_array ().sub_array (start_offset, count);} + { return as_array ().sub_array (start_offset, count); } hb_array_t sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) const - { return as_array ().sub_array (start_offset, count);} + { return as_array ().sub_array (start_offset, count); } hb_array_t sub_array (unsigned int start_offset, unsigned int count) - { return as_array ().sub_array (start_offset, count);} + { return as_array ().sub_array (start_offset, count); } hb_array_t sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) - { return as_array ().sub_array (start_offset, count);} + { return as_array ().sub_array (start_offset, count); } hb_sorted_array_t as_sorted_array () { return hb_sorted_array (arrayZ, length); } From 3ac03bd67cb9f4a72e636bf56bc4a79e04bcba62 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Mon, 22 Jul 2019 23:35:08 +0430 Subject: [PATCH 08/30] [meta] New API, hb_ot_metadata_reference_entry for fetching meta entries --- docs/harfbuzz-sections.txt | 6 ++++ src/Makefile.sources | 2 ++ src/harfbuzz.cc | 1 + src/hb-config.hh | 1 + src/hb-ot-face-table-list.hh | 4 ++- src/hb-ot-face.cc | 1 + src/hb-ot-layout.cc | 1 - src/hb-ot-meta-table.hh | 20 ++++++++++++ src/hb-ot-metadata.cc | 57 ++++++++++++++++++++++++++++++++++ src/hb-ot-metadata.h | 57 ++++++++++++++++++++++++++++++++++ src/hb-ot.h | 1 + test/api/Makefile.am | 1 + test/api/fonts/meta.ttf | Bin 0 -> 320 bytes test/api/test-ot-metadata.c | 58 +++++++++++++++++++++++++++++++++++ 14 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 src/hb-ot-metadata.cc create mode 100644 src/hb-ot-metadata.h create mode 100644 test/api/fonts/meta.ttf create mode 100644 test/api/test-ot-metadata.c diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt index 43fd76115..888859e28 100644 --- a/docs/harfbuzz-sections.txt +++ b/docs/harfbuzz-sections.txt @@ -607,6 +607,12 @@ hb_ot_math_get_min_connector_overlap hb_ot_math_get_glyph_assembly +
+hb-ot-metadata +hb_ot_metadata_reference_entry +hb_ot_metadata_t +
+
hb-ot-metrics hb_ot_metrics_t diff --git a/src/Makefile.sources b/src/Makefile.sources index 21fb1b6e1..a024381ab 100644 --- a/src/Makefile.sources +++ b/src/Makefile.sources @@ -89,6 +89,7 @@ HB_BASE_sources = \ hb-ot-math.cc \ hb-ot-maxp-table.hh \ hb-ot-meta-table.hh \ + hb-ot-metadata.cc \ hb-ot-metrics.cc \ hb-ot-metrics.hh \ hb-ot-name-language-static.hh \ @@ -194,6 +195,7 @@ HB_BASE_headers = \ hb-ot-font.h \ hb-ot-layout.h \ hb-ot-math.h \ + hb-ot-metadata.h \ hb-ot-metrics.h \ hb-ot-name.h \ hb-ot-shape.h \ diff --git a/src/harfbuzz.cc b/src/harfbuzz.cc index e39913761..d97143981 100644 --- a/src/harfbuzz.cc +++ b/src/harfbuzz.cc @@ -16,6 +16,7 @@ #include "hb-ot-layout.cc" #include "hb-ot-map.cc" #include "hb-ot-math.cc" +#include "hb-ot-metadata.cc" #include "hb-ot-metrics.cc" #include "hb-ot-name.cc" #include "hb-ot-shape-complex-arabic.cc" diff --git a/src/hb-config.hh b/src/hb-config.hh index bd440050e..b6db206a3 100644 --- a/src/hb-config.hh +++ b/src/hb-config.hh @@ -66,6 +66,7 @@ #define HB_NO_LAYOUT_COLLECT_GLYPHS #define HB_NO_LAYOUT_UNUSED #define HB_NO_MATH +#define HB_NO_META #define HB_NO_METRICS #define HB_NO_MMAP #define HB_NO_NAME diff --git a/src/hb-ot-face-table-list.hh b/src/hb-ot-face-table-list.hh index 4ec622c57..97fb765a2 100644 --- a/src/hb-ot-face-table-list.hh +++ b/src/hb-ot-face-table-list.hh @@ -62,7 +62,9 @@ HB_OT_ACCELERATOR (OT, name) #ifndef HB_NO_STAT HB_OT_TABLE (OT, STAT) #endif -//HB_OT_TABLE (OT, meta) +#ifndef HB_NO_META +HB_OT_ACCELERATOR (OT, meta) +#endif /* Vertical layout. */ HB_OT_TABLE (OT, vhea) diff --git a/src/hb-ot-face.cc b/src/hb-ot-face.cc index f54d0b639..5ef8df43c 100644 --- a/src/hb-ot-face.cc +++ b/src/hb-ot-face.cc @@ -32,6 +32,7 @@ #include "hb-ot-cff2-table.hh" #include "hb-ot-hmtx-table.hh" #include "hb-ot-kern-table.hh" +#include "hb-ot-meta-table.hh" #include "hb-ot-name-table.hh" #include "hb-ot-post-table.hh" #include "hb-ot-color-cbdt-table.hh" diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index dcd50a25e..4cd65b4a9 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -48,7 +48,6 @@ #include "hb-ot-layout-gpos-table.hh" #include "hb-ot-layout-base-table.hh" // Just so we compile it; unused otherwise. #include "hb-ot-layout-jstf-table.hh" // Just so we compile it; unused otherwise. -#include "hb-ot-meta-table.hh" // Just so we compile it; unused otherwise. #include "hb-ot-name-table.hh" #include "hb-ot-os2-table.hh" diff --git a/src/hb-ot-meta-table.hh b/src/hb-ot-meta-table.hh index dac55e47f..d36c3e94f 100644 --- a/src/hb-ot-meta-table.hh +++ b/src/hb-ot-meta-table.hh @@ -40,6 +40,11 @@ namespace OT { struct DataMap { + int cmp (hb_tag_t a) const { return tag.cmp (a); } + + hb_blob_t *reference_entry (hb_blob_t *meta_blob) const + { return hb_blob_create_sub_blob (meta_blob, dataZ, dataLength); } + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); @@ -62,6 +67,19 @@ struct meta { static constexpr hb_tag_t tableTag = HB_OT_TAG_meta; + struct accelerator_t + { + void init (hb_face_t *face) + { table = hb_sanitize_context_t ().reference_table (face); } + void fini () { table.destroy (); } + + hb_blob_t *reference_entry (hb_tag_t tag) const + { return table->dataMaps.lsearch (tag, Null (DataMap)).reference_entry (table.get_blob ()); } + + private: + hb_blob_ptr_t table; + }; + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); @@ -83,6 +101,8 @@ struct meta DEFINE_SIZE_ARRAY (16, dataMaps); }; +struct meta_accelerator_t : meta::accelerator_t {}; + } /* namespace OT */ diff --git a/src/hb-ot-metadata.cc b/src/hb-ot-metadata.cc new file mode 100644 index 000000000..42153be73 --- /dev/null +++ b/src/hb-ot-metadata.cc @@ -0,0 +1,57 @@ +/* + * Copyright © 2019 Ebrahim Byagowi + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + */ + +#include "hb.hh" + +#ifndef HB_NO_META + +#include "hb-ot-meta-table.hh" + +/** + * SECTION:hb-ot-metadata + * @title: hb-ot-metadata + * @short_description: OpenType Metadata + * @include: hb-ot.h + * + * Functions for fetching metadata from fonts. + **/ + +/** + * hb_ot_meta_reference_entry: + * @face: a #hb_face_t object. + * @meta_tag: tag of metadata you like to have. + * + * It fetches metadata entry of a given tag from a font. + * + * Returns: (transfer full): A blob containing the blob. + * + * Since: REPLACEME + **/ +hb_blob_t * +hb_ot_metadata_reference_entry (hb_face_t *face, hb_ot_metadata_t meta_tag) +{ + return face->table.meta->reference_entry (meta_tag); +} + +#endif diff --git a/src/hb-ot-metadata.h b/src/hb-ot-metadata.h new file mode 100644 index 000000000..3654458a1 --- /dev/null +++ b/src/hb-ot-metadata.h @@ -0,0 +1,57 @@ +/* + * Copyright © 2019 Ebrahim Byagowi + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + */ + +#ifndef HB_OT_H_IN +#error "Include instead." +#endif + +#ifndef HB_OT_METADATA_H +#define HB_OT_METADATA_H + +#include "hb.h" + +HB_BEGIN_DECLS + +/** + * hb_ot_metadata_t: + * + * From https://docs.microsoft.com/en-us/typography/opentype/spec/meta + * + * Since: REPLACEME + **/ +typedef enum { +/* + HB_OT_METADATA_APPL = HB_TAG ('a','p','p','l'), + HB_OT_METADATA_BILD = HB_TAG ('b','i','l','d'), +*/ + HB_OT_METADATA_DESIGN_LANGUAGES = HB_TAG ('d','l','n','g'), + HB_OT_METADATA_SUPPORTED_LANGUAGES = HB_TAG ('s','l','n','g') +} hb_ot_metadata_t; + +HB_EXTERN hb_blob_t * +hb_ot_metadata_reference_entry (hb_face_t *face, hb_ot_metadata_t tag); + +HB_END_DECLS + +#endif /* HB_OT_METADATA_H */ diff --git a/src/hb-ot.h b/src/hb-ot.h index d00ee80ae..411d0936f 100644 --- a/src/hb-ot.h +++ b/src/hb-ot.h @@ -35,6 +35,7 @@ #include "hb-ot-font.h" #include "hb-ot-layout.h" #include "hb-ot-math.h" +#include "hb-ot-metadata.h" #include "hb-ot-metrics.h" #include "hb-ot-name.h" #include "hb-ot-shape.h" diff --git a/test/api/Makefile.am b/test/api/Makefile.am index 63c7195fa..a675c50ff 100644 --- a/test/api/Makefile.am +++ b/test/api/Makefile.am @@ -84,6 +84,7 @@ TEST_PROGS += \ test-ot-color \ test-ot-ligature-carets \ test-ot-name \ + test-ot-metadata \ test-ot-metrics \ test-ot-tag \ test-ot-extents-cff \ diff --git a/test/api/fonts/meta.ttf b/test/api/fonts/meta.ttf new file mode 100644 index 0000000000000000000000000000000000000000..414d7e67117f4bbfb58504825e6aa4a3f5472a0e GIT binary patch literal 320 zcmZQzWME)mVQ^qzVqnNfO-$jNr;!R2@d0A944?qpH6}M8y9J0|fb0`MT+RS83y43*1V4=DxB1Gz%=`iZ1Z zAeS9vCl~kbMXMn-$&PfB(2|&zK3=s$E;l8(a-+LHNEYe9y)k#Z) O@j*01EHw`(%m4r~NJE$a literal 0 HcmV?d00001 diff --git a/test/api/test-ot-metadata.c b/test/api/test-ot-metadata.c new file mode 100644 index 000000000..d5f922415 --- /dev/null +++ b/test/api/test-ot-metadata.c @@ -0,0 +1,58 @@ +/* + * Copyright © 2019 Ebrahim Byagowi + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + */ + +#include "hb-test.h" + +#include + +/* Unit tests for hb-ot-metadata.h */ + +static void +test_ot_metadata_reference_entry (void) +{ + hb_face_t *face = hb_test_open_font_file ("fonts/meta.ttf"); + hb_blob_t *dlng = hb_ot_metadata_reference_entry (face, HB_OT_METADATA_DESIGN_LANGUAGES); + g_assert_cmpint (hb_blob_get_length (dlng), ==, 8); + g_assert_cmpmem (hb_blob_get_data (dlng, NULL), 8, "ar,de,fa", 8); + hb_blob_destroy (dlng); + hb_blob_t *fslf = hb_ot_metadata_reference_entry (face, (hb_ot_metadata_t) HB_TAG ('f','s','l','f')); + g_assert_cmpint (hb_blob_get_length (fslf), ==, 12); + hb_blob_destroy (fslf); + hb_blob_t *nacl = hb_ot_metadata_reference_entry (face, (hb_ot_metadata_t) HB_TAG ('n','a','c','l')); + g_assert_cmpint (hb_blob_get_length (nacl), ==, 0); + hb_blob_destroy (nacl); + hb_blob_t *slng = hb_ot_metadata_reference_entry (face, HB_OT_METADATA_SUPPORTED_LANGUAGES); + g_assert_cmpint (hb_blob_get_length (slng), ==, 11); + g_assert_cmpmem (hb_blob_get_data (slng, NULL), 11, "ar,de,en,fa", 11); + hb_blob_destroy (slng); + hb_face_destroy (face); +} + +int +main (int argc, char **argv) +{ + hb_test_init (&argc, &argv); + hb_test_add (test_ot_metadata_reference_entry); + return hb_test_run (); +} From bc65ebbce765545bc4455d8ae5ba4a6a99201e41 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Wed, 24 Jul 2019 02:28:09 +0430 Subject: [PATCH 09/30] [meta] hb_ot_metadata_get_entries, tags iteration API --- src/hb-ot-meta-table.hh | 17 +++++++++++++++++ src/hb-ot-metadata.cc | 28 ++++++++++++++++++++++++---- src/hb-ot-metadata.h | 8 +++++++- test/api/test-ot-metadata.c | 26 ++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 5 deletions(-) diff --git a/src/hb-ot-meta-table.hh b/src/hb-ot-meta-table.hh index d36c3e94f..7d60c7662 100644 --- a/src/hb-ot-meta-table.hh +++ b/src/hb-ot-meta-table.hh @@ -42,6 +42,8 @@ struct DataMap { int cmp (hb_tag_t a) const { return tag.cmp (a); } + hb_tag_t get_tag () const { return tag; } + hb_blob_t *reference_entry (hb_blob_t *meta_blob) const { return hb_blob_create_sub_blob (meta_blob, dataZ, dataLength); } @@ -76,6 +78,21 @@ struct meta hb_blob_t *reference_entry (hb_tag_t tag) const { return table->dataMaps.lsearch (tag, Null (DataMap)).reference_entry (table.get_blob ()); } + unsigned int get_entries (unsigned int start_offset, + unsigned int *count, + hb_ot_metadata_t *entries) const + { + unsigned int entries_count = table->dataMaps.len; + if (count && *count) + { + unsigned int len = hb_min (entries_count - start_offset, *count); + for (unsigned int i = 0; i < len; i++) + entries[i] = (hb_ot_metadata_t) table->dataMaps[i + start_offset].get_tag (); + *count = len; + } + return table->dataMaps.len; + } + private: hb_blob_ptr_t table; }; diff --git a/src/hb-ot-metadata.cc b/src/hb-ot-metadata.cc index 42153be73..8ad602a91 100644 --- a/src/hb-ot-metadata.cc +++ b/src/hb-ot-metadata.cc @@ -38,9 +38,29 @@ **/ /** - * hb_ot_meta_reference_entry: + * hb_ot_metadata_reference_entry: + * @face: a face object + * @start_offset: iteration's start offset + * @entries_count:(inout) (allow-none): buffer size as input, filled size as output + * @entries: (out caller-allocates) (array length=entries_count): entries tags buffer + * + * Return value: Number of all available feature types. + * + * Since: REPLACEME + **/ +unsigned int +hb_ot_metadata_get_entries (hb_face_t *face, + unsigned int start_offset, + unsigned int *entries_count, /* IN/OUT. May be NULL. */ + hb_ot_metadata_t *entries /* OUT. May be NULL. */) +{ + return face->table.meta->get_entries (start_offset, entries_count, entries); +} + +/** + * hb_ot_metadata_reference_entry: * @face: a #hb_face_t object. - * @meta_tag: tag of metadata you like to have. + * @metadata_tag: tag of metadata you like to have. * * It fetches metadata entry of a given tag from a font. * @@ -49,9 +69,9 @@ * Since: REPLACEME **/ hb_blob_t * -hb_ot_metadata_reference_entry (hb_face_t *face, hb_ot_metadata_t meta_tag) +hb_ot_metadata_reference_entry (hb_face_t *face, hb_ot_metadata_t metadata_tag) { - return face->table.meta->reference_entry (meta_tag); + return face->table.meta->reference_entry (metadata_tag); } #endif diff --git a/src/hb-ot-metadata.h b/src/hb-ot-metadata.h index 3654458a1..5d26e1d5a 100644 --- a/src/hb-ot-metadata.h +++ b/src/hb-ot-metadata.h @@ -49,8 +49,14 @@ typedef enum { HB_OT_METADATA_SUPPORTED_LANGUAGES = HB_TAG ('s','l','n','g') } hb_ot_metadata_t; +HB_EXTERN unsigned int +hb_ot_metadata_get_entries (hb_face_t *face, + unsigned int start_offset, + unsigned int *entries_count, /* IN/OUT. May be NULL. */ + hb_ot_metadata_t *entries /* OUT. May be NULL. */); + HB_EXTERN hb_blob_t * -hb_ot_metadata_reference_entry (hb_face_t *face, hb_ot_metadata_t tag); +hb_ot_metadata_reference_entry (hb_face_t *face, hb_ot_metadata_t metadata_tag); HB_END_DECLS diff --git a/test/api/test-ot-metadata.c b/test/api/test-ot-metadata.c index d5f922415..f0e633e50 100644 --- a/test/api/test-ot-metadata.c +++ b/test/api/test-ot-metadata.c @@ -28,6 +28,31 @@ /* Unit tests for hb-ot-metadata.h */ +static void +test_ot_metadata_get_entries (void) +{ + hb_face_t *face = hb_test_open_font_file ("fonts/meta.ttf"); + hb_ot_metadata_t entries[2]; + + unsigned int entries_count = 2; + g_assert_cmpint (hb_ot_metadata_get_entries (face, 0, &entries_count, entries), ==, 5); + g_assert_cmpint (entries_count, ==, 2); + g_assert_cmpint (entries[0], ==, HB_TAG ('a','p','p','l')); + g_assert_cmpint (entries[1], ==, HB_TAG ('b','i','l','d')); + + entries_count = 1; + g_assert_cmpint (hb_ot_metadata_get_entries (face, 2, &entries_count, entries), ==, 5); + g_assert_cmpint (entries_count, ==, 1); + g_assert_cmpint (entries[0], ==, HB_TAG ('d','l','n','g')); + + entries_count = 2; + g_assert_cmpint (hb_ot_metadata_get_entries (face, 4, &entries_count, entries), ==, 5); + g_assert_cmpint (entries_count, ==, 1); + g_assert_cmpint (entries[0], ==, HB_TAG ('s','l','n','g')); + + hb_face_destroy (face); +} + static void test_ot_metadata_reference_entry (void) { @@ -53,6 +78,7 @@ int main (int argc, char **argv) { hb_test_init (&argc, &argv); + hb_test_add (test_ot_metadata_get_entries); hb_test_add (test_ot_metadata_reference_entry); return hb_test_run (); } From 80e246a1f2b3c4e3c25a4a3ec042e7610944abd4 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Wed, 24 Jul 2019 03:08:34 +0430 Subject: [PATCH 10/30] [meta] Add a test program for metadata --- src/Makefile.am | 5 +++ src/test-ot-metadata.cc | 70 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 src/test-ot-metadata.cc diff --git a/src/Makefile.am b/src/Makefile.am index 54e4a02cf..84b51ac3e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -332,6 +332,7 @@ noinst_PROGRAMS = \ main \ test \ test-buffer-serialize \ + test-ot-metadata \ test-ot-name \ test-gpos-size-params \ test-gsub-would-substitute \ @@ -350,6 +351,10 @@ test_buffer_serialize_SOURCES = test-buffer-serialize.cc test_buffer_serialize_CPPFLAGS = $(HBCFLAGS) test_buffer_serialize_LDADD = libharfbuzz.la $(HBLIBS) +test_ot_metadata_SOURCES = test-ot-metadata.cc +test_ot_metadata_CPPFLAGS = $(HBCFLAGS) +test_ot_metadata_LDADD = libharfbuzz.la $(HBLIBS) + test_ot_name_SOURCES = test-ot-name.cc test_ot_name_CPPFLAGS = $(HBCFLAGS) test_ot_name_LDADD = libharfbuzz.la $(HBLIBS) diff --git a/src/test-ot-metadata.cc b/src/test-ot-metadata.cc new file mode 100644 index 000000000..5c9e85210 --- /dev/null +++ b/src/test-ot-metadata.cc @@ -0,0 +1,70 @@ +/* + * Copyright © 2019 Ebrahim Byagowi + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + */ + +#include "hb.hh" +#include "hb-ot.h" + +#include +#include + +#ifdef HB_NO_OPEN +#define hb_blob_create_from_file(x) hb_blob_get_empty () +#endif + +int +main (int argc, char **argv) +{ + if (argc != 2) { + fprintf (stderr, "usage: %s font-file\n", argv[0]); + exit (1); + } + + hb_blob_t *blob = hb_blob_create_from_file (argv[1]); + hb_face_t *face = hb_face_create (blob, 0 /* first face */); + hb_blob_destroy (blob); + blob = nullptr; + + unsigned int count = 0; + +#ifndef HB_NO_META + count = hb_ot_metadata_get_entries (face, 0, nullptr, nullptr); + + hb_ot_metadata_t *tags = (hb_ot_metadata_t *) + malloc (sizeof (hb_ot_metadata_t) * count); + hb_ot_metadata_get_entries (face, 0, &count, tags); + for (unsigned i = 0; i < count; ++i) + { + hb_blob_t *entry = hb_ot_metadata_reference_entry (face, tags[i]); + printf ("%c%c%c%c, size: %d: %.*s\n", + HB_UNTAG (tags[i]), hb_blob_get_length (entry), + hb_blob_get_length (entry), hb_blob_get_data (entry, nullptr)); + hb_blob_destroy (entry); + } + free (tags); +#endif + + hb_face_destroy (face); + + return !count; +} From a250af98ae74c94ac3aa069e6e5958a937586bfc Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Wed, 24 Jul 2019 03:10:41 +0430 Subject: [PATCH 11/30] [meta] Add max value to hb_ot_metadata_t --- src/hb-ot-metadata.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hb-ot-metadata.h b/src/hb-ot-metadata.h index 5d26e1d5a..71e92a81f 100644 --- a/src/hb-ot-metadata.h +++ b/src/hb-ot-metadata.h @@ -46,7 +46,9 @@ typedef enum { HB_OT_METADATA_BILD = HB_TAG ('b','i','l','d'), */ HB_OT_METADATA_DESIGN_LANGUAGES = HB_TAG ('d','l','n','g'), - HB_OT_METADATA_SUPPORTED_LANGUAGES = HB_TAG ('s','l','n','g') + HB_OT_METADATA_SUPPORTED_LANGUAGES = HB_TAG ('s','l','n','g'), + + _HB_OT_METADATA_MAX_VALUE = HB_TAG_MAX_SIGNED /*< skip >*/ } hb_ot_metadata_t; HB_EXTERN unsigned int From 821d9e9034c57c5c593741284b134c76cc3c7c0f Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Fri, 26 Jul 2019 00:08:58 +0430 Subject: [PATCH 12/30] Use .sub_array for DataMap tags iteration --- src/hb-ot-meta-table.hh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/hb-ot-meta-table.hh b/src/hb-ot-meta-table.hh index 7d60c7662..a7bd7bffc 100644 --- a/src/hb-ot-meta-table.hh +++ b/src/hb-ot-meta-table.hh @@ -82,13 +82,11 @@ struct meta unsigned int *count, hb_ot_metadata_t *entries) const { - unsigned int entries_count = table->dataMaps.len; if (count && *count) { - unsigned int len = hb_min (entries_count - start_offset, *count); - for (unsigned int i = 0; i < len; i++) - entries[i] = (hb_ot_metadata_t) table->dataMaps[i + start_offset].get_tag (); - *count = len; + hb_array_t array = table->dataMaps.sub_array (start_offset, count); + for (unsigned int i = 0; i < *count; i++) + entries[i] = (hb_ot_metadata_t) array[i].get_tag (); } return table->dataMaps.len; } From 62932c14bd256f10031380047ededd93a2aacd88 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Fri, 26 Jul 2019 00:30:29 +0430 Subject: [PATCH 13/30] [meta] Rename ot-metadata to ot-meta per review --- docs/harfbuzz-sections.txt | 7 +++-- src/Makefile.am | 8 ++--- src/Makefile.sources | 4 +-- src/harfbuzz.cc | 2 +- src/hb-ot-meta-table.hh | 8 ++--- src/{hb-ot-metadata.cc => hb-ot-meta.cc} | 22 +++++++------- src/{hb-ot-metadata.h => hb-ot-meta.h} | 30 +++++++++---------- src/hb-ot.h | 2 +- src/{test-ot-metadata.cc => test-ot-meta.cc} | 10 +++---- test/api/Makefile.am | 2 +- .../{test-ot-metadata.c => test-ot-meta.c} | 26 ++++++++-------- 11 files changed, 61 insertions(+), 60 deletions(-) rename src/{hb-ot-metadata.cc => hb-ot-meta.cc} (77%) rename src/{hb-ot-metadata.h => hb-ot-meta.h} (65%) rename src/{test-ot-metadata.cc => test-ot-meta.cc} (86%) rename test/api/{test-ot-metadata.c => test-ot-meta.c} (72%) diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt index 888859e28..99916ebe2 100644 --- a/docs/harfbuzz-sections.txt +++ b/docs/harfbuzz-sections.txt @@ -608,9 +608,10 @@ hb_ot_math_get_glyph_assembly
-hb-ot-metadata -hb_ot_metadata_reference_entry -hb_ot_metadata_t +hb-ot-meta +hb_ot_meta_t +hb_ot_meta_get_entries +hb_ot_meta_reference_entry
diff --git a/src/Makefile.am b/src/Makefile.am index 84b51ac3e..7173f4b7d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -332,7 +332,7 @@ noinst_PROGRAMS = \ main \ test \ test-buffer-serialize \ - test-ot-metadata \ + test-ot-meta \ test-ot-name \ test-gpos-size-params \ test-gsub-would-substitute \ @@ -351,9 +351,9 @@ test_buffer_serialize_SOURCES = test-buffer-serialize.cc test_buffer_serialize_CPPFLAGS = $(HBCFLAGS) test_buffer_serialize_LDADD = libharfbuzz.la $(HBLIBS) -test_ot_metadata_SOURCES = test-ot-metadata.cc -test_ot_metadata_CPPFLAGS = $(HBCFLAGS) -test_ot_metadata_LDADD = libharfbuzz.la $(HBLIBS) +test_ot_meta_SOURCES = test-ot-meta.cc +test_ot_meta_CPPFLAGS = $(HBCFLAGS) +test_ot_meta_LDADD = libharfbuzz.la $(HBLIBS) test_ot_name_SOURCES = test-ot-name.cc test_ot_name_CPPFLAGS = $(HBCFLAGS) diff --git a/src/Makefile.sources b/src/Makefile.sources index a024381ab..a8369bf1a 100644 --- a/src/Makefile.sources +++ b/src/Makefile.sources @@ -89,7 +89,7 @@ HB_BASE_sources = \ hb-ot-math.cc \ hb-ot-maxp-table.hh \ hb-ot-meta-table.hh \ - hb-ot-metadata.cc \ + hb-ot-meta.cc \ hb-ot-metrics.cc \ hb-ot-metrics.hh \ hb-ot-name-language-static.hh \ @@ -195,7 +195,7 @@ HB_BASE_headers = \ hb-ot-font.h \ hb-ot-layout.h \ hb-ot-math.h \ - hb-ot-metadata.h \ + hb-ot-meta.h \ hb-ot-metrics.h \ hb-ot-name.h \ hb-ot-shape.h \ diff --git a/src/harfbuzz.cc b/src/harfbuzz.cc index d97143981..d338d1735 100644 --- a/src/harfbuzz.cc +++ b/src/harfbuzz.cc @@ -16,7 +16,7 @@ #include "hb-ot-layout.cc" #include "hb-ot-map.cc" #include "hb-ot-math.cc" -#include "hb-ot-metadata.cc" +#include "hb-ot-meta.cc" #include "hb-ot-metrics.cc" #include "hb-ot-name.cc" #include "hb-ot-shape-complex-arabic.cc" diff --git a/src/hb-ot-meta-table.hh b/src/hb-ot-meta-table.hh index a7bd7bffc..cc31bfb32 100644 --- a/src/hb-ot-meta-table.hh +++ b/src/hb-ot-meta-table.hh @@ -78,15 +78,15 @@ struct meta hb_blob_t *reference_entry (hb_tag_t tag) const { return table->dataMaps.lsearch (tag, Null (DataMap)).reference_entry (table.get_blob ()); } - unsigned int get_entries (unsigned int start_offset, - unsigned int *count, - hb_ot_metadata_t *entries) const + unsigned int get_entries (unsigned int start_offset, + unsigned int *count, + hb_ot_meta_t *entries) const { if (count && *count) { hb_array_t array = table->dataMaps.sub_array (start_offset, count); for (unsigned int i = 0; i < *count; i++) - entries[i] = (hb_ot_metadata_t) array[i].get_tag (); + entries[i] = (hb_ot_meta_t) array[i].get_tag (); } return table->dataMaps.len; } diff --git a/src/hb-ot-metadata.cc b/src/hb-ot-meta.cc similarity index 77% rename from src/hb-ot-metadata.cc rename to src/hb-ot-meta.cc index 8ad602a91..78eca6829 100644 --- a/src/hb-ot-metadata.cc +++ b/src/hb-ot-meta.cc @@ -29,8 +29,8 @@ #include "hb-ot-meta-table.hh" /** - * SECTION:hb-ot-metadata - * @title: hb-ot-metadata + * SECTION:hb-ot-meta + * @title: hb-ot-meta * @short_description: OpenType Metadata * @include: hb-ot.h * @@ -38,7 +38,7 @@ **/ /** - * hb_ot_metadata_reference_entry: + * hb_ot_meta_reference_entry: * @face: a face object * @start_offset: iteration's start offset * @entries_count:(inout) (allow-none): buffer size as input, filled size as output @@ -49,18 +49,18 @@ * Since: REPLACEME **/ unsigned int -hb_ot_metadata_get_entries (hb_face_t *face, - unsigned int start_offset, - unsigned int *entries_count, /* IN/OUT. May be NULL. */ - hb_ot_metadata_t *entries /* OUT. May be NULL. */) +hb_ot_meta_get_entries (hb_face_t *face, + unsigned int start_offset, + unsigned int *entries_count, /* IN/OUT. May be NULL. */ + hb_ot_meta_t *entries /* OUT. May be NULL. */) { return face->table.meta->get_entries (start_offset, entries_count, entries); } /** - * hb_ot_metadata_reference_entry: + * hb_ot_meta_reference_entry: * @face: a #hb_face_t object. - * @metadata_tag: tag of metadata you like to have. + * @meta_tag: tag of metadata you like to have. * * It fetches metadata entry of a given tag from a font. * @@ -69,9 +69,9 @@ hb_ot_metadata_get_entries (hb_face_t *face, * Since: REPLACEME **/ hb_blob_t * -hb_ot_metadata_reference_entry (hb_face_t *face, hb_ot_metadata_t metadata_tag) +hb_ot_meta_reference_entry (hb_face_t *face, hb_ot_meta_t meta_tag) { - return face->table.meta->reference_entry (metadata_tag); + return face->table.meta->reference_entry (meta_tag); } #endif diff --git a/src/hb-ot-metadata.h b/src/hb-ot-meta.h similarity index 65% rename from src/hb-ot-metadata.h rename to src/hb-ot-meta.h index 71e92a81f..e80273a7b 100644 --- a/src/hb-ot-metadata.h +++ b/src/hb-ot-meta.h @@ -26,15 +26,15 @@ #error "Include instead." #endif -#ifndef HB_OT_METADATA_H -#define HB_OT_METADATA_H +#ifndef HB_OT_META_H +#define HB_OT_META_H #include "hb.h" HB_BEGIN_DECLS /** - * hb_ot_metadata_t: + * hb_ot_meta_t: * * From https://docs.microsoft.com/en-us/typography/opentype/spec/meta * @@ -42,24 +42,24 @@ HB_BEGIN_DECLS **/ typedef enum { /* - HB_OT_METADATA_APPL = HB_TAG ('a','p','p','l'), - HB_OT_METADATA_BILD = HB_TAG ('b','i','l','d'), + HB_OT_META_APPL = HB_TAG ('a','p','p','l'), + HB_OT_META_BILD = HB_TAG ('b','i','l','d'), */ - HB_OT_METADATA_DESIGN_LANGUAGES = HB_TAG ('d','l','n','g'), - HB_OT_METADATA_SUPPORTED_LANGUAGES = HB_TAG ('s','l','n','g'), + HB_OT_META_DESIGN_LANGUAGES = HB_TAG ('d','l','n','g'), + HB_OT_META_SUPPORTED_LANGUAGES= HB_TAG ('s','l','n','g'), - _HB_OT_METADATA_MAX_VALUE = HB_TAG_MAX_SIGNED /*< skip >*/ -} hb_ot_metadata_t; + _HB_OT_META_MAX_VALUE = HB_TAG_MAX_SIGNED /*< skip >*/ +} hb_ot_meta_t; HB_EXTERN unsigned int -hb_ot_metadata_get_entries (hb_face_t *face, - unsigned int start_offset, - unsigned int *entries_count, /* IN/OUT. May be NULL. */ - hb_ot_metadata_t *entries /* OUT. May be NULL. */); +hb_ot_meta_get_entries (hb_face_t *face, + unsigned int start_offset, + unsigned int *entries_count, /* IN/OUT. May be NULL. */ + hb_ot_meta_t *entries /* OUT. May be NULL. */); HB_EXTERN hb_blob_t * -hb_ot_metadata_reference_entry (hb_face_t *face, hb_ot_metadata_t metadata_tag); +hb_ot_meta_reference_entry (hb_face_t *face, hb_ot_meta_t meta_tag); HB_END_DECLS -#endif /* HB_OT_METADATA_H */ +#endif /* HB_OT_META_H */ diff --git a/src/hb-ot.h b/src/hb-ot.h index 411d0936f..f2dbaa1b3 100644 --- a/src/hb-ot.h +++ b/src/hb-ot.h @@ -35,7 +35,7 @@ #include "hb-ot-font.h" #include "hb-ot-layout.h" #include "hb-ot-math.h" -#include "hb-ot-metadata.h" +#include "hb-ot-meta.h" #include "hb-ot-metrics.h" #include "hb-ot-name.h" #include "hb-ot-shape.h" diff --git a/src/test-ot-metadata.cc b/src/test-ot-meta.cc similarity index 86% rename from src/test-ot-metadata.cc rename to src/test-ot-meta.cc index 5c9e85210..33b1ee94e 100644 --- a/src/test-ot-metadata.cc +++ b/src/test-ot-meta.cc @@ -48,14 +48,14 @@ main (int argc, char **argv) unsigned int count = 0; #ifndef HB_NO_META - count = hb_ot_metadata_get_entries (face, 0, nullptr, nullptr); + count = hb_ot_meta_get_entries (face, 0, nullptr, nullptr); - hb_ot_metadata_t *tags = (hb_ot_metadata_t *) - malloc (sizeof (hb_ot_metadata_t) * count); - hb_ot_metadata_get_entries (face, 0, &count, tags); + hb_ot_meta_t *tags = (hb_ot_meta_t *) + malloc (sizeof (hb_ot_meta_t) * count); + hb_ot_meta_get_entries (face, 0, &count, tags); for (unsigned i = 0; i < count; ++i) { - hb_blob_t *entry = hb_ot_metadata_reference_entry (face, tags[i]); + hb_blob_t *entry = hb_ot_meta_reference_entry (face, tags[i]); printf ("%c%c%c%c, size: %d: %.*s\n", HB_UNTAG (tags[i]), hb_blob_get_length (entry), hb_blob_get_length (entry), hb_blob_get_data (entry, nullptr)); diff --git a/test/api/Makefile.am b/test/api/Makefile.am index a675c50ff..2386e53ea 100644 --- a/test/api/Makefile.am +++ b/test/api/Makefile.am @@ -84,7 +84,7 @@ TEST_PROGS += \ test-ot-color \ test-ot-ligature-carets \ test-ot-name \ - test-ot-metadata \ + test-ot-meta \ test-ot-metrics \ test-ot-tag \ test-ot-extents-cff \ diff --git a/test/api/test-ot-metadata.c b/test/api/test-ot-meta.c similarity index 72% rename from test/api/test-ot-metadata.c rename to test/api/test-ot-meta.c index f0e633e50..a08e67dc5 100644 --- a/test/api/test-ot-metadata.c +++ b/test/api/test-ot-meta.c @@ -26,27 +26,27 @@ #include -/* Unit tests for hb-ot-metadata.h */ +/* Unit tests for hb-ot-meta.h */ static void -test_ot_metadata_get_entries (void) +test_ot_meta_get_entries (void) { hb_face_t *face = hb_test_open_font_file ("fonts/meta.ttf"); - hb_ot_metadata_t entries[2]; + hb_ot_meta_t entries[2]; unsigned int entries_count = 2; - g_assert_cmpint (hb_ot_metadata_get_entries (face, 0, &entries_count, entries), ==, 5); + g_assert_cmpint (hb_ot_meta_get_entries (face, 0, &entries_count, entries), ==, 5); g_assert_cmpint (entries_count, ==, 2); g_assert_cmpint (entries[0], ==, HB_TAG ('a','p','p','l')); g_assert_cmpint (entries[1], ==, HB_TAG ('b','i','l','d')); entries_count = 1; - g_assert_cmpint (hb_ot_metadata_get_entries (face, 2, &entries_count, entries), ==, 5); + g_assert_cmpint (hb_ot_meta_get_entries (face, 2, &entries_count, entries), ==, 5); g_assert_cmpint (entries_count, ==, 1); g_assert_cmpint (entries[0], ==, HB_TAG ('d','l','n','g')); entries_count = 2; - g_assert_cmpint (hb_ot_metadata_get_entries (face, 4, &entries_count, entries), ==, 5); + g_assert_cmpint (hb_ot_meta_get_entries (face, 4, &entries_count, entries), ==, 5); g_assert_cmpint (entries_count, ==, 1); g_assert_cmpint (entries[0], ==, HB_TAG ('s','l','n','g')); @@ -54,20 +54,20 @@ test_ot_metadata_get_entries (void) } static void -test_ot_metadata_reference_entry (void) +test_ot_meta_reference_entry (void) { hb_face_t *face = hb_test_open_font_file ("fonts/meta.ttf"); - hb_blob_t *dlng = hb_ot_metadata_reference_entry (face, HB_OT_METADATA_DESIGN_LANGUAGES); + hb_blob_t *dlng = hb_ot_meta_reference_entry (face, HB_OT_META_DESIGN_LANGUAGES); g_assert_cmpint (hb_blob_get_length (dlng), ==, 8); g_assert_cmpmem (hb_blob_get_data (dlng, NULL), 8, "ar,de,fa", 8); hb_blob_destroy (dlng); - hb_blob_t *fslf = hb_ot_metadata_reference_entry (face, (hb_ot_metadata_t) HB_TAG ('f','s','l','f')); + hb_blob_t *fslf = hb_ot_meta_reference_entry (face, (hb_ot_meta_t) HB_TAG ('f','s','l','f')); g_assert_cmpint (hb_blob_get_length (fslf), ==, 12); hb_blob_destroy (fslf); - hb_blob_t *nacl = hb_ot_metadata_reference_entry (face, (hb_ot_metadata_t) HB_TAG ('n','a','c','l')); + hb_blob_t *nacl = hb_ot_meta_reference_entry (face, (hb_ot_meta_t) HB_TAG ('n','a','c','l')); g_assert_cmpint (hb_blob_get_length (nacl), ==, 0); hb_blob_destroy (nacl); - hb_blob_t *slng = hb_ot_metadata_reference_entry (face, HB_OT_METADATA_SUPPORTED_LANGUAGES); + hb_blob_t *slng = hb_ot_meta_reference_entry (face, HB_OT_META_SUPPORTED_LANGUAGES); g_assert_cmpint (hb_blob_get_length (slng), ==, 11); g_assert_cmpmem (hb_blob_get_data (slng, NULL), 11, "ar,de,en,fa", 11); hb_blob_destroy (slng); @@ -78,7 +78,7 @@ int main (int argc, char **argv) { hb_test_init (&argc, &argv); - hb_test_add (test_ot_metadata_get_entries); - hb_test_add (test_ot_metadata_reference_entry); + hb_test_add (test_ot_meta_get_entries); + hb_test_add (test_ot_meta_reference_entry); return hb_test_run (); } From aaffe41094f8ddefad6f33e86cbd04a24dd9bfff Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Fri, 26 Jul 2019 01:14:37 +0430 Subject: [PATCH 14/30] [meta] minor, simplify iterator --- src/hb-ot-meta-table.hh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hb-ot-meta-table.hh b/src/hb-ot-meta-table.hh index cc31bfb32..37f627cad 100644 --- a/src/hb-ot-meta-table.hh +++ b/src/hb-ot-meta-table.hh @@ -82,11 +82,11 @@ struct meta unsigned int *count, hb_ot_meta_t *entries) const { - if (count && *count) + if (count) { - hb_array_t array = table->dataMaps.sub_array (start_offset, count); - for (unsigned int i = 0; i < *count; i++) - entries[i] = (hb_ot_meta_t) array[i].get_tag (); + hb_array_t arr = table->dataMaps.sub_array (start_offset, count); + for (unsigned int i = 0; i < arr.length; i++) + entries[i] = (hb_ot_meta_t) arr[i].get_tag (); } return table->dataMaps.len; } From d3d99f8bb6ad77d1ac73901885acfffd3bb3e7f7 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Fri, 26 Jul 2019 16:46:04 +0430 Subject: [PATCH 15/30] [metrics] Expose raw OS2/HHEA asc/dsc values using private tags (#1867) --- src/hb-ot-metrics.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/hb-ot-metrics.cc b/src/hb-ot-metrics.cc index d0694bb51..07eb4667a 100644 --- a/src/hb-ot-metrics.cc +++ b/src/hb-ot-metrics.cc @@ -100,6 +100,14 @@ _get_gasp (hb_face_t *face, float *result, hb_ot_metrics_t metrics_tag) } #endif +/* Private tags for https://github.com/harfbuzz/harfbuzz/issues/1866 */ +#define _HB_OT_METRICS_HORIZONTAL_ASCENDER_OS2 HB_TAG ('O','a','s','c') +#define _HB_OT_METRICS_HORIZONTAL_ASCENDER_HHEA HB_TAG ('H','a','s','c') +#define _HB_OT_METRICS_HORIZONTAL_DESCENDER_OS2 HB_TAG ('O','d','s','c') +#define _HB_OT_METRICS_HORIZONTAL_DESCENDER_HHEA HB_TAG ('H','d','s','c') +#define _HB_OT_METRICS_HORIZONTAL_LINE_GAP_OS2 HB_TAG ('O','l','g','p') +#define _HB_OT_METRICS_HORIZONTAL_LINE_GAP_HHEA HB_TAG ('H','l','g','p') + /** * hb_ot_metrics_get_position: * @font: a #hb_font_t object. @@ -158,6 +166,14 @@ hb_ot_metrics_get_position (hb_font_t *font, case HB_OT_METRICS_STRIKEOUT_OFFSET: return GET_METRIC_Y (OS2, yStrikeoutPosition); case HB_OT_METRICS_UNDERLINE_SIZE: return GET_METRIC_Y (post->table, underlineThickness); case HB_OT_METRICS_UNDERLINE_OFFSET: return GET_METRIC_Y (post->table, underlinePosition); + + /* Private tags */ + case _HB_OT_METRICS_HORIZONTAL_ASCENDER_OS2: return GET_METRIC_Y (OS2, sTypoAscender); + case _HB_OT_METRICS_HORIZONTAL_ASCENDER_HHEA: return GET_METRIC_Y (hhea, ascender); + case _HB_OT_METRICS_HORIZONTAL_DESCENDER_OS2: return GET_METRIC_Y (OS2, sTypoDescender); + case _HB_OT_METRICS_HORIZONTAL_DESCENDER_HHEA: return GET_METRIC_Y (hhea, descender); + case _HB_OT_METRICS_HORIZONTAL_LINE_GAP_OS2: return GET_METRIC_Y (OS2, sTypoLineGap); + case _HB_OT_METRICS_HORIZONTAL_LINE_GAP_HHEA: return GET_METRIC_Y (hhea, lineGap); #undef GET_METRIC_Y #undef GET_METRIC_X #undef GET_VAR From 6d53cda1baf130853e5725fe8fea1d1c5f766a79 Mon Sep 17 00:00:00 2001 From: Zero King Date: Fri, 26 Jul 2019 15:43:51 +0000 Subject: [PATCH 16/30] [util] Fix memory leak --- util/options.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/util/options.cc b/util/options.cc index 42dfa956a..f71a5a34d 100644 --- a/util/options.cc +++ b/util/options.cc @@ -370,6 +370,7 @@ parse_unicodes (const char *name G_GNUC_UNUSED, hb_codepoint_t u = strtoul (s, &p, 16); if (errno || s == p) { + g_string_free (gs, TRUE); g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE, "Failed parsing Unicode values at: '%s'", s); return false; From 658424b29efbc758541a790193c42171bb7fa965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Derzsi=20D=C3=A1niel?= Date: Fri, 26 Jul 2019 22:52:03 +0300 Subject: [PATCH 17/30] [cmake] Fix CMake build on newer CMake versions Unfortunately, newer CMake versions die during regex variable extraction, causing the build to fail. This is caused by the lack of escaping used around variables in the extract_make_variable function, causing these variables to be automatically unwrapped into empty strings. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac857ef8f..66e4a8388 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,8 +142,8 @@ endif () ## Extract variables from Makefile files function (extract_make_variable variable makefile_source) - string(REGEX MATCH "${variable} = ([^$]+)\\$" temp ${makefile_source}) - string(REGEX MATCHALL "[^ \n\t\\]+" listVar ${CMAKE_MATCH_1}) + string(REGEX MATCH "${variable} = ([^$]+)\\$" temp "${makefile_source}") + string(REGEX MATCHALL "[^ \n\t\\]+" listVar "${CMAKE_MATCH_1}") set (${variable} ${listVar} PARENT_SCOPE) endfunction () From 0a18efd766b3b6cc987ee18785f7858fe2bd1c67 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 26 Jul 2019 14:34:26 -0700 Subject: [PATCH 18/30] Minor --- src/hb-ot-layout-gsub-table.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index a6cc1a230..84e1b1578 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -248,7 +248,7 @@ struct SingleSubst if (unlikely (!c->extend_min (u.format))) return_trace (false); unsigned format = 2; unsigned delta = 0; - if (glyphs.len ()) + if (glyphs) { format = 1; auto get_delta = [=] (hb_codepoint_pair_t _) { From eddd45653282ffff8ef002ad2163bcf8bf4f3df1 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sun, 28 Jul 2019 02:21:54 +0430 Subject: [PATCH 19/30] [base] minor spacing --- src/hb-ot-layout-base-table.hh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hb-ot-layout-base-table.hh b/src/hb-ot-layout-base-table.hh index 091236294..91facf875 100644 --- a/src/hb-ot-layout-base-table.hh +++ b/src/hb-ot-layout-base-table.hh @@ -195,8 +195,8 @@ struct FeatMinMaxRecord struct MinMax { void get_min_max (hb_tag_t feature_tag, - const BaseCoord **min, - const BaseCoord **max) const + const BaseCoord **min, + const BaseCoord **max) const { /* TODO Replace hb_bsearch() with .bsearch(). */ const FeatMinMaxRecord *minMaxCoord = (const FeatMinMaxRecord *) @@ -412,9 +412,9 @@ struct BaseScriptList struct Axis { bool get_baseline (hb_ot_layout_baseline_t baseline, - hb_tag_t script_tag, - hb_tag_t language_tag, - const BaseCoord **coord) const + hb_tag_t script_tag, + hb_tag_t language_tag, + const BaseCoord **coord) const { const BaseScript &base_script = (this+baseScriptList).get_base_script (script_tag); if (base_script.is_empty ()) return false; From a157342fce2616141ee62d68ad8e3fb93e52187e Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sun, 28 Jul 2019 18:54:13 +0430 Subject: [PATCH 20/30] [base] Fix use of bsearch --- src/hb-ot-layout-base-table.hh | 94 +++++++++++----------------------- 1 file changed, 31 insertions(+), 63 deletions(-) diff --git a/src/hb-ot-layout-base-table.hh b/src/hb-ot-layout-base-table.hh index 91facf875..ee3aad961 100644 --- a/src/hb-ot-layout-base-table.hh +++ b/src/hb-ot-layout-base-table.hh @@ -1,7 +1,7 @@ /* - * Copyright © 2016 Elie Roux + * Copyright © 2016 Elie Roux * Copyright © 2018 Google, Inc. - * Copyright © 2018 Ebrahim Byagowi + * Copyright © 2018-2019 Ebrahim Byagowi * * This is part of HarfBuzz, a text shaping library. * @@ -32,9 +32,6 @@ #include "hb-open-type.hh" #include "hb-ot-layout-common.hh" -/* To be removed */ -typedef hb_tag_t hb_ot_layout_baseline_t; - namespace OT { /* @@ -153,14 +150,9 @@ struct BaseCoord struct FeatMinMaxRecord { - HB_INTERNAL static int cmp (const void *key_, const void *entry_) - { - hb_tag_t key = * (hb_tag_t *) key_; - const FeatMinMaxRecord &entry = * (const FeatMinMaxRecord *) entry_; - return key < (unsigned int) entry.tag ? -1 : - key > (unsigned int) entry.tag ? 1 : - 0; - } + int cmp (hb_tag_t key) const { return tag.cmp (key); } + + bool has_data () const { return tag; } void get_min_max (const BaseCoord **min, const BaseCoord **max) const { @@ -198,14 +190,9 @@ struct MinMax const BaseCoord **min, const BaseCoord **max) const { - /* TODO Replace hb_bsearch() with .bsearch(). */ - const FeatMinMaxRecord *minMaxCoord = (const FeatMinMaxRecord *) - hb_bsearch (&feature_tag, featMinMaxRecords.arrayZ, - featMinMaxRecords.len, - FeatMinMaxRecord::static_size, - FeatMinMaxRecord::cmp); - if (minMaxCoord) - minMaxCoord->get_min_max (min, max); + const FeatMinMaxRecord &minMaxCoord = featMinMaxRecords.bsearch (feature_tag); + if (minMaxCoord.has_data ()) + minMaxCoord.get_min_max (min, max); else { if (likely (min)) *min = &(this+minCoord); @@ -271,14 +258,9 @@ struct BaseValues struct BaseLangSysRecord { - HB_INTERNAL static int cmp (const void *key_, const void *entry_) - { - hb_tag_t key = * (hb_tag_t *) key_; - const BaseLangSysRecord &entry = * (const BaseLangSysRecord *) entry_; - return key < (unsigned int) entry.baseLangSysTag ? -1 : - key > (unsigned int) entry.baseLangSysTag ? 1 : - 0; - } + int cmp (hb_tag_t key) const { return baseLangSysTag.cmp (key); } + + bool has_data () const { return baseLangSysTag; } const MinMax &get_min_max () const { return this+minMax; } @@ -303,19 +285,14 @@ struct BaseScript { const MinMax &get_min_max (hb_tag_t language_tag) const { - /* TODO Replace hb_bsearch() with .bsearch(). */ - const BaseLangSysRecord* record = (const BaseLangSysRecord *) - hb_bsearch (&language_tag, baseLangSysRecords.arrayZ, - baseLangSysRecords.len, - BaseLangSysRecord::static_size, - BaseLangSysRecord::cmp); - return record ? record->get_min_max () : this+defaultMinMax; + const BaseLangSysRecord& record = baseLangSysRecords.bsearch (language_tag); + return record.has_data () ? record.get_min_max () : this+defaultMinMax; } const BaseCoord &get_base_coord (int baseline_tag_index) const { return (this+baseValues).get_base_coord (baseline_tag_index); } - bool is_empty () const { return !baseValues; } + bool has_data () const { return baseValues; } bool sanitize (hb_sanitize_context_t *c) const { @@ -345,14 +322,9 @@ struct BaseScript struct BaseScriptList; struct BaseScriptRecord { - HB_INTERNAL static int cmp (const void *key_, const void *entry_) - { - hb_tag_t key = * (hb_tag_t *) key_; - const BaseScriptRecord &entry = * (const BaseScriptRecord *) entry_; - return key < (unsigned int) entry.baseScriptTag ? -1 : - key > (unsigned int) entry.baseScriptTag ? 1 : - 0; - } + int cmp (hb_tag_t key) const { return baseScriptTag.cmp (key); } + + bool has_data () const { return baseScriptTag; } const BaseScript &get_base_script (const BaseScriptList *list) const { return list+baseScript; } @@ -376,20 +348,11 @@ struct BaseScriptRecord struct BaseScriptList { - const BaseScriptRecord *find_record (hb_tag_t script) const - { - /* TODO Replace hb_bsearch() with .bsearch(). */ - return (const BaseScriptRecord *) hb_bsearch (&script, baseScriptRecords.arrayZ, - baseScriptRecords.len, - BaseScriptRecord::static_size, - BaseScriptRecord::cmp); - } - - /* TODO: Or client should handle fallback? */ const BaseScript &get_base_script (hb_tag_t script) const { - const BaseScriptRecord *record = find_record (script); - if (!record) record = find_record ((hb_script_t) HB_TAG ('D','F','L','T')); + const BaseScriptRecord *record = &baseScriptRecords.bsearch (script); + /* TODO: Or client should handle fallback? */ + if (!record->has_data ()) record = &baseScriptRecords.bsearch (HB_TAG ('D','F','L','T')); return record ? record->get_base_script (this) : Null (BaseScript); } @@ -417,9 +380,14 @@ struct Axis const BaseCoord **coord) const { const BaseScript &base_script = (this+baseScriptList).get_base_script (script_tag); - if (base_script.is_empty ()) return false; + if (!base_script.has_data ()) return false; - if (likely (coord)) *coord = &base_script.get_base_coord ((this+baseTagList).bsearch (baseline)); + if (likely (coord)) + { + unsigned int tag_index = 0; + (this+baseTagList).bfind (baseline, &tag_index); + *coord = &base_script.get_base_coord (tag_index); + } return true; } @@ -431,7 +399,7 @@ struct Axis const BaseCoord **max_coord) const { const BaseScript &base_script = (this+baseScriptList).get_base_script (script_tag); - if (base_script.is_empty ()) return false; + if (!base_script.has_data ()) return false; base_script.get_min_max (language_tag).get_min_max (feature_tag, min_coord, max_coord); @@ -483,9 +451,9 @@ struct BASE if (!get_axis (direction).get_baseline (baseline, script_tag, language_tag, &base_coord)) return false; - if (likely (base && base_coord)) *base = base_coord->get_coord (font, - get_var_store (), - direction); + if (likely (base && base_coord)) + *base = base_coord->get_coord (font, get_var_store (), direction); + return true; } From c7b22b96cc64c81248362a70f2d60d93ee520f2d Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sun, 28 Jul 2019 19:46:57 +0430 Subject: [PATCH 21/30] [base] minor --- src/hb-ot-layout-base-table.hh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/hb-ot-layout-base-table.hh b/src/hb-ot-layout-base-table.hh index ee3aad961..d8b5acc12 100644 --- a/src/hb-ot-layout-base-table.hh +++ b/src/hb-ot-layout-base-table.hh @@ -351,10 +351,8 @@ struct BaseScriptList const BaseScript &get_base_script (hb_tag_t script) const { const BaseScriptRecord *record = &baseScriptRecords.bsearch (script); - /* TODO: Or client should handle fallback? */ if (!record->has_data ()) record = &baseScriptRecords.bsearch (HB_TAG ('D','F','L','T')); - - return record ? record->get_base_script (this) : Null (BaseScript); + return record->has_data () ? record->get_base_script (this) : Null (BaseScript); } bool sanitize (hb_sanitize_context_t *c) const From ed126d8c37c45d8d60eb0368143c6776d1fcfbff Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sun, 28 Jul 2019 20:21:59 +0430 Subject: [PATCH 22/30] [base] fix build --- src/hb-ot-layout-base-table.hh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hb-ot-layout-base-table.hh b/src/hb-ot-layout-base-table.hh index d8b5acc12..1b7bce7db 100644 --- a/src/hb-ot-layout-base-table.hh +++ b/src/hb-ot-layout-base-table.hh @@ -32,6 +32,9 @@ #include "hb-open-type.hh" #include "hb-ot-layout-common.hh" +/* To be removed */ +typedef hb_tag_t hb_ot_layout_baseline_t; + namespace OT { /* From 53853c044a6382ece51393dfc3a4fe6a5f8a5a23 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sun, 28 Jul 2019 20:23:48 +0430 Subject: [PATCH 23/30] [meta] minor --- src/hb-ot-meta-table.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-ot-meta-table.hh b/src/hb-ot-meta-table.hh index 37f627cad..708cdf4ff 100644 --- a/src/hb-ot-meta-table.hh +++ b/src/hb-ot-meta-table.hh @@ -76,7 +76,7 @@ struct meta void fini () { table.destroy (); } hb_blob_t *reference_entry (hb_tag_t tag) const - { return table->dataMaps.lsearch (tag, Null (DataMap)).reference_entry (table.get_blob ()); } + { return table->dataMaps.lsearch (tag).reference_entry (table.get_blob ()); } unsigned int get_entries (unsigned int start_offset, unsigned int *count, From d9c44e7239daf59e283fecd4166c984b43d48e24 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sun, 28 Jul 2019 20:35:32 +0430 Subject: [PATCH 24/30] [base] Check if the returned base_coord is valid --- src/hb-ot-layout-base-table.hh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/hb-ot-layout-base-table.hh b/src/hb-ot-layout-base-table.hh index 1b7bce7db..25a57fb33 100644 --- a/src/hb-ot-layout-base-table.hh +++ b/src/hb-ot-layout-base-table.hh @@ -116,6 +116,8 @@ struct BaseCoordFormat3 struct BaseCoord { + bool has_data () const { return u.format; } + hb_position_t get_coord (hb_font_t *font, const VariationStore &var_store, hb_direction_t direction) const @@ -142,10 +144,10 @@ struct BaseCoord protected: union { - HBUINT16 format; - BaseCoordFormat1 format1; - BaseCoordFormat2 format2; - BaseCoordFormat3 format3; + HBUINT16 format; + BaseCoordFormat1 format1; + BaseCoordFormat2 format2; + BaseCoordFormat3 format3; } u; public: DEFINE_SIZE_UNION (2, format); @@ -449,7 +451,8 @@ struct BASE hb_position_t *base) const { const BaseCoord *base_coord; - if (!get_axis (direction).get_baseline (baseline, script_tag, language_tag, &base_coord)) + if (unlikely (!get_axis (direction).get_baseline (baseline, script_tag, language_tag, &base_coord) && + base_coord && !base_coord->has_data ())) return false; if (likely (base && base_coord)) From 69655d5bc3c7b240424545bdef197d9d7251e509 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sun, 28 Jul 2019 20:39:20 +0430 Subject: [PATCH 25/30] [base] minor --- src/hb-ot-layout-base-table.hh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-layout-base-table.hh b/src/hb-ot-layout-base-table.hh index 25a57fb33..3b69f6c6a 100644 --- a/src/hb-ot-layout-base-table.hh +++ b/src/hb-ot-layout-base-table.hh @@ -267,8 +267,7 @@ struct BaseLangSysRecord bool has_data () const { return baseLangSysTag; } - const MinMax &get_min_max () const - { return this+minMax; } + const MinMax &get_min_max () const { return this+minMax; } bool sanitize (hb_sanitize_context_t *c, const void *base) const { @@ -450,7 +449,7 @@ struct BASE hb_tag_t language_tag, hb_position_t *base) const { - const BaseCoord *base_coord; + const BaseCoord *base_coord = nullptr; if (unlikely (!get_axis (direction).get_baseline (baseline, script_tag, language_tag, &base_coord) && base_coord && !base_coord->has_data ())) return false; From 87454c447d705327a26c1f879e0a4f3002ae2667 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sun, 28 Jul 2019 20:46:47 +0430 Subject: [PATCH 26/30] [base] fix logic --- src/hb-ot-layout-base-table.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-layout-base-table.hh b/src/hb-ot-layout-base-table.hh index 3b69f6c6a..12cc163ce 100644 --- a/src/hb-ot-layout-base-table.hh +++ b/src/hb-ot-layout-base-table.hh @@ -450,11 +450,11 @@ struct BASE hb_position_t *base) const { const BaseCoord *base_coord = nullptr; - if (unlikely (!get_axis (direction).get_baseline (baseline, script_tag, language_tag, &base_coord) && - base_coord && !base_coord->has_data ())) + if (unlikely (!get_axis (direction).get_baseline (baseline, script_tag, language_tag, &base_coord) || + !base_coord || !base_coord->has_data ())) return false; - if (likely (base && base_coord)) + if (likely (base)) *base = base_coord->get_coord (font, get_var_store (), direction); return true; From e21bdf500d4ecc3a5fd6f79aabf6232f3967035e Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sun, 28 Jul 2019 22:59:09 +0430 Subject: [PATCH 27/30] Increase subset fuzzer timeout to 8s Probably we should just remove timeout when running tsan and vaglrind here, the flaky bots --- test/fuzzing/run-subset-fuzzer-tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fuzzing/run-subset-fuzzer-tests.py b/test/fuzzing/run-subset-fuzzer-tests.py index d431e10a3..f94c13ffe 100755 --- a/test/fuzzing/run-subset-fuzzer-tests.py +++ b/test/fuzzing/run-subset-fuzzer-tests.py @@ -33,7 +33,7 @@ def cmd(command): def timeout(p, is_killed): is_killed['value'] = True p.kill() - timer = threading.Timer (6, timeout, [p, is_killed]) + timer = threading.Timer (8, timeout, [p, is_killed]) try: timer.start() From 7bcc5dfa97a43d9c5f6dfdb87b4f0d5a589ecd48 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 28 Jul 2019 20:55:50 -0700 Subject: [PATCH 28/30] [iter] Fix accumulate to accept const types --- src/hb-iter.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-iter.hh b/src/hb-iter.hh index c820c8fb4..8d2ff80c2 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -480,7 +480,7 @@ struct hb_reduce_t template > + typename AccuT = hb_decay> AccuT operator () (Iter it) { From 2c2a2b97dbe24ae2e09018f435559c97a460bdcb Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Mon, 29 Jul 2019 22:01:13 +0430 Subject: [PATCH 29/30] [meta] Rename hb_ot_meta_t to hb_ot_meta_tag_t --- src/hb-ot-meta-table.hh | 10 +++++----- src/hb-ot-meta.cc | 10 +++++----- src/hb-ot-meta.h | 14 +++++++------- src/test-ot-meta.cc | 4 ++-- test/api/test-ot-meta.c | 6 +++--- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/hb-ot-meta-table.hh b/src/hb-ot-meta-table.hh index 708cdf4ff..f0842e4ef 100644 --- a/src/hb-ot-meta-table.hh +++ b/src/hb-ot-meta-table.hh @@ -32,7 +32,7 @@ * https://docs.microsoft.com/en-us/typography/opentype/spec/meta * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6meta.html */ -#define HB_OT_TAG_meta HB_TAG('m','e','t','a') +#define HB_OT_TAG_meta HB_TAG ('m','e','t','a') namespace OT { @@ -78,15 +78,15 @@ struct meta hb_blob_t *reference_entry (hb_tag_t tag) const { return table->dataMaps.lsearch (tag).reference_entry (table.get_blob ()); } - unsigned int get_entries (unsigned int start_offset, - unsigned int *count, - hb_ot_meta_t *entries) const + unsigned int get_entries (unsigned int start_offset, + unsigned int *count, + hb_ot_meta_tag_t *entries) const { if (count) { hb_array_t arr = table->dataMaps.sub_array (start_offset, count); for (unsigned int i = 0; i < arr.length; i++) - entries[i] = (hb_ot_meta_t) arr[i].get_tag (); + entries[i] = (hb_ot_meta_tag_t) arr[i].get_tag (); } return table->dataMaps.len; } diff --git a/src/hb-ot-meta.cc b/src/hb-ot-meta.cc index 78eca6829..a5ce14876 100644 --- a/src/hb-ot-meta.cc +++ b/src/hb-ot-meta.cc @@ -49,10 +49,10 @@ * Since: REPLACEME **/ unsigned int -hb_ot_meta_get_entries (hb_face_t *face, - unsigned int start_offset, - unsigned int *entries_count, /* IN/OUT. May be NULL. */ - hb_ot_meta_t *entries /* OUT. May be NULL. */) +hb_ot_meta_get_entries (hb_face_t *face, + unsigned int start_offset, + unsigned int *entries_count, /* IN/OUT. May be NULL. */ + hb_ot_meta_tag_t *entries /* OUT. May be NULL. */) { return face->table.meta->get_entries (start_offset, entries_count, entries); } @@ -69,7 +69,7 @@ hb_ot_meta_get_entries (hb_face_t *face, * Since: REPLACEME **/ hb_blob_t * -hb_ot_meta_reference_entry (hb_face_t *face, hb_ot_meta_t meta_tag) +hb_ot_meta_reference_entry (hb_face_t *face, hb_ot_meta_tag_t meta_tag) { return face->table.meta->reference_entry (meta_tag); } diff --git a/src/hb-ot-meta.h b/src/hb-ot-meta.h index e80273a7b..5267728ea 100644 --- a/src/hb-ot-meta.h +++ b/src/hb-ot-meta.h @@ -34,7 +34,7 @@ HB_BEGIN_DECLS /** - * hb_ot_meta_t: + * hb_ot_meta_tag_t: * * From https://docs.microsoft.com/en-us/typography/opentype/spec/meta * @@ -49,16 +49,16 @@ typedef enum { HB_OT_META_SUPPORTED_LANGUAGES= HB_TAG ('s','l','n','g'), _HB_OT_META_MAX_VALUE = HB_TAG_MAX_SIGNED /*< skip >*/ -} hb_ot_meta_t; +} hb_ot_meta_tag_t; HB_EXTERN unsigned int -hb_ot_meta_get_entries (hb_face_t *face, - unsigned int start_offset, - unsigned int *entries_count, /* IN/OUT. May be NULL. */ - hb_ot_meta_t *entries /* OUT. May be NULL. */); +hb_ot_meta_get_entries (hb_face_t *face, + unsigned int start_offset, + unsigned int *entries_count, /* IN/OUT. May be NULL. */ + hb_ot_meta_tag_t *entries /* OUT. May be NULL. */); HB_EXTERN hb_blob_t * -hb_ot_meta_reference_entry (hb_face_t *face, hb_ot_meta_t meta_tag); +hb_ot_meta_reference_entry (hb_face_t *face, hb_ot_meta_tag_t meta_tag); HB_END_DECLS diff --git a/src/test-ot-meta.cc b/src/test-ot-meta.cc index 33b1ee94e..512df5a78 100644 --- a/src/test-ot-meta.cc +++ b/src/test-ot-meta.cc @@ -50,8 +50,8 @@ main (int argc, char **argv) #ifndef HB_NO_META count = hb_ot_meta_get_entries (face, 0, nullptr, nullptr); - hb_ot_meta_t *tags = (hb_ot_meta_t *) - malloc (sizeof (hb_ot_meta_t) * count); + hb_ot_meta_tag_t *tags = (hb_ot_meta_tag_t *) + malloc (sizeof (hb_ot_meta_tag_t) * count); hb_ot_meta_get_entries (face, 0, &count, tags); for (unsigned i = 0; i < count; ++i) { diff --git a/test/api/test-ot-meta.c b/test/api/test-ot-meta.c index a08e67dc5..b8be5a30d 100644 --- a/test/api/test-ot-meta.c +++ b/test/api/test-ot-meta.c @@ -32,7 +32,7 @@ static void test_ot_meta_get_entries (void) { hb_face_t *face = hb_test_open_font_file ("fonts/meta.ttf"); - hb_ot_meta_t entries[2]; + hb_ot_meta_tag_t entries[2]; unsigned int entries_count = 2; g_assert_cmpint (hb_ot_meta_get_entries (face, 0, &entries_count, entries), ==, 5); @@ -61,10 +61,10 @@ test_ot_meta_reference_entry (void) g_assert_cmpint (hb_blob_get_length (dlng), ==, 8); g_assert_cmpmem (hb_blob_get_data (dlng, NULL), 8, "ar,de,fa", 8); hb_blob_destroy (dlng); - hb_blob_t *fslf = hb_ot_meta_reference_entry (face, (hb_ot_meta_t) HB_TAG ('f','s','l','f')); + hb_blob_t *fslf = hb_ot_meta_reference_entry (face, (hb_ot_meta_tag_t) HB_TAG ('f','s','l','f')); g_assert_cmpint (hb_blob_get_length (fslf), ==, 12); hb_blob_destroy (fslf); - hb_blob_t *nacl = hb_ot_meta_reference_entry (face, (hb_ot_meta_t) HB_TAG ('n','a','c','l')); + hb_blob_t *nacl = hb_ot_meta_reference_entry (face, (hb_ot_meta_tag_t) HB_TAG ('n','a','c','l')); g_assert_cmpint (hb_blob_get_length (nacl), ==, 0); hb_blob_destroy (nacl); hb_blob_t *slng = hb_ot_meta_reference_entry (face, HB_OT_META_SUPPORTED_LANGUAGES); From 4e1da6bb612b0c6386ab143dbb4ca19ff25bc2ba Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Mon, 29 Jul 2019 22:03:56 +0430 Subject: [PATCH 30/30] [metrics] Rename hb_ot_metrics_t to hb_ot_metrics_tag_t --- src/hb-ot-metrics.cc | 22 +++++++++++----------- src/hb-ot-metrics.h | 16 ++++++++-------- src/hb-ot-metrics.hh | 6 +++--- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/hb-ot-metrics.cc b/src/hb-ot-metrics.cc index 07eb4667a..d211d7e68 100644 --- a/src/hb-ot-metrics.cc +++ b/src/hb-ot-metrics.cc @@ -34,7 +34,7 @@ static float -_fix_ascender_descender (float value, hb_ot_metrics_t metrics_tag) +_fix_ascender_descender (float value, hb_ot_metrics_tag_t metrics_tag) { if (metrics_tag == HB_OT_METRICS_HORIZONTAL_ASCENDER || metrics_tag == HB_OT_METRICS_VERTICAL_ASCENDER) @@ -48,9 +48,9 @@ _fix_ascender_descender (float value, hb_ot_metrics_t metrics_tag) /* The common part of _get_position logic needed on hb-ot-font and here to be able to have slim builds without the not always needed parts */ bool -_hb_ot_metrics_get_position_common (hb_font_t *font, - hb_ot_metrics_t metrics_tag, - hb_position_t *position /* OUT. May be NULL. */) +_hb_ot_metrics_get_position_common (hb_font_t *font, + hb_ot_metrics_tag_t metrics_tag, + hb_position_t *position /* OUT. May be NULL. */) { hb_face_t *face = font->face; switch ((unsigned) metrics_tag) @@ -91,7 +91,7 @@ _hb_ot_metrics_get_position_common (hb_font_t *font, #if 0 static bool -_get_gasp (hb_face_t *face, float *result, hb_ot_metrics_t metrics_tag) +_get_gasp (hb_face_t *face, float *result, hb_ot_metrics_tag_t metrics_tag) { const OT::GaspRange& range = face->table.gasp->get_gasp_range (metrics_tag - HB_TAG ('g','s','p','0')); if (&range == &Null (OT::GaspRange)) return false; @@ -120,9 +120,9 @@ _get_gasp (hb_face_t *face, float *result, hb_ot_metrics_t metrics_tag) * Since: REPLACEME **/ hb_bool_t -hb_ot_metrics_get_position (hb_font_t *font, - hb_ot_metrics_t metrics_tag, - hb_position_t *position /* OUT. May be NULL. */) +hb_ot_metrics_get_position (hb_font_t *font, + hb_ot_metrics_tag_t metrics_tag, + hb_position_t *position /* OUT. May be NULL. */) { hb_face_t *face = font->face; switch ((unsigned) metrics_tag) @@ -192,7 +192,7 @@ hb_ot_metrics_get_position (hb_font_t *font, * Since: REPLACEME **/ float -hb_ot_metrics_get_variation (hb_font_t *font, hb_ot_metrics_t metrics_tag) +hb_ot_metrics_get_variation (hb_font_t *font, hb_ot_metrics_tag_t metrics_tag) { return font->face->table.MVAR->get_var (metrics_tag, font->coords, font->num_coords); } @@ -207,7 +207,7 @@ hb_ot_metrics_get_variation (hb_font_t *font, hb_ot_metrics_t metrics_tag) * Since: REPLACEME **/ hb_position_t -hb_ot_metrics_get_x_variation (hb_font_t *font, hb_ot_metrics_t metrics_tag) +hb_ot_metrics_get_x_variation (hb_font_t *font, hb_ot_metrics_tag_t metrics_tag) { return font->em_scalef_x (hb_ot_metrics_get_variation (font, metrics_tag)); } @@ -222,7 +222,7 @@ hb_ot_metrics_get_x_variation (hb_font_t *font, hb_ot_metrics_t metrics_tag) * Since: REPLACEME **/ hb_position_t -hb_ot_metrics_get_y_variation (hb_font_t *font, hb_ot_metrics_t metrics_tag) +hb_ot_metrics_get_y_variation (hb_font_t *font, hb_ot_metrics_tag_t metrics_tag) { return font->em_scalef_y (hb_ot_metrics_get_variation (font, metrics_tag)); } diff --git a/src/hb-ot-metrics.h b/src/hb-ot-metrics.h index c60ee739c..6b2747b96 100644 --- a/src/hb-ot-metrics.h +++ b/src/hb-ot-metrics.h @@ -36,7 +36,7 @@ HB_BEGIN_DECLS /** - * hb_ot_metrics_t: + * hb_ot_metrics_tag_t: * * From https://docs.microsoft.com/en-us/typography/opentype/spec/mvar#value-tags * @@ -73,21 +73,21 @@ typedef enum { HB_OT_METRICS_UNDERLINE_OFFSET = HB_TAG ('u','n','d','o'), _HB_OT_METRICS_MAX_VALUE = HB_TAG_MAX_SIGNED /*< skip >*/ -} hb_ot_metrics_t; +} hb_ot_metrics_tag_t; HB_EXTERN hb_bool_t -hb_ot_metrics_get_position (hb_font_t *font, - hb_ot_metrics_t metrics_tag, - hb_position_t *position /* OUT. May be NULL. */); +hb_ot_metrics_get_position (hb_font_t *font, + hb_ot_metrics_tag_t metrics_tag, + hb_position_t *position /* OUT. May be NULL. */); HB_EXTERN float -hb_ot_metrics_get_variation (hb_font_t *font, hb_ot_metrics_t metrics_tag); +hb_ot_metrics_get_variation (hb_font_t *font, hb_ot_metrics_tag_t metrics_tag); HB_EXTERN hb_position_t -hb_ot_metrics_get_x_variation (hb_font_t *font, hb_ot_metrics_t metrics_tag); +hb_ot_metrics_get_x_variation (hb_font_t *font, hb_ot_metrics_tag_t metrics_tag); HB_EXTERN hb_position_t -hb_ot_metrics_get_y_variation (hb_font_t *font, hb_ot_metrics_t metrics_tag); +hb_ot_metrics_get_y_variation (hb_font_t *font, hb_ot_metrics_tag_t metrics_tag); HB_END_DECLS diff --git a/src/hb-ot-metrics.hh b/src/hb-ot-metrics.hh index f9ae46fc9..19a5e9ed4 100644 --- a/src/hb-ot-metrics.hh +++ b/src/hb-ot-metrics.hh @@ -28,8 +28,8 @@ #include "hb.hh" HB_INTERNAL bool -_hb_ot_metrics_get_position_common (hb_font_t *font, - hb_ot_metrics_t metrics_tag, - hb_position_t *position /* OUT. May be NULL. */); +_hb_ot_metrics_get_position_common (hb_font_t *font, + hb_ot_metrics_tag_t metrics_tag, + hb_position_t *position /* OUT. May be NULL. */); #endif /* HB_OT_METRICS_HH */