w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

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 
30 /**
31  * hb_subset_input_create_or_fail:
32  *
33  * Return value: New subset input.
34  *
35  * Since: 1.8.0
36  **/
39 {
40  hb_subset_input_t *input = hb_object_create<hb_subset_input_t>();
41 
42  if (unlikely (!input))
43  return nullptr;
44 
45  input->unicodes = hb_set_create ();
46  input->glyphs = hb_set_create ();
47  input->name_ids = hb_set_create ();
48  hb_set_add_range (input->name_ids, 0, 6);
49  input->name_languages = hb_set_create ();
50  hb_set_add (input->name_languages, 0x0409);
51  input->drop_tables = hb_set_create ();
52  input->drop_hints = false;
53  input->desubroutinize = false;
54  input->retain_gids = false;
55  input->name_legacy = false;
56 
57  hb_tag_t default_drop_tables[] = {
58  // Layout disabled by default
59  HB_TAG ('G', 'S', 'U', 'B'),
60  HB_TAG ('G', 'P', 'O', 'S'),
61  HB_TAG ('G', 'D', 'E', 'F'),
62  HB_TAG ('m', 'o', 'r', 'x'),
63  HB_TAG ('m', 'o', 'r', 't'),
64  HB_TAG ('k', 'e', 'r', 'x'),
65  HB_TAG ('k', 'e', 'r', 'n'),
66 
67  // Copied from fontTools:
68  HB_TAG ('B', 'A', 'S', 'E'),
69  HB_TAG ('J', 'S', 'T', 'F'),
70  HB_TAG ('D', 'S', 'I', 'G'),
71  HB_TAG ('E', 'B', 'D', 'T'),
72  HB_TAG ('E', 'B', 'L', 'C'),
73  HB_TAG ('E', 'B', 'S', 'C'),
74  HB_TAG ('S', 'V', 'G', ' '),
75  HB_TAG ('P', 'C', 'L', 'T'),
76  HB_TAG ('L', 'T', 'S', 'H'),
77  // Graphite tables
78  HB_TAG ('F', 'e', 'a', 't'),
79  HB_TAG ('G', 'l', 'a', 't'),
80  HB_TAG ('G', 'l', 'o', 'c'),
81  HB_TAG ('S', 'i', 'l', 'f'),
82  HB_TAG ('S', 'i', 'l', 'l'),
83  };
84 
85  input->drop_tables->add_array (default_drop_tables, ARRAY_LENGTH (default_drop_tables));
86 
87  return input;
88 }
89 
90 /**
91  * hb_subset_input_reference: (skip)
92  * @subset_input: a subset_input.
93  *
94  *
95  *
96  * Return value:
97  *
98  * Since: 1.8.0
99  **/
102 {
103  return hb_object_reference (subset_input);
104 }
105 
106 /**
107  * hb_subset_input_destroy:
108  * @subset_input: a subset_input.
109  *
110  * Since: 1.8.0
111  **/
112 void
114 {
115  if (!hb_object_destroy (subset_input)) return;
116 
117  hb_set_destroy (subset_input->unicodes);
118  hb_set_destroy (subset_input->glyphs);
119  hb_set_destroy (subset_input->name_ids);
120  hb_set_destroy (subset_input->name_languages);
121  hb_set_destroy (subset_input->drop_tables);
122 
123  free (subset_input);
124 }
125 
126 /**
127  * hb_subset_input_unicode_set:
128  * @subset_input: a subset_input.
129  *
130  * Since: 1.8.0
131  **/
134 {
135  return subset_input->unicodes;
136 }
137 
138 /**
139  * hb_subset_input_glyph_set:
140  * @subset_input: a subset_input.
141  *
142  * Since: 1.8.0
143  **/
146 {
147  return subset_input->glyphs;
148 }
149 
152 {
153  return subset_input->name_ids;
154 }
155 
158 {
159  return subset_input->name_languages;
160 }
161 
164 {
165  return subset_input->drop_tables;
166 }
167 
168 HB_EXTERN void
170  hb_bool_t drop_hints)
171 {
172  subset_input->drop_hints = drop_hints;
173 }
174 
177 {
178  return subset_input->drop_hints;
179 }
180 
181 HB_EXTERN void
183  hb_bool_t desubroutinize)
184 {
185  subset_input->desubroutinize = desubroutinize;
186 }
187 
190 {
191  return subset_input->desubroutinize;
192 }
193 
194 /**
195  * hb_subset_input_set_retain_gids:
196  * @subset_input: a subset_input.
197  * @retain_gids: If true the subsetter will not renumber glyph ids.
198  * Since: 2.4.0
199  **/
200 HB_EXTERN void
202  hb_bool_t retain_gids)
203 {
204  subset_input->retain_gids = retain_gids;
205 }
206 
207 /**
208  * hb_subset_input_get_retain_gids:
209  * Returns: value of retain_gids.
210  * Since: 2.4.0
211  **/
214 {
215  return subset_input->retain_gids;
216 }
217 
218 HB_EXTERN void
220  hb_bool_t name_legacy)
221 {
222  subset_input->name_legacy = name_legacy;
223 }
224 
227 {
228  return subset_input->name_legacy;
229 }
#define ARRAY_LENGTH(__array)
Definition: cairoint.h:137
#define free(a)
Definition: decNumber.cpp:310
#define unlikely(x)
Definition: jbig2arith.cc:116
#define input
Definition: cpascal.h:53
#define HB_TAG(c1, c2, c3, c4)
Definition: hb-common.h:155
int hb_bool_t
Definition: hb-common.h:97
uint32_t hb_tag_t
Definition: hb-common.h:147
#define HB_EXTERN
Definition: hb-common.h:37
static bool hb_object_destroy(Type *obj)
Definition: hb-object.hh:274
static Type * hb_object_reference(Type *obj)
Definition: hb-object.hh:264
void hb_set_add_range(hb_set_t *set, hb_codepoint_t first, hb_codepoint_t last)
Definition: hb-set.cc:251
void hb_set_add(hb_set_t *set, hb_codepoint_t codepoint)
Definition: hb-set.cc:233
hb_set_t * hb_set_create()
Definition: hb-set.cc:52
void hb_set_destroy(hb_set_t *set)
Definition: hb-set.cc:106
hb_set_t * hb_subset_input_glyph_set(hb_subset_input_t *subset_input)
void hb_subset_input_set_retain_gids(hb_subset_input_t *subset_input, hb_bool_t retain_gids)
hb_subset_input_t * hb_subset_input_reference(hb_subset_input_t *subset_input)
hb_bool_t hb_subset_input_get_drop_hints(hb_subset_input_t *subset_input)
hb_bool_t hb_subset_input_get_name_legacy(hb_subset_input_t *subset_input)
hb_set_t * hb_subset_input_nameid_set(hb_subset_input_t *subset_input)
hb_set_t * hb_subset_input_drop_tables_set(hb_subset_input_t *subset_input)
void hb_subset_input_destroy(hb_subset_input_t *subset_input)
void hb_subset_input_set_name_legacy(hb_subset_input_t *subset_input, hb_bool_t name_legacy)
hb_bool_t hb_subset_input_get_desubroutinize(hb_subset_input_t *subset_input)
hb_subset_input_t * hb_subset_input_create_or_fail()
hb_set_t * hb_subset_input_unicode_set(hb_subset_input_t *subset_input)
void hb_subset_input_set_desubroutinize(hb_subset_input_t *subset_input, hb_bool_t desubroutinize)
hb_set_t * hb_subset_input_namelangid_set(hb_subset_input_t *subset_input)
void hb_subset_input_set_drop_hints(hb_subset_input_t *subset_input, hb_bool_t drop_hints)
hb_bool_t hb_subset_input_get_retain_gids(hb_subset_input_t *subset_input)
hb_set_t * drop_tables
hb_set_t * name_languages
Definition: execute.c:108