blob: 3b2c42a96b6a0dd36dd31b6e3416f1476e68d521 [file] [log] [blame]
Behdad Esfahbodaba0a942018-08-31 13:25:19 -07001/*
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_INPUT_HH
28#define HB_SUBSET_INPUT_HH
29
30
31#include "hb.hh"
32
33#include "hb-subset.h"
Garret Rieger05204d72021-08-25 16:51:26 -070034#include "hb-map.hh"
35#include "hb-set.hh"
Behdad Esfahbodaba0a942018-08-31 13:25:19 -070036
37#include "hb-font.hh"
38
Garret Riegerf9d8e4a2021-07-29 15:25:41 -070039HB_MARK_AS_FLAG_T (hb_subset_flags_t);
40
Behdad Esfahbodaba0a942018-08-31 13:25:19 -070041struct hb_subset_input_t
42{
43 hb_object_header_t header;
Behdad Esfahbodaba0a942018-08-31 13:25:19 -070044
Garret Rieger7194c2a2021-08-27 08:20:58 -070045 union {
46 struct {
47 hb_set_t *glyphs;
48 hb_set_t *unicodes;
49 hb_set_t *no_subset_tables;
50 hb_set_t *drop_tables;
51 hb_set_t *name_ids;
52 hb_set_t *name_languages;
53 hb_set_t *layout_features;
54 } sets;
Garret Rieger57d6bf82021-08-27 10:59:28 -070055 hb_set_t* set_ptrs[sizeof (sets) / sizeof (hb_set_t*)];
Garret Rieger7194c2a2021-08-27 08:20:58 -070056 };
Behdad Esfahbodaba0a942018-08-31 13:25:19 -070057
Garret Riegerf9d8e4a2021-07-29 15:25:41 -070058 unsigned flags;
Garret Riegera6c6cda2021-06-09 17:46:47 -070059
Garret Rieger7194c2a2021-08-27 08:20:58 -070060 inline unsigned num_sets () const
61 {
Garret Rieger57d6bf82021-08-27 10:59:28 -070062 return sizeof (set_ptrs) / sizeof (hb_set_t*);
Garret Rieger7194c2a2021-08-27 08:20:58 -070063 }
64
65 inline hb_array_t<hb_set_t*> sets_iter ()
66 {
67 return hb_array_t<hb_set_t*> (set_ptrs, num_sets ());
68 }
69
Garret Rieger05204d72021-08-25 16:51:26 -070070 inline hb_set_t* unicodes()
71 {
Garret Rieger7194c2a2021-08-27 08:20:58 -070072 return sets.unicodes;
Garret Rieger05204d72021-08-25 16:51:26 -070073 }
74
75 inline const hb_set_t* unicodes() const
76 {
Garret Rieger7194c2a2021-08-27 08:20:58 -070077 return sets.unicodes;
Garret Rieger05204d72021-08-25 16:51:26 -070078 }
79
80 inline hb_set_t* glyphs ()
81 {
Garret Rieger7194c2a2021-08-27 08:20:58 -070082 return sets.glyphs;
Garret Rieger05204d72021-08-25 16:51:26 -070083 }
84
85 inline const hb_set_t* glyphs () const
86 {
Garret Rieger7194c2a2021-08-27 08:20:58 -070087 return sets.glyphs;
Garret Rieger05204d72021-08-25 16:51:26 -070088 }
89
90 inline hb_set_t* name_ids ()
91 {
Garret Rieger7194c2a2021-08-27 08:20:58 -070092 return sets.name_ids;
Garret Rieger05204d72021-08-25 16:51:26 -070093 }
94
95 inline const hb_set_t* name_ids () const
96 {
Garret Rieger7194c2a2021-08-27 08:20:58 -070097 return sets.name_ids;
Garret Rieger05204d72021-08-25 16:51:26 -070098 }
99
100 inline hb_set_t* name_languages ()
101 {
Garret Rieger7194c2a2021-08-27 08:20:58 -0700102 return sets.name_languages;
Garret Rieger05204d72021-08-25 16:51:26 -0700103 }
104
105 inline const hb_set_t* name_languages () const
106 {
Garret Rieger7194c2a2021-08-27 08:20:58 -0700107 return sets.name_languages;
Garret Rieger05204d72021-08-25 16:51:26 -0700108 }
109
110 inline hb_set_t* no_subset_tables ()
111 {
Garret Rieger7194c2a2021-08-27 08:20:58 -0700112 return sets.no_subset_tables;
Garret Rieger05204d72021-08-25 16:51:26 -0700113 }
114
115 inline const hb_set_t* no_subset_tables () const
116 {
Garret Rieger7194c2a2021-08-27 08:20:58 -0700117 return sets.no_subset_tables;
Garret Rieger05204d72021-08-25 16:51:26 -0700118 }
119
120 inline hb_set_t* drop_tables ()
121 {
Garret Rieger7194c2a2021-08-27 08:20:58 -0700122 return sets.drop_tables;
Garret Rieger05204d72021-08-25 16:51:26 -0700123 }
124
125 inline const hb_set_t* drop_tables () const
126 {
Garret Rieger7194c2a2021-08-27 08:20:58 -0700127 return sets.drop_tables;
Garret Rieger05204d72021-08-25 16:51:26 -0700128 }
129
130 inline hb_set_t* layout_features ()
131 {
Garret Rieger7194c2a2021-08-27 08:20:58 -0700132 return sets.layout_features;
Garret Rieger05204d72021-08-25 16:51:26 -0700133 }
134
135 inline const hb_set_t* layout_features () const
136 {
Garret Rieger7194c2a2021-08-27 08:20:58 -0700137 return sets.layout_features;
Garret Rieger05204d72021-08-25 16:51:26 -0700138 }
139
140 bool in_error () const
141 {
Garret Rieger7194c2a2021-08-27 08:20:58 -0700142 for (unsigned i = 0; i < num_sets (); i++)
Garret Rieger05204d72021-08-25 16:51:26 -0700143 {
Garret Rieger7194c2a2021-08-27 08:20:58 -0700144 if (unlikely (set_ptrs[i]->in_error ()))
Garret Rieger05204d72021-08-25 16:51:26 -0700145 return true;
146 }
147 return false;
148 }
Behdad Esfahbodaba0a942018-08-31 13:25:19 -0700149};
150
151
152#endif /* HB_SUBSET_INPUT_HH */