harfbuzzjs 0.2.1 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/.github/workflows/build.yml +45 -0
  2. package/.gitmodules +3 -0
  3. package/LICENSE +0 -1
  4. package/README.md +2 -8
  5. package/build-subset.sh +21 -0
  6. package/build.sh +17 -57
  7. package/{subset/config-override.h → config-override-subset.h} +0 -0
  8. package/config-override.h +4 -3
  9. package/examples/Mada.abjad.otf +0 -0
  10. package/{subset/roboto-black.ttf → examples/Roboto-Black.ttf} +0 -0
  11. package/{subset/test.js → examples/hb-subset.example.node.js} +5 -5
  12. package/examples/hbjs.example.html +0 -1
  13. package/examples/hbjs.example.js +6 -3
  14. package/examples/hbjs.example.node.js +2 -0
  15. package/examples/nohbjs.html +0 -1
  16. package/harfbuzz.ts +46 -1
  17. package/hb-subset.symbols +28 -0
  18. package/hb-subset.wasm +0 -0
  19. package/hb.wasm +0 -0
  20. package/hbjs.cc +256 -0
  21. package/hbjs.js +73 -4
  22. package/hbjs.symbols +41 -0
  23. package/index.js +0 -1
  24. package/package.json +1 -1
  25. package/hbjs.c +0 -284
  26. package/libc/ctype.h +0 -73
  27. package/libc/emmalloc.cpp +0 -1202
  28. package/libc/fprintf.c +0 -65
  29. package/libc/include/assert.h +0 -14
  30. package/libc/include/cassert +0 -1
  31. package/libc/include/cfloat +0 -1
  32. package/libc/include/climits +0 -1
  33. package/libc/include/cmath +0 -1
  34. package/libc/include/cstdarg +0 -1
  35. package/libc/include/cstddef +0 -1
  36. package/libc/include/cstdio +0 -1
  37. package/libc/include/cstdlib +0 -1
  38. package/libc/include/cstring +0 -1
  39. package/libc/include/emscripten.h +0 -0
  40. package/libc/include/float.h +0 -6
  41. package/libc/include/limits.h +0 -2
  42. package/libc/include/locale.h +0 -0
  43. package/libc/include/malloc.h +0 -13
  44. package/libc/include/math.h +0 -0
  45. package/libc/include/raqm-version.h +0 -5
  46. package/libc/include/stdarg.h +0 -0
  47. package/libc/include/stdbool.h +0 -12
  48. package/libc/include/stddef.h +0 -0
  49. package/libc/include/stdint.h +0 -1
  50. package/libc/include/stdio.h +0 -0
  51. package/libc/include/stdlib.h +0 -110
  52. package/libc/include/string.h +0 -26
  53. package/libc/include/sys/types.h +0 -1
  54. package/libc/include/unistd.h +0 -14
  55. package/libc/main.c +0 -7
  56. package/libc/malloc.cc +0 -29
  57. package/libc/prf.c +0 -667
  58. package/libc/sprintf.c +0 -112
  59. package/libc/strtol.c +0 -79
  60. package/libc/zephyr-string.c +0 -381
  61. package/subset/build.sh +0 -48
  62. package/subset/hb-subset.wasm +0 -0
  63. package/subset/test.cc +0 -50
