/src/harfbuzz/src/OT/Layout/Common/CoverageFormat2.hh
Line | Count | Source |
1 | | /* |
2 | | * Copyright © 2007,2008,2009 Red Hat, Inc. |
3 | | * Copyright © 2010,2012 Google, Inc. |
4 | | * |
5 | | * This is part of HarfBuzz, a text shaping library. |
6 | | * |
7 | | * Permission is hereby granted, without written agreement and without |
8 | | * license or royalty fees, to use, copy, modify, and distribute this |
9 | | * software and its documentation for any purpose, provided that the |
10 | | * above copyright notice and the following two paragraphs appear in |
11 | | * all copies of this software. |
12 | | * |
13 | | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
14 | | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
15 | | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
16 | | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
17 | | * DAMAGE. |
18 | | * |
19 | | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
20 | | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
21 | | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
22 | | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
23 | | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
24 | | * |
25 | | * Red Hat Author(s): Behdad Esfahbod |
26 | | * Google Author(s): Behdad Esfahbod, Garret Rieger |
27 | | */ |
28 | | |
29 | | #ifndef OT_LAYOUT_COMMON_COVERAGEFORMAT2_HH |
30 | | #define OT_LAYOUT_COMMON_COVERAGEFORMAT2_HH |
31 | | |
32 | | #include "RangeRecord.hh" |
33 | | |
34 | | namespace OT { |
35 | | namespace Layout { |
36 | | namespace Common { |
37 | | |
38 | | template <typename Types> |
39 | | struct CoverageFormat2_4 |
40 | | { |
41 | | friend struct Coverage; |
42 | | |
43 | | protected: |
44 | | HBUINT16 coverageFormat; /* Format identifier--format = 2 */ |
45 | | SortedArray16Of<RangeRecord<Types>> |
46 | | rangeRecord; /* Array of glyph ranges--ordered by |
47 | | * Start GlyphID. rangeCount entries |
48 | | * long */ |
49 | | public: |
50 | | DEFINE_SIZE_ARRAY (4, rangeRecord); |
51 | | |
52 | | private: |
53 | | |
54 | | bool sanitize (hb_sanitize_context_t *c) const |
55 | 3.66k | { |
56 | 3.66k | TRACE_SANITIZE (this); |
57 | 3.66k | return_trace (rangeRecord.sanitize (c)); |
58 | 3.66k | } |
59 | | |
60 | | unsigned int get_coverage (hb_codepoint_t glyph_id) const |
61 | 0 | { |
62 | 0 | const RangeRecord<Types> &range = rangeRecord.bsearch (glyph_id); |
63 | 0 | return likely (range.first <= range.last) |
64 | 0 | ? (unsigned int) range.value + (glyph_id - range.first) |
65 | 0 | : NOT_COVERED; |
66 | 0 | } |
67 | | |
68 | | unsigned get_population () const |
69 | 10 | { |
70 | 10 | typename Types::large_int ret = 0; |
71 | 10 | for (const auto &r : rangeRecord) |
72 | 10 | ret += r.get_population (); |
73 | 10 | return ret > UINT_MAX ? UINT_MAX : (unsigned) ret; |
74 | 10 | } |
75 | | |
76 | | template <typename Iterator, |
77 | | hb_requires (hb_is_sorted_source_of (Iterator, hb_codepoint_t))> |
78 | | bool serialize (hb_serialize_context_t *c, Iterator glyphs) |
79 | 0 | { |
80 | 0 | TRACE_SERIALIZE (this); |
81 | 0 | if (unlikely (!c->extend_min (this))) return_trace (false); |
82 | | |
83 | 0 | unsigned num_ranges = 0; |
84 | 0 | hb_codepoint_t last = (hb_codepoint_t) -2; |
85 | 0 | for (auto g: glyphs) |
86 | 0 | { |
87 | 0 | if (last + 1 != g) |
88 | 0 | num_ranges++; |
89 | 0 | last = g; |
90 | 0 | } |
91 | |
|
92 | 0 | if (unlikely (!rangeRecord.serialize (c, num_ranges))) return_trace (false); |
93 | 0 | if (!num_ranges) return_trace (true); |
94 | | |
95 | 0 | unsigned count = 0; |
96 | 0 | unsigned range = (unsigned) -1; |
97 | 0 | last = (hb_codepoint_t) -2; |
98 | 0 | unsigned unsorted = false; |
99 | 0 | for (auto g: glyphs) |
100 | 0 | { |
101 | 0 | if (last + 1 != g) |
102 | 0 | { |
103 | 0 | if (unlikely (last != (hb_codepoint_t) -2 && last + 1 > g)) |
104 | 0 | unsorted = true; |
105 | |
|
106 | 0 | range++; |
107 | 0 | rangeRecord.arrayZ[range].first = g; |
108 | 0 | rangeRecord.arrayZ[range].value = count; |
109 | 0 | } |
110 | 0 | rangeRecord.arrayZ[range].last = g; |
111 | 0 | last = g; |
112 | 0 | count++; |
113 | 0 | } |
114 | |
|
115 | 0 | if (unlikely (unsorted)) |
116 | 0 | rangeRecord.as_array ().qsort (RangeRecord<Types>::cmp_range); |
117 | |
|
118 | 0 | return_trace (true); |
119 | 0 | } Unexecuted instantiation: _ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI17hb_sorted_array_tIKjETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSA_18is_sorted_iteratorEvE4typeELPv0EEEbP22hb_serialize_context_tSA_ Unexecuted instantiation: hb-ot-face.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tI13hb_zip_iter_tIS6_IN23hb_bit_set_invertible_t6iter_tERK8hb_map_tL24hb_function_sortedness_t1ELPv0EE16hb_repeat_iter_tI10hb_array_tIKNS_7NumTypeILb1EtLj2EEEEEERK3$_6LSD_1ELSE_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrST_18is_sorted_iteratorEvE4typeELSE_0EEEbP22hb_serialize_context_tST_ Unexecuted instantiation: hb-ot-face.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tI13hb_zip_iter_tINS1_8Coverage6iter_tE15hb_range_iter_tIjjEERK8hb_set_tRK3$_6LPv0EEZNKS0_9GPOS_impl16SinglePosFormat26subsetEP19hb_subset_context_tEUlRK9hb_pair_tIjjEE_L24hb_function_sortedness_t1ELSK_0EESJ_LSV_1ELSK_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSZ_18is_sorted_iteratorEvE4typeELSK_0EEEbP22hb_serialize_context_tSZ_ Unexecuted instantiation: hb-ot-face.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tI13hb_zip_iter_tINS1_8Coverage6iter_tE10hb_array_tIKNS0_9GPOS_impl15EntryExitRecordEEERK8hb_set_tRK3$_6LPv0EEZNKSC_17CursivePosFormat16subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSE_EE_L24hb_function_sortedness_t1ELSN_0EESM_LSW_1ELSN_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS10_18is_sorted_iteratorEvE4typeELSN_0EEEbP22hb_serialize_context_tS10_ Unexecuted instantiation: hb-ot-face.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tI13hb_zip_iter_tINS1_8Coverage6iter_tE10hb_array_tIKNS0_9GPOS_impl10MarkRecordEEERK8hb_set_tRK3$_6LPv0EESM_L24hb_function_sortedness_t1ELSN_0EERK8hb_map_tLSP_1ELSN_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSW_18is_sorted_iteratorEvE4typeELSN_0EEEbP22hb_serialize_context_tSW_ Unexecuted instantiation: _ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI17hb_sorted_array_tIKNS_11HBGlyphID16EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSB_18is_sorted_iteratorEvE4typeELPv0EEEbP22hb_serialize_context_tSB_ Unexecuted instantiation: hb-ot-face.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tIS7_I13hb_zip_iter_tINS1_8Coverage6iter_tE10hb_array_tIKNS_11HBGlyphID16EEERK8hb_set_tRK3$_6LPv0EESI_RK3$_7LSM_0EEZNKS0_9GSUB_impl30ReverseChainSingleSubstFormat16subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSD_EE_L24hb_function_sortedness_t1ELSM_0EESL_LS10_1ELSM_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS14_18is_sorted_iteratorEvE4typeELSM_0EEEbP22hb_serialize_context_tS14_ Unexecuted instantiation: hb-ot-face.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tIS6_IN23hb_bit_set_invertible_t6iter_tEZNKS0_9GSUB_impl20SingleSubstFormat1_3IS3_E6subsetEP19hb_subset_context_tEUljE_L24hb_function_sortedness_t1ELPv0EERK8hb_set_tRK3$_7LSH_0EEZNKSC_6subsetESE_EUl9hb_pair_tIjjEE_LSG_1ELSH_0EERK3$_6LSG_1ELSH_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSZ_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSZ_ Unexecuted instantiation: hb-ot-face.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tIS7_I13hb_zip_iter_tINS1_8Coverage6iter_tE10hb_array_tIKNS_11HBGlyphID16EEERK8hb_set_tRK3$_6LPv0EESI_RK3$_7LSM_0EEZNKS0_9GSUB_impl20SingleSubstFormat2_4IS3_E6subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSD_EE_L24hb_function_sortedness_t1ELSM_0EESL_LS11_1ELSM_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS15_18is_sorted_iteratorEvE4typeELSM_0EEEbP22hb_serialize_context_tS15_ Unexecuted instantiation: _ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIN23hb_bit_set_invertible_t6iter_tERK8hb_map_tL24hb_function_sortedness_t1ELPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSG_18is_sorted_iteratorEvE4typeELSD_0EEEbP22hb_serialize_context_tSG_ Unexecuted instantiation: hb-aat-layout.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tI13hb_zip_iter_tIS6_IN23hb_bit_set_invertible_t6iter_tERK8hb_map_tL24hb_function_sortedness_t1ELPv0EE16hb_repeat_iter_tI10hb_array_tIKNS_7NumTypeILb1EtLj2EEEEEERK3$_6LSD_1ELSE_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrST_18is_sorted_iteratorEvE4typeELSE_0EEEbP22hb_serialize_context_tST_ Unexecuted instantiation: hb-aat-layout.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tI13hb_zip_iter_tINS1_8Coverage6iter_tE15hb_range_iter_tIjjEERK8hb_set_tRK3$_6LPv0EEZNKS0_9GPOS_impl16SinglePosFormat26subsetEP19hb_subset_context_tEUlRK9hb_pair_tIjjEE_L24hb_function_sortedness_t1ELSK_0EESJ_LSV_1ELSK_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSZ_18is_sorted_iteratorEvE4typeELSK_0EEEbP22hb_serialize_context_tSZ_ Unexecuted instantiation: hb-aat-layout.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tI13hb_zip_iter_tINS1_8Coverage6iter_tE10hb_array_tIKNS0_9GPOS_impl15EntryExitRecordEEERK8hb_set_tRK3$_6LPv0EEZNKSC_17CursivePosFormat16subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSE_EE_L24hb_function_sortedness_t1ELSN_0EESM_LSW_1ELSN_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS10_18is_sorted_iteratorEvE4typeELSN_0EEEbP22hb_serialize_context_tS10_ Unexecuted instantiation: hb-aat-layout.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tI13hb_zip_iter_tINS1_8Coverage6iter_tE10hb_array_tIKNS0_9GPOS_impl10MarkRecordEEERK8hb_set_tRK3$_6LPv0EESM_L24hb_function_sortedness_t1ELSN_0EERK8hb_map_tLSP_1ELSN_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSW_18is_sorted_iteratorEvE4typeELSN_0EEEbP22hb_serialize_context_tSW_ Unexecuted instantiation: hb-aat-layout.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tIS7_I13hb_zip_iter_tINS1_8Coverage6iter_tE10hb_array_tIKNS_11HBGlyphID16EEERK8hb_set_tRK3$_6LPv0EESI_RK3$_7LSM_0EEZNKS0_9GSUB_impl30ReverseChainSingleSubstFormat16subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSD_EE_L24hb_function_sortedness_t1ELSM_0EESL_LS10_1ELSM_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS14_18is_sorted_iteratorEvE4typeELSM_0EEEbP22hb_serialize_context_tS14_ Unexecuted instantiation: hb-aat-layout.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tIS6_IN23hb_bit_set_invertible_t6iter_tEZNKS0_9GSUB_impl20SingleSubstFormat1_3IS3_E6subsetEP19hb_subset_context_tEUljE_L24hb_function_sortedness_t1ELPv0EERK8hb_set_tRK3$_7LSH_0EEZNKSC_6subsetESE_EUl9hb_pair_tIjjEE_LSG_1ELSH_0EERK3$_6LSG_1ELSH_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSZ_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSZ_ Unexecuted instantiation: hb-aat-layout.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tIS7_I13hb_zip_iter_tINS1_8Coverage6iter_tE10hb_array_tIKNS_11HBGlyphID16EEERK8hb_set_tRK3$_6LPv0EESI_RK3$_7LSM_0EEZNKS0_9GSUB_impl20SingleSubstFormat2_4IS3_E6subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSD_EE_L24hb_function_sortedness_t1ELSM_0EESL_LS11_1ELSM_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS15_18is_sorted_iteratorEvE4typeELSM_0EEEbP22hb_serialize_context_tS15_ Unexecuted instantiation: hb-ot-layout.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tI13hb_zip_iter_tIS6_IN23hb_bit_set_invertible_t6iter_tERK8hb_map_tL24hb_function_sortedness_t1ELPv0EE16hb_repeat_iter_tI10hb_array_tIKNS_7NumTypeILb1EtLj2EEEEEERK3$_6LSD_1ELSE_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrST_18is_sorted_iteratorEvE4typeELSE_0EEEbP22hb_serialize_context_tST_ Unexecuted instantiation: hb-ot-layout.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tI13hb_zip_iter_tINS1_8Coverage6iter_tE15hb_range_iter_tIjjEERK8hb_set_tRK3$_6LPv0EEZNKS0_9GPOS_impl16SinglePosFormat26subsetEP19hb_subset_context_tEUlRK9hb_pair_tIjjEE_L24hb_function_sortedness_t1ELSK_0EESJ_LSV_1ELSK_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSZ_18is_sorted_iteratorEvE4typeELSK_0EEEbP22hb_serialize_context_tSZ_ Unexecuted instantiation: hb-ot-layout.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tI13hb_zip_iter_tINS1_8Coverage6iter_tE10hb_array_tIKNS0_9GPOS_impl15EntryExitRecordEEERK8hb_set_tRK3$_6LPv0EEZNKSC_17CursivePosFormat16subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSE_EE_L24hb_function_sortedness_t1ELSN_0EESM_LSW_1ELSN_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS10_18is_sorted_iteratorEvE4typeELSN_0EEEbP22hb_serialize_context_tS10_ Unexecuted instantiation: hb-ot-layout.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tI13hb_zip_iter_tINS1_8Coverage6iter_tE10hb_array_tIKNS0_9GPOS_impl10MarkRecordEEERK8hb_set_tRK3$_6LPv0EESM_L24hb_function_sortedness_t1ELSN_0EERK8hb_map_tLSP_1ELSN_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSW_18is_sorted_iteratorEvE4typeELSN_0EEEbP22hb_serialize_context_tSW_ Unexecuted instantiation: hb-ot-layout.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tIS7_I13hb_zip_iter_tINS1_8Coverage6iter_tE10hb_array_tIKNS_11HBGlyphID16EEERK8hb_set_tRK3$_6LPv0EESI_RK3$_7LSM_0EEZNKS0_9GSUB_impl30ReverseChainSingleSubstFormat16subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSD_EE_L24hb_function_sortedness_t1ELSM_0EESL_LS10_1ELSM_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS14_18is_sorted_iteratorEvE4typeELSM_0EEEbP22hb_serialize_context_tS14_ Unexecuted instantiation: hb-ot-layout.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tIS6_IN23hb_bit_set_invertible_t6iter_tEZNKS0_9GSUB_impl20SingleSubstFormat1_3IS3_E6subsetEP19hb_subset_context_tEUljE_L24hb_function_sortedness_t1ELPv0EERK8hb_set_tRK3$_7LSH_0EEZNKSC_6subsetESE_EUl9hb_pair_tIjjEE_LSG_1ELSH_0EERK3$_6LSG_1ELSH_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSZ_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSZ_ Unexecuted instantiation: hb-ot-layout.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tIS7_I13hb_zip_iter_tINS1_8Coverage6iter_tE10hb_array_tIKNS_11HBGlyphID16EEERK8hb_set_tRK3$_6LPv0EESI_RK3$_7LSM_0EEZNKS0_9GSUB_impl20SingleSubstFormat2_4IS3_E6subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSD_EE_L24hb_function_sortedness_t1ELSM_0EESL_LS11_1ELSM_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS15_18is_sorted_iteratorEvE4typeELSM_0EEEbP22hb_serialize_context_tS15_ Unexecuted instantiation: hb-ot-shaper-arabic.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tI13hb_zip_iter_tI17hb_sorted_array_tINS_11HBGlyphID16EE10hb_array_tIS9_EERK3$_6L24hb_function_sortedness_t1ELPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSL_18is_sorted_iteratorEvE4typeELSI_0EEEbP22hb_serialize_context_tSL_ Unexecuted instantiation: hb-ot-shaper-arabic.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tIS7_I13hb_zip_iter_tINS1_8Coverage6iter_tE10hb_array_tIKNS_11HBGlyphID16EEERK8hb_set_tRK3$_6LPv0EESI_RK3$_7LSM_0EEZNKS0_9GSUB_impl30ReverseChainSingleSubstFormat16subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSD_EE_L24hb_function_sortedness_t1ELSM_0EESL_LS10_1ELSM_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS14_18is_sorted_iteratorEvE4typeELSM_0EEEbP22hb_serialize_context_tS14_ Unexecuted instantiation: hb-ot-shaper-arabic.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tIS6_IN23hb_bit_set_invertible_t6iter_tEZNKS0_9GSUB_impl20SingleSubstFormat1_3IS3_E6subsetEP19hb_subset_context_tEUljE_L24hb_function_sortedness_t1ELPv0EERK8hb_set_tRK3$_7LSH_0EEZNKSC_6subsetESE_EUl9hb_pair_tIjjEE_LSG_1ELSH_0EERK3$_6LSG_1ELSH_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSZ_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSZ_ Unexecuted instantiation: hb-ot-shaper-arabic.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tIS7_I13hb_zip_iter_tINS1_8Coverage6iter_tE10hb_array_tIKNS_11HBGlyphID16EEERK8hb_set_tRK3$_6LPv0EESI_RK3$_7LSM_0EEZNKS0_9GSUB_impl20SingleSubstFormat2_4IS3_E6subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSD_EE_L24hb_function_sortedness_t1ELSM_0EESL_LS11_1ELSM_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS15_18is_sorted_iteratorEvE4typeELSM_0EEEbP22hb_serialize_context_tS15_ Unexecuted instantiation: hb-ot-shape-fallback.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tI13hb_zip_iter_tIS6_IN23hb_bit_set_invertible_t6iter_tERK8hb_map_tL24hb_function_sortedness_t1ELPv0EE16hb_repeat_iter_tI10hb_array_tIKNS_7NumTypeILb1EtLj2EEEEEERK3$_6LSD_1ELSE_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrST_18is_sorted_iteratorEvE4typeELSE_0EEEbP22hb_serialize_context_tST_ Unexecuted instantiation: hb-ot-shape-fallback.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tI13hb_zip_iter_tINS1_8Coverage6iter_tE15hb_range_iter_tIjjEERK8hb_set_tRK3$_6LPv0EEZNKS0_9GPOS_impl16SinglePosFormat26subsetEP19hb_subset_context_tEUlRK9hb_pair_tIjjEE_L24hb_function_sortedness_t1ELSK_0EESJ_LSV_1ELSK_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSZ_18is_sorted_iteratorEvE4typeELSK_0EEEbP22hb_serialize_context_tSZ_ Unexecuted instantiation: hb-ot-shape-fallback.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tI13hb_zip_iter_tINS1_8Coverage6iter_tE10hb_array_tIKNS0_9GPOS_impl15EntryExitRecordEEERK8hb_set_tRK3$_6LPv0EEZNKSC_17CursivePosFormat16subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSE_EE_L24hb_function_sortedness_t1ELSN_0EESM_LSW_1ELSN_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS10_18is_sorted_iteratorEvE4typeELSN_0EEEbP22hb_serialize_context_tS10_ Unexecuted instantiation: hb-ot-shape-fallback.cc:_ZN2OT6Layout6Common17CoverageFormat2_4INS0_10SmallTypesEE9serializeI13hb_map_iter_tIS6_I16hb_filter_iter_tI13hb_zip_iter_tINS1_8Coverage6iter_tE10hb_array_tIKNS0_9GPOS_impl10MarkRecordEEERK8hb_set_tRK3$_6LPv0EESM_L24hb_function_sortedness_t1ELSN_0EERK8hb_map_tLSP_1ELSN_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSW_18is_sorted_iteratorEvE4typeELSN_0EEEbP22hb_serialize_context_tSW_ |
120 | | |
121 | | bool intersects (const hb_set_t *glyphs) const |
122 | 0 | { |
123 | 0 | if (rangeRecord.len > glyphs->get_population () * hb_bit_storage ((unsigned) rangeRecord.len)) |
124 | 0 | { |
125 | 0 | for (auto g : *glyphs) |
126 | 0 | if (get_coverage (g) != NOT_COVERED) |
127 | 0 | return true; |
128 | 0 | return false; |
129 | 0 | } |
130 | | |
131 | 0 | return hb_any (+ hb_iter (rangeRecord) |
132 | 0 | | hb_map ([glyphs] (const RangeRecord<Types> &range) { return range.intersects (*glyphs); })); |
133 | 0 | } |
134 | | bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const |
135 | 0 | { |
136 | 0 | auto *range = rangeRecord.as_array ().bsearch (index); |
137 | 0 | if (range) |
138 | 0 | return range->intersects (*glyphs); |
139 | 0 | return false; |
140 | 0 | } |
141 | | |
142 | | template <typename IterableOut, |
143 | | hb_requires (hb_is_sink_of (IterableOut, hb_codepoint_t))> |
144 | | void intersect_set (const hb_set_t &glyphs, IterableOut&& intersect_glyphs) const |
145 | 0 | { |
146 | | /* Break out of loop for overlapping, broken, tables, |
147 | | * to avoid fuzzer timouts. */ |
148 | 0 | hb_codepoint_t last = 0; |
149 | 0 | for (const auto& range : rangeRecord) |
150 | 0 | { |
151 | 0 | if (unlikely (range.first < last)) |
152 | 0 | break; |
153 | 0 | last = range.last; |
154 | 0 | for (hb_codepoint_t g = range.first - 1; |
155 | 0 | glyphs.next (&g) && g <= last;) |
156 | 0 | intersect_glyphs << g; |
157 | 0 | } |
158 | 0 | } |
159 | | |
160 | 0 | unsigned cost () const { return hb_bit_storage ((unsigned) rangeRecord.len); /* bsearch cost */ } |
161 | | |
162 | | template <typename set_t> |
163 | | bool collect_coverage (set_t *glyphs) const |
164 | 47 | { |
165 | 47 | for (const auto& range: rangeRecord) |
166 | 186 | if (unlikely (!range.collect_coverage (glyphs))) |
167 | 0 | return false; |
168 | 47 | return true; |
169 | 47 | } Unexecuted instantiation: bool OT::Layout::Common::CoverageFormat2_4<OT::Layout::SmallTypes>::collect_coverage<hb_bit_set_t>(hb_bit_set_t*) const Unexecuted instantiation: bool OT::Layout::Common::CoverageFormat2_4<OT::Layout::SmallTypes>::collect_coverage<hb_set_t>(hb_set_t*) const bool OT::Layout::Common::CoverageFormat2_4<OT::Layout::SmallTypes>::collect_coverage<hb_set_digest_t>(hb_set_digest_t*) const Line | Count | Source | 164 | 47 | { | 165 | 47 | for (const auto& range: rangeRecord) | 166 | 186 | if (unlikely (!range.collect_coverage (glyphs))) | 167 | 0 | return false; | 168 | 47 | return true; | 169 | 47 | } |
|
170 | | |
171 | | public: |
172 | | /* Older compilers need this to be public. */ |
173 | | struct iter_t |
174 | | { |
175 | | void init (const CoverageFormat2_4 &c_) |
176 | 0 | { |
177 | 0 | c = &c_; |
178 | 0 | coverage = 0; |
179 | 0 | i = 0; |
180 | 0 | j = c->rangeRecord.len ? c->rangeRecord[0].first : 0; |
181 | 0 | if (unlikely (c->rangeRecord[0].first > c->rangeRecord[0].last)) |
182 | 0 | { |
183 | | /* Broken table. Skip. */ |
184 | 0 | i = c->rangeRecord.len; |
185 | 0 | j = 0; |
186 | 0 | } |
187 | 0 | } |
188 | 0 | bool __more__ () const { return i < c->rangeRecord.len; } |
189 | | void __next__ () |
190 | 0 | { |
191 | 0 | if (j >= c->rangeRecord[i].last) |
192 | 0 | { |
193 | 0 | i++; |
194 | 0 | if (__more__ ()) |
195 | 0 | { |
196 | 0 | unsigned int old = coverage; |
197 | 0 | j = c->rangeRecord.arrayZ[i].first; |
198 | 0 | coverage = c->rangeRecord.arrayZ[i].value; |
199 | 0 | if (unlikely (coverage != old + 1)) |
200 | 0 | { |
201 | | /* Broken table. Skip. Important to avoid DoS. |
202 | | * Also, our callers depend on coverage being |
203 | | * consecutive and monotonically increasing, |
204 | | * ie. iota(). */ |
205 | 0 | i = c->rangeRecord.len; |
206 | 0 | j = 0; |
207 | 0 | return; |
208 | 0 | } |
209 | 0 | } |
210 | 0 | else |
211 | 0 | j = 0; |
212 | 0 | return; |
213 | 0 | } |
214 | 0 | coverage++; |
215 | 0 | j++; |
216 | 0 | } |
217 | 0 | hb_codepoint_t get_glyph () const { return j; } |
218 | | bool operator != (const iter_t& o) const |
219 | 0 | { return i != o.i || j != o.j; } |
220 | | iter_t __end__ () const |
221 | 0 | { |
222 | 0 | iter_t it; |
223 | 0 | it.init (*c); |
224 | 0 | it.i = c->rangeRecord.len; |
225 | 0 | it.j = 0; |
226 | 0 | return it; |
227 | 0 | } |
228 | | |
229 | | private: |
230 | | const struct CoverageFormat2_4 *c; |
231 | | unsigned int i, coverage; |
232 | | hb_codepoint_t j; |
233 | | }; |
234 | | private: |
235 | | }; |
236 | | |
237 | | } |
238 | | } |
239 | | } |
240 | | |
241 | | #endif // #ifndef OT_LAYOUT_COMMON_COVERAGEFORMAT2_HH |