| 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 | **/ |
| 37 | hb_subset_input_t * |
| 38 | hb_subset_input_create_or_fail () |
| 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->drop_layout = true; |
| 48 | |
| 49 | return input; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * hb_subset_input_reference: (skip) |
| 54 | * @subset_input: a subset_input. |
| 55 | * |
| 56 | * |
| 57 | * |
| 58 | * Return value: |
| 59 | * |
| 60 | * Since: 1.8.0 |
| 61 | **/ |
| 62 | hb_subset_input_t * |
| 63 | hb_subset_input_reference (hb_subset_input_t *subset_input) |
| 64 | { |
| 65 | return hb_object_reference (subset_input); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * hb_subset_input_destroy: |
| 70 | * @subset_input: a subset_input. |
| 71 | * |
| 72 | * Since: 1.8.0 |
| 73 | **/ |
| 74 | void |
| 75 | hb_subset_input_destroy (hb_subset_input_t *subset_input) |
| 76 | { |
| 77 | if (!hb_object_destroy (subset_input)) return; |
| 78 | |
| 79 | hb_set_destroy (subset_input->unicodes); |
| 80 | hb_set_destroy (subset_input->glyphs); |
| 81 | |
| 82 | free (subset_input); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * hb_subset_input_unicode_set: |
| 87 | * @subset_input: a subset_input. |
| 88 | * |
| 89 | * Since: 1.8.0 |
| 90 | **/ |
| 91 | HB_EXTERN hb_set_t * |
| 92 | hb_subset_input_unicode_set (hb_subset_input_t *subset_input) |
| 93 | { |
| 94 | return subset_input->unicodes; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * hb_subset_input_glyph_set: |
| 99 | * @subset_input: a subset_input. |
| 100 | * |
| 101 | * Since: 1.8.0 |
| 102 | **/ |
| 103 | HB_EXTERN hb_set_t * |
| 104 | hb_subset_input_glyph_set (hb_subset_input_t *subset_input) |
| 105 | { |
| 106 | return subset_input->glyphs; |
| 107 | } |
| 108 | |
| 109 | HB_EXTERN void |
| 110 | hb_subset_input_set_drop_hints (hb_subset_input_t *subset_input, |
| 111 | hb_bool_t drop_hints) |
| 112 | { |
| 113 | subset_input->drop_hints = drop_hints; |
| 114 | } |
| 115 | |
| 116 | HB_EXTERN hb_bool_t |
| 117 | hb_subset_input_get_drop_hints (hb_subset_input_t *subset_input) |
| 118 | { |
| 119 | return subset_input->drop_hints; |
| 120 | } |
| 121 | |
| 122 | HB_EXTERN void |
| 123 | hb_subset_input_set_drop_layout (hb_subset_input_t *subset_input, |
| 124 | hb_bool_t drop_layout) |
| 125 | { |
| 126 | subset_input->drop_layout = drop_layout; |
| 127 | } |
| 128 | |
| 129 | HB_EXTERN hb_bool_t |
| 130 | hb_subset_input_get_drop_layout (hb_subset_input_t *subset_input) |
| 131 | { |
| 132 | return subset_input->drop_layout; |
| 133 | } |
| 134 | |
| 135 | HB_EXTERN void |
| 136 | hb_subset_input_set_desubroutinize (hb_subset_input_t *subset_input, |
| 137 | hb_bool_t desubroutinize) |
| 138 | { |
| 139 | subset_input->desubroutinize = desubroutinize; |
| 140 | } |
| 141 | |
| 142 | HB_EXTERN hb_bool_t |
| 143 | hb_subset_input_get_desubroutinize (hb_subset_input_t *subset_input) |
| 144 | { |
| 145 | return subset_input->desubroutinize; |
| 146 | } |
| 147 | |