Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/harfbuzz/src/hb-static.cc @ 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 © 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): Behdad Esfahbod | |
| 25 */ | |
| 26 | |
| 27 #include "hb.hh" | |
| 28 | |
| 29 #include "hb-open-type.hh" | |
| 30 #include "hb-face.hh" | |
| 31 | |
| 32 #include "hb-aat-layout-common.hh" | |
| 33 #include "hb-aat-layout-feat-table.hh" | |
| 34 #include "hb-ot-layout-common.hh" | |
| 35 #include "hb-ot-cmap-table.hh" | |
| 36 #include "hb-ot-color-colr-table.hh" | |
| 37 #include "hb-ot-glyf-table.hh" | |
| 38 #include "hb-ot-head-table.hh" | |
| 39 #include "hb-ot-maxp-table.hh" | |
| 40 | |
| 41 #ifndef HB_NO_VISIBILITY | |
| 42 #include "hb-ot-name-language-static.hh" | |
| 43 | |
| 44 uint64_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (uint64_t) - 1) / sizeof (uint64_t)] = {}; | |
| 45 /*thread_local*/ uint64_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (uint64_t) - 1) / sizeof (uint64_t)] = {}; | |
| 46 | |
| 47 DEFINE_NULL_NAMESPACE_BYTES (OT, Index) = {0xFF,0xFF}; | |
| 48 DEFINE_NULL_NAMESPACE_BYTES (OT, VarIdx) = {0xFF,0xFF,0xFF,0xFF}; | |
| 49 DEFINE_NULL_NAMESPACE_BYTES (OT, LangSys) = {0x00,0x00, 0xFF,0xFF, 0x00,0x00}; | |
| 50 DEFINE_NULL_NAMESPACE_BYTES (OT, RangeRecord) = {0x01}; | |
| 51 DEFINE_NULL_NAMESPACE_BYTES (OT, ClipRecord) = {0x01}; | |
| 52 DEFINE_NULL_NAMESPACE_BYTES (OT, CmapSubtableLongGroup) = {0x00,0x00,0x00,0x01, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00}; | |
| 53 DEFINE_NULL_NAMESPACE_BYTES (AAT, SettingName) = {0xFF,0xFF, 0xFF,0xFF}; | |
| 54 DEFINE_NULL_NAMESPACE_BYTES (AAT, Lookup) = {0xFF,0xFF}; | |
| 55 | |
| 56 | |
| 57 /* hb_map_t */ | |
| 58 | |
| 59 const hb_codepoint_t minus_1 = -1; | |
| 60 | |
| 61 /* hb_face_t */ | |
| 62 | |
| 63 #ifndef HB_NO_BEYOND_64K | |
| 64 static inline unsigned | |
| 65 load_num_glyphs_from_loca (const hb_face_t *face) | |
| 66 { | |
| 67 unsigned ret = 0; | |
| 68 | |
| 69 unsigned indexToLocFormat = face->table.head->indexToLocFormat; | |
| 70 | |
| 71 if (indexToLocFormat <= 1) | |
| 72 { | |
| 73 bool short_offset = 0 == indexToLocFormat; | |
| 74 hb_blob_t *loca_blob = face->table.loca.get_blob (); | |
| 75 ret = hb_max (1u, loca_blob->length / (short_offset ? 2 : 4)) - 1; | |
| 76 } | |
| 77 | |
| 78 return ret; | |
| 79 } | |
| 80 #endif | |
| 81 | |
| 82 static inline unsigned | |
| 83 load_num_glyphs_from_maxp (const hb_face_t *face) | |
| 84 { | |
| 85 return face->table.maxp->get_num_glyphs (); | |
| 86 } | |
| 87 | |
| 88 unsigned int | |
| 89 hb_face_t::load_num_glyphs () const | |
| 90 { | |
| 91 unsigned ret = 0; | |
| 92 | |
| 93 #ifndef HB_NO_BEYOND_64K | |
| 94 ret = hb_max (ret, load_num_glyphs_from_loca (this)); | |
| 95 #endif | |
| 96 | |
| 97 ret = hb_max (ret, load_num_glyphs_from_maxp (this)); | |
| 98 | |
| 99 num_glyphs = ret; | |
| 100 return ret; | |
| 101 } | |
| 102 | |
| 103 unsigned int | |
| 104 hb_face_t::load_upem () const | |
| 105 { | |
| 106 unsigned int ret = table.head->get_upem (); | |
| 107 upem = ret; | |
| 108 return ret; | |
| 109 } | |
| 110 | |
| 111 | |
| 112 /* hb_user_data_array_t */ | |
| 113 | |
| 114 bool | |
| 115 hb_user_data_array_t::set (hb_user_data_key_t *key, | |
| 116 void * data, | |
| 117 hb_destroy_func_t destroy, | |
| 118 hb_bool_t replace) | |
| 119 { | |
| 120 if (!key) | |
| 121 return false; | |
| 122 | |
| 123 if (replace) { | |
| 124 if (!data && !destroy) { | |
| 125 items.remove (key, lock); | |
| 126 return true; | |
| 127 } | |
| 128 } | |
| 129 hb_user_data_item_t item = {key, data, destroy}; | |
| 130 bool ret = !!items.replace_or_insert (item, lock, (bool) replace); | |
| 131 | |
| 132 return ret; | |
| 133 } | |
| 134 | |
| 135 void * | |
| 136 hb_user_data_array_t::get (hb_user_data_key_t *key) | |
| 137 { | |
| 138 hb_user_data_item_t item = {nullptr, nullptr, nullptr}; | |
| 139 | |
| 140 return items.find (key, &item, lock) ? item.data : nullptr; | |
| 141 } | |
| 142 | |
| 143 | |
| 144 #endif |
