Garret Rieger | af46a4d | 2018-02-05 17:14:46 -0800 | [diff] [blame] | 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 | * |
Rod Sheeter | d0ce3c6 | 2018-02-06 16:58:35 -0800 | [diff] [blame] | 24 | * Google Author(s): Garret Rieger, Roderick Sheeter |
Garret Rieger | af46a4d | 2018-02-05 17:14:46 -0800 | [diff] [blame] | 25 | */ |
| 26 | |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 27 | #ifndef HB_SUBSET_HH |
| 28 | #define HB_SUBSET_HH |
Garret Rieger | af46a4d | 2018-02-05 17:14:46 -0800 | [diff] [blame] | 29 | |
Rod Sheeter | d0ce3c6 | 2018-02-06 16:58:35 -0800 | [diff] [blame] | 30 | |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 31 | #include "hb.hh" |
Garret Rieger | af46a4d | 2018-02-05 17:14:46 -0800 | [diff] [blame] | 32 | |
Behdad Esfahbod | 0bff699 | 2018-02-19 11:51:25 -0800 | [diff] [blame] | 33 | #include "hb-subset.h" |
Rod Sheeter | d0ce3c6 | 2018-02-06 16:58:35 -0800 | [diff] [blame] | 34 | |
Behdad Esfahbod | d1f2990 | 2018-08-31 16:31:00 -0700 | [diff] [blame] | 35 | #include "hb-machinery.hh" |
Behdad Esfahbod | aba0a94 | 2018-08-31 13:25:19 -0700 | [diff] [blame] | 36 | #include "hb-subset-input.hh" |
| 37 | #include "hb-subset-plan.hh" |
Rod Sheeter | d0ce3c6 | 2018-02-06 16:58:35 -0800 | [diff] [blame] | 38 | |
Behdad Esfahbod | d1f2990 | 2018-08-31 16:31:00 -0700 | [diff] [blame] | 39 | struct hb_subset_context_t : |
Behdad Esfahbod | e58b190 | 2018-08-31 16:46:35 -0700 | [diff] [blame] | 40 | hb_dispatch_context_t<hb_subset_context_t, bool, HB_DEBUG_SUBSET> |
Behdad Esfahbod | d1f2990 | 2018-08-31 16:31:00 -0700 | [diff] [blame] | 41 | { |
Ebrahim Byagowi | e412008 | 2018-12-17 21:31:01 +0330 | [diff] [blame] | 42 | const char *get_name () { return "SUBSET"; } |
Behdad Esfahbod | ac350c9 | 2019-05-05 09:10:46 -0700 | [diff] [blame] | 43 | static return_t default_return_value () { return true; } |
Behdad Esfahbod | d1f2990 | 2018-08-31 16:31:00 -0700 | [diff] [blame] | 44 | |
Behdad Esfahbod | c14efb8 | 2019-05-05 09:54:58 -0700 | [diff] [blame] | 45 | private: |
| 46 | template <typename T, typename ...Ts> auto |
Behdad Esfahbod | 83e3eab | 2019-05-07 20:58:43 -0700 | [diff] [blame] | 47 | _dispatch (const T &obj, hb_priority<1>, Ts&&... ds) HB_AUTO_RETURN |
Behdad Esfahbod | 6d555ce | 2021-11-02 00:18:22 -0600 | [diff] [blame] | 48 | ( obj.subset (this, std::forward<Ts> (ds)...) ) |
Behdad Esfahbod | c14efb8 | 2019-05-05 09:54:58 -0700 | [diff] [blame] | 49 | template <typename T, typename ...Ts> auto |
Behdad Esfahbod | 83e3eab | 2019-05-07 20:58:43 -0700 | [diff] [blame] | 50 | _dispatch (const T &obj, hb_priority<0>, Ts&&... ds) HB_AUTO_RETURN |
Behdad Esfahbod | 6d555ce | 2021-11-02 00:18:22 -0600 | [diff] [blame] | 51 | ( obj.dispatch (this, std::forward<Ts> (ds)...) ) |
Behdad Esfahbod | c14efb8 | 2019-05-05 09:54:58 -0700 | [diff] [blame] | 52 | public: |
| 53 | template <typename T, typename ...Ts> auto |
Behdad Esfahbod | 83e3eab | 2019-05-07 20:58:43 -0700 | [diff] [blame] | 54 | dispatch (const T &obj, Ts&&... ds) HB_AUTO_RETURN |
Behdad Esfahbod | 6d555ce | 2021-11-02 00:18:22 -0600 | [diff] [blame] | 55 | ( _dispatch (obj, hb_prioritize, std::forward<Ts> (ds)...) ) |
Behdad Esfahbod | c14efb8 | 2019-05-05 09:54:58 -0700 | [diff] [blame] | 56 | |
Ebrahim Byagowi | e642aab | 2020-02-28 22:24:25 +0330 | [diff] [blame] | 57 | hb_blob_t *source_blob; |
Behdad Esfahbod | d1f2990 | 2018-08-31 16:31:00 -0700 | [diff] [blame] | 58 | hb_subset_plan_t *plan; |
Behdad Esfahbod | e58b190 | 2018-08-31 16:46:35 -0700 | [diff] [blame] | 59 | hb_serialize_context_t *serializer; |
Qunxin Liu | 8b5d3eb | 2020-04-17 11:58:31 -0700 | [diff] [blame] | 60 | hb_tag_t table_tag; |
Behdad Esfahbod | d1f2990 | 2018-08-31 16:31:00 -0700 | [diff] [blame] | 61 | |
Ebrahim Byagowi | e642aab | 2020-02-28 22:24:25 +0330 | [diff] [blame] | 62 | hb_subset_context_t (hb_blob_t *source_blob_, |
| 63 | hb_subset_plan_t *plan_, |
Qunxin Liu | 8b5d3eb | 2020-04-17 11:58:31 -0700 | [diff] [blame] | 64 | hb_serialize_context_t *serializer_, |
| 65 | hb_tag_t table_tag_) : |
| 66 | source_blob (source_blob_), |
Behdad Esfahbod | d1f2990 | 2018-08-31 16:31:00 -0700 | [diff] [blame] | 67 | plan (plan_), |
| 68 | serializer (serializer_), |
Behdad Esfahbod | 1535440 | 2020-06-19 08:30:59 -0700 | [diff] [blame] | 69 | table_tag (table_tag_) {} |
Behdad Esfahbod | d1f2990 | 2018-08-31 16:31:00 -0700 | [diff] [blame] | 70 | }; |
Garret Rieger | af46a4d | 2018-02-05 17:14:46 -0800 | [diff] [blame] | 71 | |
Rod Sheeter | fa87770 | 2018-02-14 14:16:25 -0800 | [diff] [blame] | 72 | |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 73 | #endif /* HB_SUBSET_HH */ |