Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/harfbuzz/src/hb-subset-accelerator.hh @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /* | |
| 2 * Copyright © 2022 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 | |
| 25 */ | |
| 26 | |
| 27 #ifndef HB_SUBSET_ACCELERATOR_HH | |
| 28 #define HB_SUBSET_ACCELERATOR_HH | |
| 29 | |
| 30 | |
| 31 #include "hb.hh" | |
| 32 | |
| 33 #include "hb-map.hh" | |
| 34 #include "hb-multimap.hh" | |
| 35 #include "hb-set.hh" | |
| 36 | |
| 37 extern HB_INTERNAL hb_user_data_key_t _hb_subset_accelerator_user_data_key; | |
| 38 | |
| 39 namespace CFF { | |
| 40 struct cff_subset_accelerator_t; | |
| 41 } | |
| 42 | |
| 43 namespace OT { | |
| 44 struct SubtableUnicodesCache; | |
| 45 }; | |
| 46 | |
| 47 struct hb_subset_accelerator_t | |
| 48 { | |
| 49 static hb_user_data_key_t* user_data_key() | |
| 50 { | |
| 51 return &_hb_subset_accelerator_user_data_key; | |
| 52 } | |
| 53 | |
| 54 static hb_subset_accelerator_t* create(const hb_map_t& unicode_to_gid_, | |
| 55 const hb_multimap_t gid_to_unicodes_, | |
| 56 const hb_set_t& unicodes_, | |
| 57 bool has_seac_) { | |
| 58 hb_subset_accelerator_t* accel = | |
| 59 (hb_subset_accelerator_t*) hb_malloc (sizeof(hb_subset_accelerator_t)); | |
| 60 new (accel) hb_subset_accelerator_t (unicode_to_gid_, gid_to_unicodes_, unicodes_); | |
| 61 accel->has_seac = has_seac_; | |
| 62 return accel; | |
| 63 } | |
| 64 | |
| 65 static void destroy(void* value) { | |
| 66 if (!value) return; | |
| 67 | |
| 68 hb_subset_accelerator_t* accel = (hb_subset_accelerator_t*) value; | |
| 69 | |
| 70 if (accel->cff_accelerator && accel->destroy_cff_accelerator) | |
| 71 accel->destroy_cff_accelerator ((void*) accel->cff_accelerator); | |
| 72 | |
| 73 if (accel->cmap_cache && accel->destroy_cmap_cache) | |
| 74 accel->destroy_cmap_cache ((void*) accel->cmap_cache); | |
| 75 | |
| 76 accel->~hb_subset_accelerator_t (); | |
| 77 hb_free (accel); | |
| 78 } | |
| 79 | |
| 80 hb_subset_accelerator_t (const hb_map_t& unicode_to_gid_, | |
| 81 const hb_multimap_t& gid_to_unicodes_, | |
| 82 const hb_set_t& unicodes_) | |
| 83 : unicode_to_gid(unicode_to_gid_), gid_to_unicodes (gid_to_unicodes_), unicodes(unicodes_), | |
| 84 cmap_cache(nullptr), destroy_cmap_cache(nullptr), | |
| 85 has_seac(false), cff_accelerator(nullptr), destroy_cff_accelerator(nullptr) | |
| 86 { sanitized_table_cache_lock.init (); } | |
| 87 | |
| 88 ~hb_subset_accelerator_t () | |
| 89 { sanitized_table_cache_lock.fini (); } | |
| 90 | |
| 91 // Generic | |
| 92 | |
| 93 mutable hb_mutex_t sanitized_table_cache_lock; | |
| 94 mutable hb_hashmap_t<hb_tag_t, hb::unique_ptr<hb_blob_t>> sanitized_table_cache; | |
| 95 | |
| 96 const hb_map_t unicode_to_gid; | |
| 97 const hb_multimap_t gid_to_unicodes; | |
| 98 const hb_set_t unicodes; | |
| 99 | |
| 100 // cmap | |
| 101 const OT::SubtableUnicodesCache* cmap_cache; | |
| 102 hb_destroy_func_t destroy_cmap_cache; | |
| 103 | |
| 104 // CFF | |
| 105 bool has_seac; | |
| 106 const CFF::cff_subset_accelerator_t* cff_accelerator; | |
| 107 hb_destroy_func_t destroy_cff_accelerator; | |
| 108 | |
| 109 // TODO(garretrieger): cumulative glyf checksum map | |
| 110 | |
| 111 bool in_error () const | |
| 112 { | |
| 113 return unicode_to_gid.in_error () || | |
| 114 gid_to_unicodes.in_error () || | |
| 115 unicodes.in_error () || | |
| 116 sanitized_table_cache.in_error (); | |
| 117 } | |
| 118 }; | |
| 119 | |
| 120 | |
| 121 #endif /* HB_SUBSET_ACCELERATOR_HH */ |
