/work/workdir/UnpackedTarball/harfbuzz/src/hb-ot-fetch.cc
Line | Count | Source |
1 | | /* |
2 | | * Copyright © 2026 Khaled Hosny |
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 | | |
25 | | #include "hb.hh" |
26 | | |
27 | | #ifndef HB_NO_OT_FETCH |
28 | | |
29 | | #include "hb-ot.h" |
30 | | |
31 | | #include "hb-ot-head-table.hh" |
32 | | #include "hb-ot-os2-table.hh" |
33 | | #include "hb-ot-post-table.hh" |
34 | | |
35 | | /** |
36 | | * SECTION:hb-ot-fetch |
37 | | * @title: hb-ot-fetch |
38 | | * @short_description: OpenType bit fields and numbers |
39 | | * @include: hb-ot.h |
40 | | * |
41 | | * Functions for fetching various bit fields and numbers scattered around |
42 | | * OpenType tables. |
43 | | * |
44 | | * These are raw table values, and many of them are legacy or unreliable, but |
45 | | * applications might need them for various legacy reasons. |
46 | | **/ |
47 | | |
48 | | |
49 | | /** |
50 | | * hb_ot_fetch_bits: |
51 | | * @face: #hb_face_t to work upon |
52 | | * @tag: tag of the bit field to fetch |
53 | | * |
54 | | * Fetches a bit field of @face. |
55 | | * |
56 | | * Return value: the bit field, or zero if the font does not have it. |
57 | | * |
58 | | * Since: 14.3.0 |
59 | | **/ |
60 | | uint32_t |
61 | | hb_ot_fetch_bits (hb_face_t *face, |
62 | | hb_ot_bits_tag_t tag) |
63 | 300k | { |
64 | 300k | switch ((unsigned) tag) |
65 | 300k | { |
66 | 0 | case HB_OT_BITS_TAG_FS_TYPE: return face->table.OS2->fsType; |
67 | 150k | case HB_OT_BITS_TAG_FS_SELECTION: return face->table.OS2->fsSelection; |
68 | 0 | case HB_OT_BITS_TAG_MAC_STYLE: return face->table.head->get_mac_style (); |
69 | 150k | case HB_OT_BITS_TAG_IS_FIXED_PITCH: return face->table.post->table->isFixedPitch; |
70 | 7 | case HB_OT_BITS_TAG_UNICODE_RANGE_1: return face->table.OS2->ulUnicodeRange[0]; |
71 | 7 | case HB_OT_BITS_TAG_UNICODE_RANGE_2: return face->table.OS2->ulUnicodeRange[1]; |
72 | 7 | case HB_OT_BITS_TAG_UNICODE_RANGE_3: return face->table.OS2->ulUnicodeRange[2]; |
73 | 7 | case HB_OT_BITS_TAG_UNICODE_RANGE_4: return face->table.OS2->ulUnicodeRange[3]; |
74 | 7 | case HB_OT_BITS_TAG_CODE_PAGE_RANGE_1: return face->table.OS2->v1 ().ulCodePageRange1; |
75 | 7 | case HB_OT_BITS_TAG_CODE_PAGE_RANGE_2: return face->table.OS2->v1 ().ulCodePageRange2; |
76 | 0 | default: return 0; |
77 | 300k | } |
78 | 300k | } |
79 | | |
80 | | /** |
81 | | * hb_ot_fetch_number: |
82 | | * @face: #hb_face_t to work upon |
83 | | * @tag: tag of the number to fetch |
84 | | * |
85 | | * Fetches a number of @face in font units. |
86 | | * |
87 | | * Return value: the number, or zero if the font does not have it. |
88 | | * |
89 | | * Since: 14.3.0 |
90 | | **/ |
91 | | int32_t |
92 | | hb_ot_fetch_number (hb_face_t *face, |
93 | | hb_ot_number_tag_t tag) |
94 | 62.3k | { |
95 | 62.3k | switch ((unsigned) tag) |
96 | 62.3k | { |
97 | 15.5k | case HB_OT_NUMBER_TAG_FONT_X_MIN: return face->table.head->xMin; |
98 | 15.5k | case HB_OT_NUMBER_TAG_FONT_Y_MIN: return face->table.head->yMin; |
99 | 15.5k | case HB_OT_NUMBER_TAG_FONT_X_MAX: return face->table.head->xMax; |
100 | 15.5k | case HB_OT_NUMBER_TAG_FONT_Y_MAX: return face->table.head->yMax; |
101 | 0 | default: return 0; |
102 | 62.3k | } |
103 | 62.3k | } |
104 | | |
105 | | #endif |