/work/workdir/UnpackedTarball/harfbuzz/src/hb-subset-plan.hh
Line | Count | Source |
1 | | /* |
2 | | * Copyright © 2018 Google, Inc. |
3 | | * |
4 | | * This is part of HarfBuzz, a text shaping library. |
5 | | * |
6 | | * Permission is hereby granted, without written agreement and without |
7 | | * license or royalty fees, to use, copy, modify, and distribute this |
8 | | * software and its documentation for any purpose, provided that the |
9 | | * above copyright notice and the following two paragraphs appear in |
10 | | * all copies of this software. |
11 | | * |
12 | | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
13 | | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
14 | | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
15 | | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
16 | | * DAMAGE. |
17 | | * |
18 | | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
19 | | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
20 | | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
21 | | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
22 | | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
23 | | * |
24 | | * Google Author(s): Garret Rieger, Roderick Sheeter |
25 | | */ |
26 | | |
27 | | #ifndef HB_SUBSET_PLAN_HH |
28 | | #define HB_SUBSET_PLAN_HH |
29 | | |
30 | | #include "hb.hh" |
31 | | |
32 | | #include "hb-subset.h" |
33 | | #include "hb-subset-input.hh" |
34 | | #include "hb-subset-accelerator.hh" |
35 | | |
36 | | #include "hb-map.hh" |
37 | | #include "hb-bimap.hh" |
38 | | #include "hb-set.hh" |
39 | | |
40 | | namespace OT { |
41 | | struct Feature; |
42 | | } |
43 | | |
44 | | struct os2_info_t { |
45 | | hb_codepoint_t min_cmap_codepoint; |
46 | | hb_codepoint_t max_cmap_codepoint; |
47 | | }; |
48 | | |
49 | | typedef struct os2_info_t os2_info_t; |
50 | | |
51 | | struct head_maxp_info_t |
52 | | { |
53 | | head_maxp_info_t () |
54 | 16.3k | :xMin (0x7FFF), xMax (-0x7FFF), yMin (0x7FFF), yMax (-0x7FFF), |
55 | 16.3k | maxPoints (0), maxContours (0), |
56 | 16.3k | maxCompositePoints (0), |
57 | 16.3k | maxCompositeContours (0), |
58 | 16.3k | maxComponentElements (0), |
59 | 16.3k | maxComponentDepth (0), |
60 | 16.3k | allXMinIsLsb (true) {} |
61 | | |
62 | | int xMin; |
63 | | int xMax; |
64 | | int yMin; |
65 | | int yMax; |
66 | | unsigned maxPoints; |
67 | | unsigned maxContours; |
68 | | unsigned maxCompositePoints; |
69 | | unsigned maxCompositeContours; |
70 | | unsigned maxComponentElements; |
71 | | unsigned maxComponentDepth; |
72 | | bool allXMinIsLsb; |
73 | | }; |
74 | | |
75 | | typedef struct head_maxp_info_t head_maxp_info_t; |
76 | | |
77 | | struct contour_point_t |
78 | | { |
79 | | void init (float x_ = 0.f, float y_ = 0.f, bool is_end_point_ = false) |
80 | 6.97k | { flag = 0; x = x_; y = y_; is_end_point = is_end_point_; } |
81 | | |
82 | | void transform (const float (&matrix)[4]) |
83 | 0 | { |
84 | 0 | float x_ = x * matrix[0] + y * matrix[2]; |
85 | 0 | y = x * matrix[1] + y * matrix[3]; |
86 | 0 | x = x_; |
87 | 0 | } |
88 | | |
89 | | void add_delta (float delta_x, float delta_y) |
90 | 0 | { |
91 | 0 | x += delta_x; |
92 | 0 | y += delta_y; |
93 | 0 | } |
94 | | |
95 | | HB_ALWAYS_INLINE |
96 | 7.07k | void translate (const contour_point_t &p) { x += p.x; y += p.y; } |
97 | | |
98 | | float x; |
99 | | float y; |
100 | | uint8_t flag; |
101 | | bool is_end_point; |
102 | | }; |
103 | | |
104 | | struct contour_point_vector_t : hb_vector_t<contour_point_t> |
105 | | { |
106 | | bool add_deltas (hb_array_t<const float> deltas_x, |
107 | | hb_array_t<const float> deltas_y, |
108 | | hb_array_t<const bool> indices) |
109 | 0 | { |
110 | 0 | if (indices.length != deltas_x.length || |
111 | 0 | indices.length != deltas_y.length) |
112 | 0 | return false; |
113 | | |
114 | 0 | for (unsigned i = 0; i < indices.length; i++) |
115 | 0 | { |
116 | 0 | if (!indices.arrayZ[i]) continue; |
117 | 0 | arrayZ[i].add_delta (deltas_x.arrayZ[i], deltas_y.arrayZ[i]); |
118 | 0 | } |
119 | 0 | return true; |
120 | 0 | } |
121 | | }; |
122 | | |
123 | | namespace OT { |
124 | | struct cff1_subset_accelerator_t; |
125 | | struct cff2_subset_accelerator_t; |
126 | | } |
127 | | |
128 | | struct hb_subset_plan_t |
129 | | { |
130 | | HB_INTERNAL hb_subset_plan_t (hb_face_t *, |
131 | | const hb_subset_input_t *input); |
132 | | |
133 | | HB_INTERNAL ~hb_subset_plan_t(); |
134 | | |
135 | | hb_object_header_t header; |
136 | | |
137 | | bool successful; |
138 | | unsigned flags; |
139 | | bool attach_accelerator_data = false; |
140 | | bool force_long_loca = false; |
141 | | |
142 | | // The glyph subset |
143 | | hb_map_t *codepoint_to_glyph; // Needs to be heap-allocated |
144 | | |
145 | | // Old -> New glyph id mapping |
146 | | hb_map_t *glyph_map; // Needs to be heap-allocated |
147 | | hb_map_t *reverse_glyph_map; // Needs to be heap-allocated |
148 | | |
149 | | // Plan is only good for a specific source/dest so keep them with it |
150 | | hb_face_t *source; |
151 | | #ifndef HB_NO_SUBSET_CFF |
152 | | // These have to be immediately after source: |
153 | | hb_face_lazy_loader_t<OT::cff1_subset_accelerator_t, 1> cff1_accel; |
154 | | hb_face_lazy_loader_t<OT::cff2_subset_accelerator_t, 2> cff2_accel; |
155 | | #endif |
156 | | |
157 | | hb_face_t *dest; |
158 | | |
159 | | unsigned int _num_output_glyphs; |
160 | | |
161 | | bool all_axes_pinned; |
162 | | bool pinned_at_default; |
163 | | bool has_seac; |
164 | | |
165 | | // whether to insert a catch-all FeatureVariationRecord |
166 | | bool gsub_insert_catch_all_feature_variation_rec; |
167 | | bool gpos_insert_catch_all_feature_variation_rec; |
168 | | |
169 | | // whether GDEF ItemVariationStore is retained |
170 | | mutable bool has_gdef_varstore; |
171 | | |
172 | | // whether we're doing avar2 partial instancing |
173 | | bool has_avar2; |
174 | | |
175 | | #define HB_SUBSET_PLAN_MEMBER(Type, Name) Type Name; |
176 | | #include "hb-subset-plan-member-list.hh" |
177 | | #undef HB_SUBSET_PLAN_MEMBER |
178 | | |
179 | | //recalculated head/maxp table info after instancing |
180 | | mutable head_maxp_info_t head_maxp_info; |
181 | | |
182 | | os2_info_t os2_info; |
183 | | |
184 | | const hb_subset_accelerator_t* accelerator = nullptr; |
185 | | hb_subset_accelerator_t* inprogress_accelerator = nullptr; |
186 | | |
187 | | public: |
188 | | |
189 | | template<typename T> |
190 | | struct source_table_loader |
191 | | { |
192 | | hb_blob_ptr_t<T> operator () (hb_subset_plan_t *plan) |
193 | 97.8k | { |
194 | 97.8k | hb_lock_t lock (plan->accelerator ? &plan->accelerator->sanitized_table_cache_lock : nullptr); |
195 | | |
196 | 97.8k | auto *cache = plan->accelerator ? &plan->accelerator->sanitized_table_cache : &plan->sanitized_table_cache; |
197 | 97.8k | if (cache |
198 | 97.8k | && !cache->in_error () |
199 | 97.8k | && cache->has (+T::tableTag)) { |
200 | 0 | return hb_blob_reference (cache->get (+T::tableTag).get ()); |
201 | 0 | } |
202 | | |
203 | 97.8k | hb::unique_ptr<hb_blob_t> table_blob {hb_sanitize_context_t ().reference_table<T> (plan->source)}; |
204 | 97.8k | hb_blob_t* ret = hb_blob_reference (table_blob.get ()); |
205 | | |
206 | 97.8k | if (likely (cache)) |
207 | 97.8k | cache->set (+T::tableTag, std::move (table_blob)); |
208 | | |
209 | 97.8k | return ret; |
210 | 97.8k | } Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::head const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::STAT const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::MATH>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::GDEF>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::Layout::GPOS>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::Layout::GSUB>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::BASE>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::GDEF const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::Layout::GSUB const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::Layout::GPOS const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::BASE const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::MATH const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::HVAR const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::VVAR const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::gvar const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::VARC const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::fvar const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::avar const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::cvar const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::MVAR const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::VORG const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::sbix const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::COLR const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::CPAL const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::CBLC const>::operator()(hb_subset_plan_t*) hb_subset_plan_t::source_table_loader<OT::glyf const>::operator()(hb_subset_plan_t*) Line | Count | Source | 193 | 16.3k | { | 194 | 16.3k | hb_lock_t lock (plan->accelerator ? &plan->accelerator->sanitized_table_cache_lock : nullptr); | 195 | | | 196 | 16.3k | auto *cache = plan->accelerator ? &plan->accelerator->sanitized_table_cache : &plan->sanitized_table_cache; | 197 | 16.3k | if (cache | 198 | 16.3k | && !cache->in_error () | 199 | 16.3k | && cache->has (+T::tableTag)) { | 200 | 0 | return hb_blob_reference (cache->get (+T::tableTag).get ()); | 201 | 0 | } | 202 | | | 203 | 16.3k | hb::unique_ptr<hb_blob_t> table_blob {hb_sanitize_context_t ().reference_table<T> (plan->source)}; | 204 | 16.3k | hb_blob_t* ret = hb_blob_reference (table_blob.get ()); | 205 | | | 206 | 16.3k | if (likely (cache)) | 207 | 16.3k | cache->set (+T::tableTag, std::move (table_blob)); | 208 | | | 209 | 16.3k | return ret; | 210 | 16.3k | } |
Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::hdmx const>::operator()(hb_subset_plan_t*) hb_subset_plan_t::source_table_loader<OT::name const>::operator()(hb_subset_plan_t*) Line | Count | Source | 193 | 16.3k | { | 194 | 16.3k | hb_lock_t lock (plan->accelerator ? &plan->accelerator->sanitized_table_cache_lock : nullptr); | 195 | | | 196 | 16.3k | auto *cache = plan->accelerator ? &plan->accelerator->sanitized_table_cache : &plan->sanitized_table_cache; | 197 | 16.3k | if (cache | 198 | 16.3k | && !cache->in_error () | 199 | 16.3k | && cache->has (+T::tableTag)) { | 200 | 0 | return hb_blob_reference (cache->get (+T::tableTag).get ()); | 201 | 0 | } | 202 | | | 203 | 16.3k | hb::unique_ptr<hb_blob_t> table_blob {hb_sanitize_context_t ().reference_table<T> (plan->source)}; | 204 | 16.3k | hb_blob_t* ret = hb_blob_reference (table_blob.get ()); | 205 | | | 206 | 16.3k | if (likely (cache)) | 207 | 16.3k | cache->set (+T::tableTag, std::move (table_blob)); | 208 | | | 209 | 16.3k | return ret; | 210 | 16.3k | } |
hb_subset_plan_t::source_table_loader<OT::hmtx const>::operator()(hb_subset_plan_t*) Line | Count | Source | 193 | 16.3k | { | 194 | 16.3k | hb_lock_t lock (plan->accelerator ? &plan->accelerator->sanitized_table_cache_lock : nullptr); | 195 | | | 196 | 16.3k | auto *cache = plan->accelerator ? &plan->accelerator->sanitized_table_cache : &plan->sanitized_table_cache; | 197 | 16.3k | if (cache | 198 | 16.3k | && !cache->in_error () | 199 | 16.3k | && cache->has (+T::tableTag)) { | 200 | 0 | return hb_blob_reference (cache->get (+T::tableTag).get ()); | 201 | 0 | } | 202 | | | 203 | 16.3k | hb::unique_ptr<hb_blob_t> table_blob {hb_sanitize_context_t ().reference_table<T> (plan->source)}; | 204 | 16.3k | hb_blob_t* ret = hb_blob_reference (table_blob.get ()); | 205 | | | 206 | 16.3k | if (likely (cache)) | 207 | 16.3k | cache->set (+T::tableTag, std::move (table_blob)); | 208 | | | 209 | 16.3k | return ret; | 210 | 16.3k | } |
Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::vmtx const>::operator()(hb_subset_plan_t*) hb_subset_plan_t::source_table_loader<OT::maxp const>::operator()(hb_subset_plan_t*) Line | Count | Source | 193 | 16.3k | { | 194 | 16.3k | hb_lock_t lock (plan->accelerator ? &plan->accelerator->sanitized_table_cache_lock : nullptr); | 195 | | | 196 | 16.3k | auto *cache = plan->accelerator ? &plan->accelerator->sanitized_table_cache : &plan->sanitized_table_cache; | 197 | 16.3k | if (cache | 198 | 16.3k | && !cache->in_error () | 199 | 16.3k | && cache->has (+T::tableTag)) { | 200 | 0 | return hb_blob_reference (cache->get (+T::tableTag).get ()); | 201 | 0 | } | 202 | | | 203 | 16.3k | hb::unique_ptr<hb_blob_t> table_blob {hb_sanitize_context_t ().reference_table<T> (plan->source)}; | 204 | 16.3k | hb_blob_t* ret = hb_blob_reference (table_blob.get ()); | 205 | | | 206 | 16.3k | if (likely (cache)) | 207 | 16.3k | cache->set (+T::tableTag, std::move (table_blob)); | 208 | | | 209 | 16.3k | return ret; | 210 | 16.3k | } |
Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::cmap const>::operator()(hb_subset_plan_t*) Unexecuted instantiation: hb_subset_plan_t::source_table_loader<OT::DMAP const>::operator()(hb_subset_plan_t*) hb_subset_plan_t::source_table_loader<OT::OS2 const>::operator()(hb_subset_plan_t*) Line | Count | Source | 193 | 16.3k | { | 194 | 16.3k | hb_lock_t lock (plan->accelerator ? &plan->accelerator->sanitized_table_cache_lock : nullptr); | 195 | | | 196 | 16.3k | auto *cache = plan->accelerator ? &plan->accelerator->sanitized_table_cache : &plan->sanitized_table_cache; | 197 | 16.3k | if (cache | 198 | 16.3k | && !cache->in_error () | 199 | 16.3k | && cache->has (+T::tableTag)) { | 200 | 0 | return hb_blob_reference (cache->get (+T::tableTag).get ()); | 201 | 0 | } | 202 | | | 203 | 16.3k | hb::unique_ptr<hb_blob_t> table_blob {hb_sanitize_context_t ().reference_table<T> (plan->source)}; | 204 | 16.3k | hb_blob_t* ret = hb_blob_reference (table_blob.get ()); | 205 | | | 206 | 16.3k | if (likely (cache)) | 207 | 16.3k | cache->set (+T::tableTag, std::move (table_blob)); | 208 | | | 209 | 16.3k | return ret; | 210 | 16.3k | } |
hb_subset_plan_t::source_table_loader<OT::post const>::operator()(hb_subset_plan_t*) Line | Count | Source | 193 | 16.3k | { | 194 | 16.3k | hb_lock_t lock (plan->accelerator ? &plan->accelerator->sanitized_table_cache_lock : nullptr); | 195 | | | 196 | 16.3k | auto *cache = plan->accelerator ? &plan->accelerator->sanitized_table_cache : &plan->sanitized_table_cache; | 197 | 16.3k | if (cache | 198 | 16.3k | && !cache->in_error () | 199 | 16.3k | && cache->has (+T::tableTag)) { | 200 | 0 | return hb_blob_reference (cache->get (+T::tableTag).get ()); | 201 | 0 | } | 202 | | | 203 | 16.3k | hb::unique_ptr<hb_blob_t> table_blob {hb_sanitize_context_t ().reference_table<T> (plan->source)}; | 204 | 16.3k | hb_blob_t* ret = hb_blob_reference (table_blob.get ()); | 205 | | | 206 | 16.3k | if (likely (cache)) | 207 | 16.3k | cache->set (+T::tableTag, std::move (table_blob)); | 208 | | | 209 | 16.3k | return ret; | 210 | 16.3k | } |
|
211 | | }; |
212 | | |
213 | | template<typename T> |
214 | | auto source_table() HB_AUTO_RETURN (source_table_loader<T> {} (this)) |
215 | | |
216 | 81.5k | bool in_error () const { return !successful; } |
217 | | |
218 | | HB_INTERNAL float layout_variation_delta (unsigned var_idx); |
219 | | |
220 | | bool check_success(bool success) |
221 | 1.09M | { |
222 | 1.09M | successful = (successful && success); |
223 | 1.09M | return successful; |
224 | 1.09M | } |
225 | | |
226 | | /* |
227 | | * The set of input glyph ids which will be retained in the subset. |
228 | | * Does NOT include ids kept due to retain_gids. You probably want to use |
229 | | * glyph_map/reverse_glyph_map. |
230 | | */ |
231 | | inline const hb_set_t * |
232 | | glyphset () const |
233 | 97.8k | { |
234 | 97.8k | return &_glyphset; |
235 | 97.8k | } |
236 | | |
237 | | /* |
238 | | * The set of input glyph ids which will be retained in the subset. |
239 | | */ |
240 | | inline const hb_set_t * |
241 | | glyphset_gsub () const |
242 | 0 | { |
243 | 0 | return &_glyphset_gsub; |
244 | 0 | } |
245 | | |
246 | | /* |
247 | | * Old-to-new glyph id mapping for GSUB glyphs, through the flat |
248 | | * array; returns HB_MAP_VALUE_INVALID for glyphs not retained. |
249 | | */ |
250 | | inline hb_codepoint_t |
251 | | map_gsub_glyph (hb_codepoint_t old_gid) const |
252 | 0 | { |
253 | 0 | return old_gid < glyph_map_gsub_flat.length |
254 | 0 | ? glyph_map_gsub_flat.arrayZ[old_gid] |
255 | 0 | : HB_MAP_VALUE_INVALID; |
256 | 0 | } |
257 | | |
258 | | /* |
259 | | * The total number of output glyphs in the final subset. |
260 | | */ |
261 | | inline unsigned int |
262 | | num_output_glyphs () const |
263 | 65.2k | { |
264 | 65.2k | return _num_output_glyphs; |
265 | 65.2k | } |
266 | | |
267 | | inline bool new_gid_for_codepoint (hb_codepoint_t codepoint, |
268 | | hb_codepoint_t *new_gid) const |
269 | 0 | { |
270 | 0 | hb_codepoint_t old_gid = codepoint_to_glyph->get (codepoint); |
271 | 0 | if (old_gid == HB_MAP_VALUE_INVALID) |
272 | 0 | return false; |
273 | 0 |
|
274 | 0 | return new_gid_for_old_gid (old_gid, new_gid); |
275 | 0 | } |
276 | | |
277 | | inline bool new_gid_for_old_gid (hb_codepoint_t old_gid, |
278 | | hb_codepoint_t *new_gid) const |
279 | 71.3k | { |
280 | 71.3k | hb_codepoint_t gid = glyph_map->get (old_gid); |
281 | 71.3k | if (gid == HB_MAP_VALUE_INVALID) |
282 | 0 | return false; |
283 | | |
284 | 71.3k | *new_gid = gid; |
285 | 71.3k | return true; |
286 | 71.3k | } |
287 | | |
288 | | inline bool old_gid_for_new_gid (hb_codepoint_t new_gid, |
289 | | hb_codepoint_t *old_gid) const |
290 | 37.0k | { |
291 | 37.0k | hb_codepoint_t gid = reverse_glyph_map->get (new_gid); |
292 | 37.0k | if (gid == HB_MAP_VALUE_INVALID) |
293 | 92 | return false; |
294 | | |
295 | 36.9k | *old_gid = gid; |
296 | 36.9k | return true; |
297 | 37.0k | } |
298 | | |
299 | | inline bool |
300 | | add_table (hb_tag_t tag, |
301 | | hb_blob_t *contents) |
302 | 195k | { |
303 | 195k | if (HB_DEBUG_SUBSET) |
304 | 0 | { |
305 | 0 | hb_blob_t *source_blob = source->reference_table (tag); |
306 | 0 | DEBUG_MSG(SUBSET, nullptr, "add table %c%c%c%c, dest %u bytes, source %u bytes", |
307 | 0 | HB_UNTAG(tag), |
308 | 0 | hb_blob_get_length (contents), |
309 | 0 | hb_blob_get_length (source_blob)); |
310 | 0 | hb_blob_destroy (source_blob); |
311 | 0 | } |
312 | 195k | return hb_face_builder_add_table (dest, tag, contents); |
313 | 195k | } |
314 | | }; |
315 | | |
316 | | // hb-subset-plan implementation is split into multiple files to keep |
317 | | // compile times more reasonable: |
318 | | // - hb-subset-plan.cc |
319 | | // - hb-subset-plan-layout.cc |
320 | | // - hb-subset-plan-var.cc |
321 | | // |
322 | | // The functions below are those needed to connect the split files |
323 | | // above together. |
324 | | HB_INTERNAL void |
325 | | remap_indexes (const hb_set_t *indexes, |
326 | | hb_map_t *mapping /* OUT */); |
327 | | |
328 | | |
329 | | #ifndef HB_NO_VAR |
330 | | template<typename ItemVarStore> |
331 | | HB_INTERNAL void |
332 | | remap_variation_indices (const ItemVarStore &var_store, |
333 | | const hb_set_t &variation_indices, |
334 | | const hb_vector_t<int>& normalized_coords, |
335 | | bool calculate_delta, /* not pinned at default */ |
336 | | bool no_variations, /* all axes pinned */ |
337 | | hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> &variation_idx_delta_map /* OUT */); |
338 | | |
339 | | |
340 | | template<typename DeltaSetIndexMap> |
341 | | HB_INTERNAL void |
342 | | remap_colrv1_delta_set_index_indices (const DeltaSetIndexMap &index_map, |
343 | | const hb_set_t &delta_set_idxes, |
344 | | hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> &variation_idx_delta_map, /* IN/OUT */ |
345 | | hb_map_t &new_deltaset_idx_varidx_map /* OUT */); |
346 | | |
347 | | |
348 | | HB_INTERNAL void |
349 | | generate_varstore_inner_maps (const hb_set_t& varidx_set, |
350 | | unsigned subtable_count, |
351 | | hb_vector_t<hb_inc_bimap_t> &inner_maps /* OUT */); |
352 | | |
353 | | HB_INTERNAL bool |
354 | | normalize_axes_location (hb_face_t *face, hb_subset_plan_t *plan); |
355 | | |
356 | | HB_INTERNAL void |
357 | | update_instance_metrics_map_from_cff2 (hb_subset_plan_t *plan); |
358 | | |
359 | | HB_INTERNAL bool |
360 | | get_instance_glyphs_contour_points (hb_subset_plan_t *plan); |
361 | | |
362 | | #ifndef HB_NO_BASE |
363 | | HB_INTERNAL void |
364 | | collect_base_variation_indices (hb_subset_plan_t* plan); |
365 | | #endif |
366 | | #endif |
367 | | |
368 | | #ifndef HB_NO_SUBSET_LAYOUT |
369 | | typedef hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> script_langsys_map; |
370 | | |
371 | | HB_INTERNAL void |
372 | | remap_used_mark_sets (hb_subset_plan_t *plan, |
373 | | hb_map_t& used_mark_sets_map); |
374 | | |
375 | | HB_INTERNAL void |
376 | | layout_nameid_closure (hb_subset_plan_t* plan, |
377 | | hb_set_t* drop_tables); |
378 | | |
379 | | HB_INTERNAL void |
380 | | layout_populate_gids_to_retain (hb_subset_plan_t* plan, |
381 | | hb_set_t* drop_tables); |
382 | | |
383 | | HB_INTERNAL void |
384 | | collect_layout_variation_indices (hb_subset_plan_t* plan); |
385 | | #endif |
386 | | |
387 | | |
388 | | #endif /* HB_SUBSET_PLAN_HH */ |