blob: 98c5f06fbfc5976c0c1661c02413e1d24c2ca8c2 [file] [log] [blame]
Garret Riegeraf46a4d2018-02-05 17:14:46 -08001/*
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 Sheeterd0ce3c62018-02-06 16:58:35 -080024 * Google Author(s): Garret Rieger, Roderick Sheeter
Garret Riegeraf46a4d2018-02-05 17:14:46 -080025 */
26
Behdad Esfahbodc77ae402018-08-25 22:36:36 -070027#ifndef HB_SUBSET_HH
28#define HB_SUBSET_HH
Garret Riegeraf46a4d2018-02-05 17:14:46 -080029
Rod Sheeterd0ce3c62018-02-06 16:58:35 -080030
Behdad Esfahbodc77ae402018-08-25 22:36:36 -070031#include "hb.hh"
Garret Riegeraf46a4d2018-02-05 17:14:46 -080032
Behdad Esfahbod0bff6992018-02-19 11:51:25 -080033#include "hb-subset.h"
Rod Sheeterd0ce3c62018-02-06 16:58:35 -080034
Behdad Esfahbodd1f29902018-08-31 16:31:00 -070035#include "hb-machinery.hh"
Behdad Esfahbodaba0a942018-08-31 13:25:19 -070036#include "hb-subset-input.hh"
37#include "hb-subset-plan.hh"
Rod Sheeterd0ce3c62018-02-06 16:58:35 -080038
Behdad Esfahbodd1f29902018-08-31 16:31:00 -070039struct hb_subset_context_t :
Behdad Esfahbode58b1902018-08-31 16:46:35 -070040 hb_dispatch_context_t<hb_subset_context_t, bool, HB_DEBUG_SUBSET>
Behdad Esfahbodd1f29902018-08-31 16:31:00 -070041{
Ebrahim Byagowie4120082018-12-17 21:31:01 +033042 const char *get_name () { return "SUBSET"; }
Behdad Esfahbodac350c92019-05-05 09:10:46 -070043 static return_t default_return_value () { return true; }
Behdad Esfahbodd1f29902018-08-31 16:31:00 -070044
Behdad Esfahbodc14efb82019-05-05 09:54:58 -070045 private:
46 template <typename T, typename ...Ts> auto
Behdad Esfahbod83e3eab2019-05-07 20:58:43 -070047 _dispatch (const T &obj, hb_priority<1>, Ts&&... ds) HB_AUTO_RETURN
Behdad Esfahbod6d555ce2021-11-02 00:18:22 -060048 ( obj.subset (this, std::forward<Ts> (ds)...) )
Behdad Esfahbodc14efb82019-05-05 09:54:58 -070049 template <typename T, typename ...Ts> auto
Behdad Esfahbod83e3eab2019-05-07 20:58:43 -070050 _dispatch (const T &obj, hb_priority<0>, Ts&&... ds) HB_AUTO_RETURN
Behdad Esfahbod6d555ce2021-11-02 00:18:22 -060051 ( obj.dispatch (this, std::forward<Ts> (ds)...) )
Behdad Esfahbodc14efb82019-05-05 09:54:58 -070052 public:
53 template <typename T, typename ...Ts> auto
Behdad Esfahbod83e3eab2019-05-07 20:58:43 -070054 dispatch (const T &obj, Ts&&... ds) HB_AUTO_RETURN
Behdad Esfahbod6d555ce2021-11-02 00:18:22 -060055 ( _dispatch (obj, hb_prioritize, std::forward<Ts> (ds)...) )
Behdad Esfahbodc14efb82019-05-05 09:54:58 -070056
Ebrahim Byagowie642aab2020-02-28 22:24:25 +033057 hb_blob_t *source_blob;
Behdad Esfahbodd1f29902018-08-31 16:31:00 -070058 hb_subset_plan_t *plan;
Behdad Esfahbode58b1902018-08-31 16:46:35 -070059 hb_serialize_context_t *serializer;
Qunxin Liu8b5d3eb2020-04-17 11:58:31 -070060 hb_tag_t table_tag;
Behdad Esfahbodd1f29902018-08-31 16:31:00 -070061
Ebrahim Byagowie642aab2020-02-28 22:24:25 +033062 hb_subset_context_t (hb_blob_t *source_blob_,
63 hb_subset_plan_t *plan_,
Qunxin Liu8b5d3eb2020-04-17 11:58:31 -070064 hb_serialize_context_t *serializer_,
65 hb_tag_t table_tag_) :
66 source_blob (source_blob_),
Behdad Esfahbodd1f29902018-08-31 16:31:00 -070067 plan (plan_),
68 serializer (serializer_),
Behdad Esfahbod15354402020-06-19 08:30:59 -070069 table_tag (table_tag_) {}
Behdad Esfahbodd1f29902018-08-31 16:31:00 -070070};
Garret Riegeraf46a4d2018-02-05 17:14:46 -080071
Rod Sheeterfa877702018-02-14 14:16:25 -080072
Behdad Esfahbodc77ae402018-08-25 22:36:36 -070073#endif /* HB_SUBSET_HH */