package/libc/sprintf.c DELETED
@@ -1,112 +0,0 @@
1
- /* sprintf.c */
2
-
3
- /*
4
- * Copyright (c) 1997-2010, 2013-2014 Wind River Systems, Inc.
5
- *
6
- * SPDX-License-Identifier: Apache-2.0
7
- */
8
-
9
- #include <stdarg.h>
10
- #include <stdio.h>
11
- #define va_list __builtin_va_list
12
- #define va_start __builtin_va_start
13
- #define va_end __builtin_va_end
14
- #define va_arg __builtin_va_arg
15
- typedef __SIZE_TYPE__ size_t;
16
- #define stderr 0
17
- #define _MLIBC_RESTRICT
18
-
19
- extern int _prf(int (*func)(), void *dest,
20
- const char *format, va_list vargs);
21
-
22
- struct emitter {
23
- char *ptr;
24
- int len;
25
- };
26
-
27
- static int sprintf_out(int c, struct emitter *p)
28
- {
29
- if (p->len > 1) { /* need to reserve a byte for EOS */
30
- *(p->ptr) = c;
31
- p->ptr += 1;
32
- p->len -= 1;
33
- }
34
- return 0; /* indicate keep going so we get the total count */
35
- }
36
-
37
- int snprintf(char *_MLIBC_RESTRICT s, size_t len,
38
- const char *_MLIBC_RESTRICT format, ...)
39
- {
40
- va_list vargs;
41
-
42
- struct emitter p;
43
- int r;
44
- char dummy;
45
-
46
- if (len == 0) {
47
- s = &dummy; /* write final NUL to dummy, can't change *s */
48
- }
49
-
50
- p.ptr = s;
51
- p.len = (int) len;
52
-
53
- va_start(vargs, format);
54
- r = _prf(sprintf_out, (void *) (&p), format, vargs);
55
- va_end(vargs);
56
-
57
- *(p.ptr) = 0;
58
- return r;
59
- }
60
-
61
- int sprintf(char *_MLIBC_RESTRICT s, const char *_MLIBC_RESTRICT format, ...)
62
- {
63
- va_list vargs;
64
-
65
- struct emitter p;
66
- int r;
67
-
68
- p.ptr = s;
69
- p.len = (int) 0x7fffffff; /* allow up to "maxint" characters */
70
-
71
- va_start(vargs, format);
72
- r = _prf(sprintf_out, (void *) (&p), format, vargs);
73
- va_end(vargs);
74
-
75
- *(p.ptr) = 0;
76
- return r;
77
- }
78
-
79
- int vsnprintf(char *_MLIBC_RESTRICT s, size_t len,
80
- const char *_MLIBC_RESTRICT format, va_list vargs)
81
- {
82
- struct emitter p;
83
- int r;
84
- char dummy;
85
-
86
- if (len == 0) {
87
- s = &dummy; /* write final NUL to dummy, can't change * *s */
88
- }
89
-
90
- p.ptr = s;
91
- p.len = (int) len;
92
-
93
- r = _prf(sprintf_out, (void *) (&p), format, vargs);
94
-
95
- *(p.ptr) = 0;
96
- return r;
97
- }
98
-
99
- int vsprintf(char *_MLIBC_RESTRICT s, const char *_MLIBC_RESTRICT format,
100
- va_list vargs)
101
- {
102
- struct emitter p;
103
- int r;
104
-
105
- p.ptr = s;
106
- p.len = (int) 0x7fffffff; /* allow up to "maxint" characters */
107
-
108
- r = _prf(sprintf_out, (void *) (&p), format, vargs);
109
-
110
- *(p.ptr) = 0;
111
- return r;
112
- }
package/libc/strtol.c DELETED
@@ -1,79 +0,0 @@
1
- #include <limits.h>
2
- #include <stdlib.h>
3
- #include "ctype.h"
4
-
5
- long strtol(const char *nptr, char **endptr, register int base)
6
- {
7
- register const char *s = nptr;
8
- register unsigned long acc;
9
- register int c;
10
- register unsigned long cutoff;
11
- register int neg = 0, any, cutlim;
12
-
13
- /*
14
- * Skip white space and pick up leading +/- sign if any.
15
- * If base is 0, allow 0x for hex and 0 for octal, else
16
- * assume decimal; if base is already 16, allow 0x.
17
- */
18
- do {
19
- c = *s++;
20
- } while (isspace(c));
21
- if (c == '-') {
22
- neg = 1;
23
- c = *s++;
24
- } else if (c == '+')
25
- c = *s++;
26
- if ((base == 0 || base == 16) &&
27
- c == '0' && (*s == 'x' || *s == 'X')) {
28
- c = s[1];
29
- s += 2;
30
- base = 16;
31
- }
32
- if (base == 0)
33
- base = c == '0' ? 8 : 10;
34
-
35
- /*
36
- * Compute the cutoff value between legal numbers and illegal
37
- * numbers. That is the largest legal value, divided by the
38
- * base. An input number that is greater than this value, if
39
- * followed by a legal input character, is too big. One that
40
- * is equal to this value may be valid or not; the limit
41
- * between valid and invalid numbers is then based on the last
42
- * digit. For instance, if the range for longs is
43
- * [-2147483648..2147483647] and the input base is 10,
44
- * cutoff will be set to 214748364 and cutlim to either
45
- * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
46
- * a value > 214748364, or equal but the next digit is > 7 (or 8),
47
- * the number is too big, and we will return a range error.
48
- *
49
- * Set any if any `digits' consumed; make it negative to indicate
50
- * overflow.
51
- */
52
- cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
53
- cutlim = cutoff % (unsigned long)base;
54
- cutoff /= (unsigned long)base;
55
- for (acc = 0, any = 0;; c = *s++) {
56
- if (isdigit(c))
57
- c -= '0';
58
- else if (isalpha(c))
59
- c -= isupper(c) ? 'A' - 10 : 'a' - 10;
60
- else
61
- break;
62
- if (c >= base)
63
- break;
64
- if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
65
- any = -1;
66
- else {
67
- any = 1;
68
- acc *= base;
69
- acc += c;
70
- }
71
- }
72
- if (any < 0) {
73
- acc = neg ? LONG_MIN : LONG_MAX;
74
- } else if (neg)
75
- acc = -acc;
76
- if (endptr != 0)
77
- *endptr = (char *)(any ? s - 1 : nptr);
78
- return acc;
79
- }
@@ -1,381 +0,0 @@
1
- typedef __SIZE_TYPE__ size_t;
2
- #define NULL ((void*) 0)
3
-
4
- // Source: https://github.com/intel/zephyr/blob/master/lib/libc/minimal/source/string/string.c
5
- // but modified for size optimization
6
- /* string.c - common string routines */
7
- /*
8
- * Copyright (c) 2014 Wind River Systems, Inc.
9
- *
10
- * SPDX-License-Identifier: Apache-2.0
11
- */
12
-
13
- /**
14
- *
15
- * @brief Copy a string
16
- *
17
- * @return pointer to destination buffer <d>
18
- */
19
-
20
- char *strcpy(char * d, const char * s)
21
- {
22
- char *dest = d;
23
-
24
- while (*s != '\0') {
25
- *d = *s;
26
- d++;
27
- s++;
28
- }
29
-
30
- *d = '\0';
31
-
32
- return dest;
33
- }
34
- /**
35
- *
36
- * @brief Copy part of a string
37
- *
38
- * @return pointer to destination buffer <d>
39
- */
40
- char *strncpy(char *__restrict d, const char *__restrict s, size_t n)
41
- {
42
- char *dest = d;
43
-
44
- while ((n > 0) && *s != '\0') {
45
- *d = *s;
46
- s++;
47
- d++;
48
- n--;
49
- }
50
-
51
- while (n > 0) {
52
- *d = '\0';
53
- d++;
54
- n--;
55
- }
56
-
57
- return dest;
58
- }
59
-
60
- /**
61
- *
62
- * @brief String scanning operation
63
- *
64
- * @return pointer to 1st instance of found byte, or NULL if not found
65
- */
66
-
67
- char *strchr(const char *s, int c)
68
- {
69
- char tmp = (char) c;
70
-
71
- while ((*s != tmp) && (*s != '\0'))
72
- s++;
73
-
74
- return (*s == tmp) ? (char *) s : (char *) NULL;
75
- }
76
-
77
- /**
78
- *
79
- * @brief Get string length
80
- *
81
- * @return number of bytes in string <s>
82
- */
83
-
84
- size_t strlen(const char *s)
85
- {
86
- size_t n = 0;
87
-
88
- while (*s != '\0') {
89
- s++;
90
- n++;
91
- }
92
-
93
- return n;
94
- }
95
-
96
- /**
97
- *
98
- * @brief Compare two strings
99
- *
100
- * @return negative # if <s1> < <s2>, 0 if <s1> == <s2>, else positive #
101
- */
102
-
103
- int strcmp(const char *s1, const char *s2)
104
- {
105
- while ((*s1 == *s2) && (*s1 != '\0')) {
106
- s1++;
107
- s2++;
108
- }
109
-
110
- return *s1 - *s2;
111
- }
112
-
113
- /**
114
- *
115
- * @brief Compare part of two strings
116
- *
117
- * @return negative # if <s1> < <s2>, 0 if <s1> == <s2>, else positive #
118
- */
119
-
120
- int strncmp(const char *s1, const char *s2, size_t n)
121
- {
122
- while ((n > 0) && (*s1 == *s2) && (*s1 != '\0')) {
123
- s1++;
124
- s2++;
125
- n--;
126
- }
127
-
128
- return (n == 0) ? 0 : (*s1 - *s2);
129
- }
130
-
131
- char *strncat(char *__restrict dest, const char *__restrict src,
132
- size_t n)
133
- {
134
- char *orig_dest = dest;
135
- size_t len = strlen(dest);
136
-
137
- dest += len;
138
- while ((n-- > 0) && (*src != '\0')) {
139
- *dest++ = *src++;
140
- }
141
- *dest = '\0';
142
-
143
- return orig_dest;
144
- }
145
-
146
- /**
147
- *
148
- * @brief Compare two memory areas
149
- *
150
- * @return negative # if <m1> < <m2>, 0 if <m1> == <m2>, else positive #
151
- */
152
- int memcmp(const void *m1, const void *m2, size_t n)
153
- {
154
- const char *c1 = (char *)m1;
155
- const char *c2 = (char *)m2;
156
-
157
- if (!n)
158
- return 0;
159
-
160
- while ((--n > 0) && (*c1 == *c2)) {
161
- c1++;
162
- c2++;
163
- }
164
-
165
- return *c1 - *c2;
166
- }
167
-
168
- /**
169
- *
170
- * @brief Copy bytes in memory with overlapping areas
171
- *
172
- * @return pointer to destination buffer <d>
173
- */
174
-
175
- void *memmove(void *d, const void *s, size_t n)
176
- {
177
- char *dest = (char *)d;
178
- const char *src = (char *)s;
179
-
180
- if ((size_t) ((char *)d - (char *)s) < n) {
181
- /*
182
- * The <src> buffer overlaps with the start of the <dest> buffer.
183
- * Copy backwards to prevent the premature corruption of <src>.
184
- */
185
-
186
- while (n > 0) {
187
- n--;
188
- dest[n] = src[n];
189
- }
190
- } else {
191
- /* It is safe to perform a forward-copy */
192
- while (n > 0) {
193
- *dest = *src;
194
- dest++;
195
- src++;
196
- n--;
197
- }
198
- }
199
-
200
- return d;
201
- }
202
-
203
- /**
204
- *
205
- * @brief Copy bytes in memory
206
- *
207
- * @return pointer to start of destination buffer
208
- */
209
-
210
- void *memcpy(void *__restrict d, const void *__restrict s, size_t n)
211
- {
212
- /* attempt word-sized copying only if buffers have identical alignment */
213
-
214
- unsigned char *d_byte = (unsigned char *)d;
215
- const unsigned char *s_byte = (const unsigned char *)s;
216
-
217
- if ((((unsigned long)d ^ (unsigned long)s_byte) & 0x3) == 0) {
218
-
219
- /* do byte-sized copying until word-aligned or finished */
220
-
221
- while (((unsigned long)d_byte) & 0x3) {
222
- if (n == 0) {
223
- return d;
224
- }
225
- *(d_byte++) = *(s_byte++);
226
- n--;
227
- };
228
-
229
- /* do word-sized copying as long as possible */
230
-
231
- unsigned int *d_word = (unsigned int *)d_byte;
232
- const unsigned int *s_word = (const unsigned int *)s_byte;
233
-
234
- while (n >= sizeof(unsigned int)) {
235
- *(d_word++) = *(s_word++);
236
- n -= sizeof(unsigned int);
237
- }
238
-
239
- d_byte = (unsigned char *)d_word;
240
- s_byte = (unsigned char *)s_word;
241
- }
242
-
243
- /* do byte-sized copying until finished */
244
-
245
- while (n > 0) {
246
- *(d_byte++) = *(s_byte++);
247
- n--;
248
- }
249
-
250
- return d;
251
- }
252
-
253
- /**
254
- *
255
- * @brief Set bytes in memory
256
- *
257
- * @return pointer to start of buffer
258
- */
259
-
260
- void *memset(void *buf, int c, size_t n)
261
- {
262
- /* do byte-sized initialization until word-aligned or finished */
263
-
264
- unsigned char *d_byte = (unsigned char *)buf;
265
- unsigned char c_byte = (unsigned char)c;
266
-
267
- while (((unsigned long)d_byte) & 0x3) {
268
- if (n == 0) {
269
- return buf;
270
- }
271
- *(d_byte++) = c_byte;
272
- n--;
273
- };
274
-
275
- /* do word-sized initialization as long as possible */
276
-
277
- unsigned int *d_word = (unsigned int *)d_byte;
278
- unsigned int c_word = (unsigned int)(unsigned char)c;
279
-
280
- c_word |= c_word << 8;
281
- c_word |= c_word << 16;
282
-
283
- while (n >= sizeof(unsigned int)) {
284
- *(d_word++) = c_word;
285
- n -= sizeof(unsigned int);
286
- }
287
-
288
- /* do byte-sized initialization until finished */
289
-
290
- d_byte = (unsigned char *)d_word;
291
-
292
- while (n > 0) {
293
- *(d_byte++) = c_byte;
294
- n--;
295
- }
296
-
297
- return buf;
298
- }
299
-
300
- /**
301
- *
302
- * @brief Scan byte in memory
303
- *
304
- * @return pointer to start of found byte
305
- */
306
-
307
- void *memchr(const void *s, int c, size_t n)
308
- {
309
- if (n != 0) {
310
- const unsigned char *p = (const unsigned char *)s;
311
-
312
- do {
313
- if (*p++ == c) {
314
- return ((void *)(p - 1));
315
- }
316
-
317
- } while (--n != 0);
318
- }
319
-
320
- return NULL;
321
- }
322
-
323
- // Source: https://github.com/intel/zephyr/blob/master/lib/libc/minimal/source/string/strstr.c
324
- /*-
325
- * Copyright (c) 1990, 1993
326
- * The Regents of the University of California. All rights reserved.
327
- *
328
- * This code is derived from software contributed to Berkeley by
329
- * Chris Torek.
330
- *
331
- * Redistribution and use in source and binary forms, with or without
332
- * modification, are permitted provided that the following conditions
333
- * are met:
334
- * 1. Redistributions of source code must retain the above copyright
335
- * notice, this list of conditions and the following disclaimer.
336
- * 2. Redistributions in binary form must reproduce the above copyright
337
- * notice, this list of conditions and the following disclaimer in the
338
- * documentation and/or other materials provided with the distribution.
339
- * 3. All advertising materials mentioning features or use of this software
340
- * must display the following acknowledgment:
341
- * This product includes software developed by the University of
342
- * California, Berkeley and its contributors.
343
- * 4. Neither the name of the University nor the names of its contributors
344
- * may be used to endorse or promote products derived from this software
345
- * without specific prior written permission.
346
- *
347
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
348
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
349
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
350
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
351
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
352
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
353
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
354
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
355
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
356
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
357
- * SUCH DAMAGE.
358
- */
359
-
360
- /*
361
- * Find the first occurrence of find in s.
362
- */
363
- char *strstr(const char *s, const char *find)
364
- {
365
- char c, sc;
366
- size_t len;
367
-
368
- c = *find++;
369
- if (c != 0) {
370
- len = strlen(find);
371
- do {
372
- do {
373
- sc = *s++;
374
- if (sc == 0)
375
- return (char *)NULL;
376
- } while (sc != c);
377
- } while (strncmp(s, find, len) != 0);
378
- s--;
379
- }
380
- return (char *)s;
381
- }
package/subset/build.sh DELETED
@@ -1,48 +0,0 @@
1
- #!/bin/bash
2
-
3
- (cd ..; [ -d harfbuzz/src ] || git clone https://github.com/harfbuzz/harfbuzz)
4
- (cd ../harfbuzz; git checkout 3.0.0)
5
-
6
- clang \
7
- -I../libc/include -I. -O3 \
8
- -fno-exceptions -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden \
9
- --target=wasm32 \
10
- -nostdlib -nostdinc \
11
- -flto \
12
- -DHB_TINY -DHB_USE_INTERNAL_QSORT -DHAVE_CONFIG_OVERRIDE_H \
13
- -Wl,--no-entry \
14
- -Wl,--strip-all \
15
- -Wl,--lto-O3 \
16
- -Wl,--gc-sections \
17
- -Wl,--export=malloc \
18
- -Wl,--export=hb_blob_create \
19
- -Wl,--export=hb_face_create \
20
- -Wl,--export=hb_set_create \
21
- -Wl,--export=hb_set_add \
22
- -Wl,--export=hb_set_del \
23
- -Wl,--export=hb_set_destroy \
24
- -Wl,--export=hb_set_union \
25
- -Wl,--export=hb_set_clear \
26
- -Wl,--export=hb_set_invert \
27
- -Wl,--export=hb_face_reference_blob \
28
- -Wl,--export=hb_blob_get_data \
29
- -Wl,--export=hb_blob_get_length \
30
- -Wl,--export=hb_blob_destroy \
31
- -Wl,--export=hb_face_get_empty \
32
- -Wl,--export=hb_face_destroy \
33
- -Wl,--export=hb_subset_input_create_or_fail \
34
- -Wl,--export=hb_subset_input_reference \
35
- -Wl,--export=hb_subset_input_destroy \
36
- -Wl,--export=hb_subset_input_set_user_data \
37
- -Wl,--export=hb_subset_input_get_user_data \
38
- -Wl,--export=hb_subset_input_unicode_set \
39
- -Wl,--export=hb_subset_input_glyph_set \
40
- -Wl,--export=hb_subset_input_set \
41
- -Wl,--export=hb_subset_input_get_flags \
42
- -Wl,--export=hb_subset_input_set_flags \
43
- -Wl,--export=hb_subset_or_fail \
44
- -Wl,--export=free \
45
- -Wl,--export=__heap_base \
46
- ../libc/malloc.cc ../libc/zephyr-string.c ../libc/main.c ../harfbuzz/src/harfbuzz.cc \
47
- ../harfbuzz/src/hb-subset*.cc \
48
- -o hb-subset.wasm
Binary file
package/subset/test.cc DELETED
@@ -1,50 +0,0 @@
1
- // clang test.cc -o test -I ../harfbuzz/src/ -fno-rtti -fno-exceptions -lm && ./test
2
- #include <stdio.h>
3
- #include <stdlib.h>
4
-
5
- #include <harfbuzz.cc>
6
- #include <hb-subset.cc>
7
- #include <hb-subset-cff1.cc>
8
- #include <hb-subset-cff2.cc>
9
- #include <hb-subset-cff-common.cc>
10
- #include <hb-subset-input.cc>
11
- #include <hb-subset-plan.cc>
12
-
13
- int main() {
14
- hb_blob_t *blob = hb_blob_create_from_file ("roboto-black.ttf");
15
- hb_face_t *face = hb_face_create (blob, 0/*this is ttcIndex*/);
16
- hb_blob_destroy (blob); /* face keeps a reference of to it so you can destroy it here */
17
-
18
- /* Add your glyph indices here and subset */
19
- hb_set_t *glyphs = hb_set_create ();
20
- hb_set_add (glyphs, 'a');
21
- hb_set_add (glyphs, 'b');
22
- hb_set_add (glyphs, 'c');
23
-
24
- hb_subset_input_t *input = hb_subset_input_create_or_fail ();
25
- hb_set_t *input_glyphs = hb_subset_input_unicode_set (input);
26
- hb_set_union (input_glyphs, glyphs);
27
- hb_set_destroy (glyphs);
28
- //hb_subset_input_set_drop_hints (input, true);
29
- hb_face_t *subset = hb_subset (face, input);
30
-
31
- /* Clean up */
32
- hb_subset_input_destroy (input);
33
-
34
- /* Get result blob */
35
- hb_blob_t *result = hb_face_reference_blob (subset);
36
- unsigned int length = hb_blob_get_length (result);
37
- const char *data = hb_blob_get_data (result, 0);
38
-
39
- /* Write. If you like! */
40
- FILE *f = fopen ("roboto-black-subset-c.ttf", "wb");
41
- fwrite (data, 1, length, f);
42
- fclose (f);
43
-
44
- /* Clean up */
45
- hb_blob_destroy (result);
46
- hb_face_destroy (subset);
47
- hb_face_destroy (face);
48
-
49
- return 0;
50
- }