QtBase  v6.3.1
hb-subset-input.cc
Go to the documentation of this file.
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, Rod Sheeter, Behdad Esfahbod
25  */
26 
27 #include "hb-subset.hh"
28 #include "hb-set.hh"
29 
42 {
43  hb_subset_input_t *input = hb_object_create<hb_subset_input_t>();
44 
45  if (unlikely (!input))
46  return nullptr;
47 
48  for (auto& set : input->sets_iter ())
49  set = hb_set_create ();
50 
51  if (input->in_error ())
52  {
54  return nullptr;
55  }
56 
58 
59  hb_set_add_range (input->sets.name_ids, 0, 6);
60  hb_set_add (input->sets.name_languages, 0x0409);
61 
62  hb_tag_t default_drop_tables[] = {
63  // Layout disabled by default
64  HB_TAG ('m', 'o', 'r', 'x'),
65  HB_TAG ('m', 'o', 'r', 't'),
66  HB_TAG ('k', 'e', 'r', 'x'),
67  HB_TAG ('k', 'e', 'r', 'n'),
68 
69  // Copied from fontTools:
70  HB_TAG ('B', 'A', 'S', 'E'),
71  HB_TAG ('J', 'S', 'T', 'F'),
72  HB_TAG ('D', 'S', 'I', 'G'),
73  HB_TAG ('E', 'B', 'D', 'T'),
74  HB_TAG ('E', 'B', 'L', 'C'),
75  HB_TAG ('E', 'B', 'S', 'C'),
76  HB_TAG ('S', 'V', 'G', ' '),
77  HB_TAG ('P', 'C', 'L', 'T'),
78  HB_TAG ('L', 'T', 'S', 'H'),
79  // Graphite tables
80  HB_TAG ('F', 'e', 'a', 't'),
81  HB_TAG ('G', 'l', 'a', 't'),
82  HB_TAG ('G', 'l', 'o', 'c'),
83  HB_TAG ('S', 'i', 'l', 'f'),
84  HB_TAG ('S', 'i', 'l', 'l'),
85  };
86  input->sets.drop_tables->add_array (default_drop_tables, ARRAY_LENGTH (default_drop_tables));
87 
88  hb_tag_t default_no_subset_tables[] = {
89  HB_TAG ('a', 'v', 'a', 'r'),
90  HB_TAG ('f', 'v', 'a', 'r'),
91  HB_TAG ('g', 'a', 's', 'p'),
92  HB_TAG ('c', 'v', 't', ' '),
93  HB_TAG ('f', 'p', 'g', 'm'),
94  HB_TAG ('p', 'r', 'e', 'p'),
95  HB_TAG ('V', 'D', 'M', 'X'),
96  HB_TAG ('D', 'S', 'I', 'G'),
97  HB_TAG ('M', 'V', 'A', 'R'),
98  HB_TAG ('c', 'v', 'a', 'r'),
99  HB_TAG ('S', 'T', 'A', 'T'),
100  };
101  input->sets.no_subset_tables->add_array (default_no_subset_tables,
102  ARRAY_LENGTH (default_no_subset_tables));
103 
104  //copied from _layout_features_groups in fonttools
105  hb_tag_t default_layout_features[] = {
106  // default shaper
107  // common
108  HB_TAG ('r', 'v', 'r', 'n'),
109  HB_TAG ('c', 'c', 'm', 'p'),
110  HB_TAG ('l', 'i', 'g', 'a'),
111  HB_TAG ('l', 'o', 'c', 'l'),
112  HB_TAG ('m', 'a', 'r', 'k'),
113  HB_TAG ('m', 'k', 'm', 'k'),
114  HB_TAG ('r', 'l', 'i', 'g'),
115 
116  //fractions
117  HB_TAG ('f', 'r', 'a', 'c'),
118  HB_TAG ('n', 'u', 'm', 'r'),
119  HB_TAG ('d', 'n', 'o', 'm'),
120 
121  //horizontal
122  HB_TAG ('c', 'a', 'l', 't'),
123  HB_TAG ('c', 'l', 'i', 'g'),
124  HB_TAG ('c', 'u', 'r', 's'),
125  HB_TAG ('k', 'e', 'r', 'n'),
126  HB_TAG ('r', 'c', 'l', 't'),
127 
128  //vertical
129  HB_TAG ('v', 'a', 'l', 't'),
130  HB_TAG ('v', 'e', 'r', 't'),
131  HB_TAG ('v', 'k', 'r', 'n'),
132  HB_TAG ('v', 'p', 'a', 'l'),
133  HB_TAG ('v', 'r', 't', '2'),
134 
135  //ltr
136  HB_TAG ('l', 't', 'r', 'a'),
137  HB_TAG ('l', 't', 'r', 'm'),
138 
139  //rtl
140  HB_TAG ('r', 't', 'l', 'a'),
141  HB_TAG ('r', 't', 'l', 'm'),
142 
143  //Complex shapers
144  //arabic
145  HB_TAG ('i', 'n', 'i', 't'),
146  HB_TAG ('m', 'e', 'd', 'i'),
147  HB_TAG ('f', 'i', 'n', 'a'),
148  HB_TAG ('i', 's', 'o', 'l'),
149  HB_TAG ('m', 'e', 'd', '2'),
150  HB_TAG ('f', 'i', 'n', '2'),
151  HB_TAG ('f', 'i', 'n', '3'),
152  HB_TAG ('c', 's', 'w', 'h'),
153  HB_TAG ('m', 's', 'e', 't'),
154  HB_TAG ('s', 't', 'c', 'h'),
155 
156  //hangul
157  HB_TAG ('l', 'j', 'm', 'o'),
158  HB_TAG ('v', 'j', 'm', 'o'),
159  HB_TAG ('t', 'j', 'm', 'o'),
160 
161  //tibetan
162  HB_TAG ('a', 'b', 'v', 's'),
163  HB_TAG ('b', 'l', 'w', 's'),
164  HB_TAG ('a', 'b', 'v', 'm'),
165  HB_TAG ('b', 'l', 'w', 'm'),
166 
167  //indic
168  HB_TAG ('n', 'u', 'k', 't'),
169  HB_TAG ('a', 'k', 'h', 'n'),
170  HB_TAG ('r', 'p', 'h', 'f'),
171  HB_TAG ('r', 'k', 'r', 'f'),
172  HB_TAG ('p', 'r', 'e', 'f'),
173  HB_TAG ('b', 'l', 'w', 'f'),
174  HB_TAG ('h', 'a', 'l', 'f'),
175  HB_TAG ('a', 'b', 'v', 'f'),
176  HB_TAG ('p', 's', 't', 'f'),
177  HB_TAG ('c', 'f', 'a', 'r'),
178  HB_TAG ('v', 'a', 't', 'u'),
179  HB_TAG ('c', 'j', 'c', 't'),
180  HB_TAG ('i', 'n', 'i', 't'),
181  HB_TAG ('p', 'r', 'e', 's'),
182  HB_TAG ('a', 'b', 'v', 's'),
183  HB_TAG ('b', 'l', 'w', 's'),
184  HB_TAG ('p', 's', 't', 's'),
185  HB_TAG ('h', 'a', 'l', 'n'),
186  HB_TAG ('d', 'i', 's', 't'),
187  HB_TAG ('a', 'b', 'v', 'm'),
188  HB_TAG ('b', 'l', 'w', 'm'),
189  };
190 
191  input->sets.layout_features->add_array (default_layout_features, ARRAY_LENGTH (default_layout_features));
192 
193  if (input->in_error ())
194  {
196  return nullptr;
197  }
198  return input;
199 }
200 
213 {
214  return hb_object_reference (input);
215 }
216 
226 void
228 {
229  if (!hb_object_destroy (input)) return;
230 
231  for (hb_set_t* set : input->sets_iter ())
233 
234  hb_free (input);
235 }
236 
251 {
252  return input->sets.unicodes;
253 }
254 
268 {
269  return input->sets.glyphs;
270 }
271 
285 {
286  return input->sets_iter () [set_type];
287 }
288 
301 {
302  return (hb_subset_flags_t) input->flags;
303 }
304 
315 HB_EXTERN void
317  unsigned value)
318 {
319  input->flags = (hb_subset_flags_t) value;
320 }
321 
336 hb_bool_t
339  void * data,
341  hb_bool_t replace)
342 {
343  return hb_object_set_user_data (input, key, data, destroy, replace);
344 }
345 
358 void *
361 {
362  return hb_object_get_user_data (input, key);
363 }
void hb_set_add_range(hb_set_t *set, hb_codepoint_t first, hb_codepoint_t last)
Definition: hb-set.cc:294
void hb_set_add(hb_set_t *set, hb_codepoint_t codepoint)
Definition: hb-set.cc:252
hb_set_t * hb_set_create()
Definition: hb-set.cc:52
void hb_set_destroy(hb_set_t *set)
Definition: hb-set.cc:106
void * hb_subset_input_get_user_data(const hb_subset_input_t *input, hb_user_data_key_t *key)
HB_EXTERN void hb_subset_input_set_flags(hb_subset_input_t *input, unsigned value)
HB_EXTERN hb_set_t * hb_subset_input_unicode_set(hb_subset_input_t *input)
hb_bool_t hb_subset_input_set_user_data(hb_subset_input_t *input, hb_user_data_key_t *key, void *data, hb_destroy_func_t destroy, hb_bool_t replace)
HB_EXTERN hb_subset_flags_t hb_subset_input_get_flags(hb_subset_input_t *input)
HB_EXTERN hb_set_t * hb_subset_input_set(hb_subset_input_t *input, hb_subset_sets_t set_type)
hb_subset_input_t * hb_subset_input_reference(hb_subset_input_t *input)
hb_subset_input_t * hb_subset_input_create_or_fail(void)
void hb_subset_input_destroy(hb_subset_input_t *input)
HB_EXTERN hb_set_t * hb_subset_input_glyph_set(hb_subset_input_t *input)
hb_subset_flags_t
Definition: hb-subset.h:78
@ HB_SUBSET_FLAGS_DEFAULT
Definition: hb-subset.h:79
hb_subset_sets_t
Definition: hb-subset.h:108
#define unlikely(expr)
Definition: hb.hh:251
#define hb_free
Definition: hb.hh:238
EGLOutputLayerEXT EGLint EGLAttrib value
#define ARRAY_LENGTH(a)
Definition: qkmsdevice.cpp:52
GLuint64 key
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLenum input
Definition: qopenglext.h:10816
void(* hb_destroy_func_t)(void *user_data)
Definition: hb-common.h:771
HB_BEGIN_DECLS typedef int hb_bool_t
Definition: hb-common.h:97
#define HB_TAG(c1, c2, c3, c4)
Definition: hb-common.h:169
uint32_t hb_tag_t
Definition: hb-common.h:157
#define HB_EXTERN
Definition: hb-common.h:37
HB_EXTERN hb_font_get_glyph_func_t void hb_destroy_func_t destroy
QFuture< QSet< QChar > > set
[10]