/src/harfbuzz/src/hb-static.cc
Line | Count | Source (jump to first uncovered line) |
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-cff-interp-common.hh" |
35 | | #include "hb-ot-layout-common.hh" |
36 | | #include "hb-ot-cmap-table.hh" |
37 | | #include "OT/Color/COLR/COLR.hh" |
38 | | #include "hb-ot-glyf-table.hh" |
39 | | #include "hb-ot-head-table.hh" |
40 | | #include "hb-ot-hmtx-table.hh" |
41 | | #include "hb-ot-maxp-table.hh" |
42 | | |
43 | | #ifndef HB_NO_VISIBILITY |
44 | | |
45 | | #include "hb-ot-name-language-static.hh" |
46 | | |
47 | | uint64_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (uint64_t) - 1) / sizeof (uint64_t)] = {}; |
48 | | /*thread_local*/ uint64_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (uint64_t) - 1) / sizeof (uint64_t)] = {}; |
49 | | |
50 | | DEFINE_NULL_NAMESPACE_BYTES (OT, Index) = {0xFF,0xFF}; |
51 | | DEFINE_NULL_NAMESPACE_BYTES (OT, VarIdx) = {0xFF,0xFF,0xFF,0xFF}; |
52 | | DEFINE_NULL_NAMESPACE_BYTES (OT, LangSys) = {0x00,0x00, 0xFF,0xFF, 0x00,0x00}; |
53 | | DEFINE_NULL_NAMESPACE_BYTES (OT, RangeRecord) = {0x01}; |
54 | | DEFINE_NULL_NAMESPACE_BYTES (OT, ClipRecord) = {0x01}; |
55 | | DEFINE_NULL_NAMESPACE_BYTES (OT, CmapSubtableLongGroup) = {0x00,0x00,0x00,0x01, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00}; |
56 | | DEFINE_NULL_NAMESPACE_BYTES (AAT, SettingName) = {0xFF,0xFF, 0xFF,0xFF}; |
57 | | DEFINE_NULL_NAMESPACE_BYTES (AAT, Lookup) = {0xFF,0xFF}; |
58 | | |
59 | | |
60 | | /* hb_map_t */ |
61 | | |
62 | | const hb_codepoint_t minus_1 = -1; |
63 | | static const unsigned char static_endchar_str[] = {OpCode_endchar}; |
64 | | const unsigned char *endchar_str = static_endchar_str; |
65 | | |
66 | | /* hb_face_t */ |
67 | | |
68 | | #ifndef HB_NO_BEYOND_64K |
69 | | static inline unsigned |
70 | | load_num_glyphs_from_loca (const hb_face_t *face) |
71 | | { |
72 | | unsigned ret = 0; |
73 | | |
74 | | unsigned indexToLocFormat = face->table.head->indexToLocFormat; |
75 | | |
76 | | if (indexToLocFormat <= 1) |
77 | | { |
78 | | bool short_offset = 0 == indexToLocFormat; |
79 | | hb_blob_t *loca_blob = face->table.loca.get_blob (); |
80 | | ret = hb_max (1u, loca_blob->length / (short_offset ? 2 : 4)) - 1; |
81 | | } |
82 | | |
83 | | return ret; |
84 | | } |
85 | | #endif |
86 | | |
87 | | static inline unsigned |
88 | | load_num_glyphs_from_maxp (const hb_face_t *face) |
89 | 2.30k | { |
90 | 2.30k | return face->table.maxp->get_num_glyphs (); |
91 | 2.30k | } |
92 | | |
93 | | unsigned int |
94 | | hb_face_t::load_num_glyphs () const |
95 | 2.30k | { |
96 | 2.30k | unsigned ret = 0; |
97 | | |
98 | | #ifndef HB_NO_BEYOND_64K |
99 | | ret = hb_max (ret, load_num_glyphs_from_loca (this)); |
100 | | #endif |
101 | | |
102 | 2.30k | ret = hb_max (ret, load_num_glyphs_from_maxp (this)); |
103 | | |
104 | 2.30k | num_glyphs = ret; |
105 | 2.30k | return ret; |
106 | 2.30k | } |
107 | | |
108 | | unsigned int |
109 | | hb_face_t::load_upem () const |
110 | 0 | { |
111 | 0 | unsigned int ret = table.head->get_upem (); |
112 | 0 | upem = ret; |
113 | 0 | return ret; |
114 | 0 | } |
115 | | |
116 | | |
117 | | #ifndef HB_NO_VAR |
118 | | bool |
119 | | _glyf_get_leading_bearing_with_var_unscaled (hb_font_t *font, hb_codepoint_t glyph, bool is_vertical, |
120 | | int *lsb) |
121 | 0 | { |
122 | 0 | return font->face->table.glyf->get_leading_bearing_with_var_unscaled (font, glyph, is_vertical, lsb); |
123 | 0 | } |
124 | | |
125 | | unsigned |
126 | | _glyf_get_advance_with_var_unscaled (hb_font_t *font, hb_codepoint_t glyph, bool is_vertical) |
127 | 0 | { |
128 | 0 | return font->face->table.glyf->get_advance_with_var_unscaled (font, glyph, is_vertical); |
129 | 0 | } |
130 | | #endif |
131 | | |
132 | | bool |
133 | | _glyf_get_leading_bearing_without_var_unscaled (hb_face_t *face, hb_codepoint_t gid, bool is_vertical, int *lsb) |
134 | 0 | { |
135 | 0 | return face->table.glyf->get_leading_bearing_without_var_unscaled (gid, is_vertical, lsb); |
136 | 0 | } |
137 | | |
138 | | |
139 | | #endif |