Behdad Esfahbod | fd92a3d | 2008-01-24 03:11:09 -0500 | [diff] [blame] | 1 | /* |
Behdad Esfahbod | 2409d5f | 2011-04-21 17:14:28 -0400 | [diff] [blame] | 2 | * Copyright © 1998-2004 David Turner and Werner Lemberg |
| 3 | * Copyright © 2006 Behdad Esfahbod |
| 4 | * Copyright © 2007,2008,2009 Red Hat, Inc. |
Behdad Esfahbod | 45f3d98 | 2013-05-03 17:49:44 -0400 | [diff] [blame] | 5 | * Copyright © 2012,2013 Google, Inc. |
Behdad Esfahbod | fd92a3d | 2008-01-24 03:11:09 -0500 | [diff] [blame] | 6 | * |
Behdad Esfahbod | c755cb3 | 2010-04-22 00:11:43 -0400 | [diff] [blame] | 7 | * This is part of HarfBuzz, a text shaping library. |
Behdad Esfahbod | fd92a3d | 2008-01-24 03:11:09 -0500 | [diff] [blame] | 8 | * |
| 9 | * Permission is hereby granted, without written agreement and without |
| 10 | * license or royalty fees, to use, copy, modify, and distribute this |
| 11 | * software and its documentation for any purpose, provided that the |
| 12 | * above copyright notice and the following two paragraphs appear in |
| 13 | * all copies of this software. |
| 14 | * |
| 15 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
| 16 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
| 17 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
| 18 | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
| 19 | * DAMAGE. |
| 20 | * |
| 21 | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
| 22 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 23 | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
| 24 | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
| 25 | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 26 | * |
| 27 | * Red Hat Author(s): Behdad Esfahbod |
Behdad Esfahbod | f860366 | 2012-07-30 02:38:39 -0400 | [diff] [blame] | 28 | * Google Author(s): Behdad Esfahbod |
Behdad Esfahbod | fd92a3d | 2008-01-24 03:11:09 -0500 | [diff] [blame] | 29 | */ |
| 30 | |
Behdad Esfahbod | bb4bbe6 | 2019-06-26 13:29:58 -0700 | [diff] [blame] | 31 | #include "hb.hh" |
| 32 | |
| 33 | #ifndef HB_NO_OT_LAYOUT |
| 34 | |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 35 | #include "hb-open-type.hh" |
| 36 | #include "hb-ot-layout.hh" |
Behdad Esfahbod | b929100 | 2018-08-26 01:15:47 -0700 | [diff] [blame] | 37 | #include "hb-ot-face.hh" |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 38 | #include "hb-ot-map.hh" |
| 39 | #include "hb-map.hh" |
Ebrahim Byagowi | 5b9c234 | 2018-02-27 22:56:17 +0330 | [diff] [blame] | 40 | |
Behdad Esfahbod | 574d888 | 2018-11-25 16:51:22 -0500 | [diff] [blame] | 41 | #include "hb-ot-kern-table.hh" |
Ebrahim Byagowi | 8f80e53 | 2018-12-05 13:51:14 +0330 | [diff] [blame] | 42 | #include "hb-ot-gasp-table.hh" // Just so we compile it; unused otherwise. |
Behdad Esfahbod | 7a750ac | 2011-08-17 14:19:59 +0200 | [diff] [blame] | 43 | #include "hb-ot-layout-gdef-table.hh" |
| 44 | #include "hb-ot-layout-gsub-table.hh" |
| 45 | #include "hb-ot-layout-gpos-table.hh" |
Ebrahim Byagowi | 8f80e53 | 2018-12-05 13:51:14 +0330 | [diff] [blame] | 46 | #include "hb-ot-layout-base-table.hh" // Just so we compile it; unused otherwise. |
| 47 | #include "hb-ot-layout-jstf-table.hh" // Just so we compile it; unused otherwise. |
Behdad Esfahbod | 203dc44 | 2018-05-03 21:03:27 -0400 | [diff] [blame] | 48 | #include "hb-ot-name-table.hh" |
Behdad Esfahbod | 574d888 | 2018-11-25 16:51:22 -0500 | [diff] [blame] | 49 | #include "hb-ot-os2-table.hh" |
Behdad Esfahbod | d2c9681 | 2013-05-02 18:18:24 -0400 | [diff] [blame] | 50 | |
Ebrahim Byagowi | b986fea | 2018-11-05 12:31:58 +0330 | [diff] [blame] | 51 | #include "hb-aat-layout-lcar-table.hh" |
Behdad Esfahbod | 574d888 | 2018-11-25 16:51:22 -0500 | [diff] [blame] | 52 | #include "hb-aat-layout-morx-table.hh" |
Ebrahim Byagowi | b986fea | 2018-11-05 12:31:58 +0330 | [diff] [blame] | 53 | |
Behdad Esfahbod | aff831e | 2008-01-24 06:03:45 -0500 | [diff] [blame] | 54 | |
Behdad Esfahbod | 80d9a42 | 2018-10-27 04:58:32 -0700 | [diff] [blame] | 55 | /** |
| 56 | * SECTION:hb-ot-layout |
| 57 | * @title: hb-ot-layout |
| 58 | * @short_description: OpenType Layout |
| 59 | * @include: hb-ot.h |
| 60 | * |
| 61 | * Functions for querying OpenType Layout features in the font face. |
| 62 | **/ |
| 63 | |
| 64 | |
Behdad Esfahbod | 590d55c | 2008-01-24 19:13:50 -0500 | [diff] [blame] | 65 | /* |
Behdad Esfahbod | a519588 | 2018-10-08 23:57:45 -0400 | [diff] [blame] | 66 | * kern |
| 67 | */ |
| 68 | |
Behdad Esfahbod | 588697a | 2019-06-19 16:24:51 -0700 | [diff] [blame] | 69 | #ifndef HB_NO_OT_KERN |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 70 | /** |
| 71 | * hb_ot_layout_has_kerning: |
| 72 | * @face: The #hb_face_t to work on |
| 73 | * |
Nathan Willis | d3178aa | 2019-03-17 14:27:27 +0000 | [diff] [blame] | 74 | * Tests whether a face includes any kerning data in the 'kern' table. |
| 75 | * Does NOT test for kerning lookups in the GPOS table. |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 76 | * |
| 77 | * Return value: true if data found, false otherwise |
| 78 | * |
| 79 | **/ |
Behdad Esfahbod | 385f78b | 2018-11-07 17:19:21 -0500 | [diff] [blame] | 80 | bool |
Behdad Esfahbod | a519588 | 2018-10-08 23:57:45 -0400 | [diff] [blame] | 81 | hb_ot_layout_has_kerning (hb_face_t *face) |
| 82 | { |
Behdad Esfahbod | a35c92c | 2018-11-05 22:58:43 -0500 | [diff] [blame] | 83 | return face->table.kern->has_data (); |
Behdad Esfahbod | a519588 | 2018-10-08 23:57:45 -0400 | [diff] [blame] | 84 | } |
| 85 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 86 | /** |
| 87 | * hb_ot_layout_has_machine_kerning: |
| 88 | * @face: The #hb_face_t to work on |
| 89 | * |
Nathan Willis | d3178aa | 2019-03-17 14:27:27 +0000 | [diff] [blame] | 90 | * Tests whether a face includes any state-machine kerning in the 'kern' table. |
| 91 | * Does NOT examine the GPOS table. |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 92 | * |
| 93 | * Return value: true if data found, false otherwise |
| 94 | * |
| 95 | **/ |
Behdad Esfahbod | 385f78b | 2018-11-07 17:19:21 -0500 | [diff] [blame] | 96 | bool |
Behdad Esfahbod | 7489622 | 2018-11-23 11:10:17 -0500 | [diff] [blame] | 97 | hb_ot_layout_has_machine_kerning (hb_face_t *face) |
| 98 | { |
| 99 | return face->table.kern->has_state_machine (); |
| 100 | } |
| 101 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 102 | /** |
| 103 | * hb_ot_layout_has_cross_kerning: |
| 104 | * @face: The #hb_face_t to work on |
| 105 | * |
| 106 | * Tests whether a face has any cross-stream kerning (i.e., kerns |
| 107 | * that make adjustments perpendicular to the direction of the text |
| 108 | * flow: Y adjustments in horizontal text or X adjustments in |
Nathan Willis | d3178aa | 2019-03-17 14:27:27 +0000 | [diff] [blame] | 109 | * vertical text) in the 'kern' table. |
| 110 | * |
| 111 | * Does NOT examine the GPOS table. |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 112 | * |
| 113 | * Return value: true is data found, false otherwise |
| 114 | * |
| 115 | **/ |
Behdad Esfahbod | 7489622 | 2018-11-23 11:10:17 -0500 | [diff] [blame] | 116 | bool |
Behdad Esfahbod | ca23567 | 2018-11-07 16:19:51 -0500 | [diff] [blame] | 117 | hb_ot_layout_has_cross_kerning (hb_face_t *face) |
| 118 | { |
| 119 | return face->table.kern->has_cross_stream (); |
| 120 | } |
| 121 | |
Behdad Esfahbod | a519588 | 2018-10-08 23:57:45 -0400 | [diff] [blame] | 122 | void |
Behdad Esfahbod | c221dc0 | 2018-11-14 14:49:34 -0500 | [diff] [blame] | 123 | hb_ot_layout_kern (const hb_ot_shape_plan_t *plan, |
Behdad Esfahbod | 095f5ad | 2018-11-02 13:23:54 -0400 | [diff] [blame] | 124 | hb_font_t *font, |
| 125 | hb_buffer_t *buffer) |
Behdad Esfahbod | a519588 | 2018-10-08 23:57:45 -0400 | [diff] [blame] | 126 | { |
Behdad Esfahbod | a35c92c | 2018-11-05 22:58:43 -0500 | [diff] [blame] | 127 | hb_blob_t *blob = font->face->table.kern.get_blob (); |
Behdad Esfahbod | fa3ebf8 | 2018-11-05 23:34:07 -0500 | [diff] [blame] | 128 | const AAT::kern& kern = *blob->as<AAT::kern> (); |
Behdad Esfahbod | 095f5ad | 2018-11-02 13:23:54 -0400 | [diff] [blame] | 129 | |
| 130 | AAT::hb_aat_apply_context_t c (plan, font, buffer, blob); |
| 131 | |
| 132 | kern.apply (&c); |
Behdad Esfahbod | a519588 | 2018-10-08 23:57:45 -0400 | [diff] [blame] | 133 | } |
Behdad Esfahbod | 588697a | 2019-06-19 16:24:51 -0700 | [diff] [blame] | 134 | #endif |
Behdad Esfahbod | a519588 | 2018-10-08 23:57:45 -0400 | [diff] [blame] | 135 | |
| 136 | |
| 137 | /* |
Behdad Esfahbod | 590d55c | 2008-01-24 19:13:50 -0500 | [diff] [blame] | 138 | * GDEF |
| 139 | */ |
| 140 | |
Behdad Esfahbod | 4f21703 | 2018-11-25 15:59:18 -0500 | [diff] [blame] | 141 | bool |
| 142 | OT::GDEF::is_blacklisted (hb_blob_t *blob, |
| 143 | hb_face_t *face) const |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 144 | { |
Behdad Esfahbod | 227d85e | 2019-05-10 23:15:58 -0700 | [diff] [blame] | 145 | #ifdef HB_NO_OT_LAYOUT_BLACKLIST |
Behdad Esfahbod | 9ddbfa0 | 2019-04-12 09:33:25 -0400 | [diff] [blame] | 146 | return false; |
| 147 | #endif |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 148 | /* The ugly business of blacklisting individual fonts' tables happen here! |
| 149 | * See this thread for why we finally had to bend in and do this: |
| 150 | * https://lists.freedesktop.org/archives/harfbuzz/2016-February/005489.html |
| 151 | * |
| 152 | * In certain versions of Times New Roman Italic and Bold Italic, |
| 153 | * ASCII double quotation mark U+0022 has wrong glyph class 3 (mark) |
| 154 | * in GDEF. Many versions of Tahoma have bad GDEF tables that |
| 155 | * incorrectly classify some spacing marks such as certain IPA |
| 156 | * symbols as glyph class 3. So do older versions of Microsoft |
| 157 | * Himalaya, and the version of Cantarell shipped by Ubuntu 16.04. |
| 158 | * |
| 159 | * Nuke the GDEF tables of to avoid unwanted width-zeroing. |
| 160 | * |
| 161 | * See https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 |
| 162 | * https://bugzilla.mozilla.org/show_bug.cgi?id=1279693 |
| 163 | * https://bugzilla.mozilla.org/show_bug.cgi?id=1279875 |
| 164 | */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 165 | switch HB_CODEPOINT_ENCODE3(blob->length, |
| 166 | face->table.GSUB->table.get_length (), |
| 167 | face->table.GPOS->table.get_length ()) |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 168 | { |
| 169 | /* sha1sum:c5ee92f0bca4bfb7d06c4d03e8cf9f9cf75d2e8a Windows 7? timesi.ttf */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 170 | case HB_CODEPOINT_ENCODE3 (442, 2874, 42038): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 171 | /* sha1sum:37fc8c16a0894ab7b749e35579856c73c840867b Windows 7? timesbi.ttf */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 172 | case HB_CODEPOINT_ENCODE3 (430, 2874, 40662): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 173 | /* sha1sum:19fc45110ea6cd3cdd0a5faca256a3797a069a80 Windows 7 timesi.ttf */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 174 | case HB_CODEPOINT_ENCODE3 (442, 2874, 39116): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 175 | /* sha1sum:6d2d3c9ed5b7de87bc84eae0df95ee5232ecde26 Windows 7 timesbi.ttf */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 176 | case HB_CODEPOINT_ENCODE3 (430, 2874, 39374): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 177 | /* sha1sum:8583225a8b49667c077b3525333f84af08c6bcd8 OS X 10.11.3 Times New Roman Italic.ttf */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 178 | case HB_CODEPOINT_ENCODE3 (490, 3046, 41638): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 179 | /* sha1sum:ec0f5a8751845355b7c3271d11f9918a966cb8c9 OS X 10.11.3 Times New Roman Bold Italic.ttf */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 180 | case HB_CODEPOINT_ENCODE3 (478, 3046, 41902): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 181 | /* sha1sum:96eda93f7d33e79962451c6c39a6b51ee893ce8c tahoma.ttf from Windows 8 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 182 | case HB_CODEPOINT_ENCODE3 (898, 12554, 46470): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 183 | /* sha1sum:20928dc06014e0cd120b6fc942d0c3b1a46ac2bc tahomabd.ttf from Windows 8 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 184 | case HB_CODEPOINT_ENCODE3 (910, 12566, 47732): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 185 | /* sha1sum:4f95b7e4878f60fa3a39ca269618dfde9721a79e tahoma.ttf from Windows 8.1 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 186 | case HB_CODEPOINT_ENCODE3 (928, 23298, 59332): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 187 | /* sha1sum:6d400781948517c3c0441ba42acb309584b73033 tahomabd.ttf from Windows 8.1 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 188 | case HB_CODEPOINT_ENCODE3 (940, 23310, 60732): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 189 | /* tahoma.ttf v6.04 from Windows 8.1 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 190 | case HB_CODEPOINT_ENCODE3 (964, 23836, 60072): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 191 | /* tahomabd.ttf v6.04 from Windows 8.1 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 192 | case HB_CODEPOINT_ENCODE3 (976, 23832, 61456): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 193 | /* sha1sum:e55fa2dfe957a9f7ec26be516a0e30b0c925f846 tahoma.ttf from Windows 10 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 194 | case HB_CODEPOINT_ENCODE3 (994, 24474, 60336): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 195 | /* sha1sum:7199385abb4c2cc81c83a151a7599b6368e92343 tahomabd.ttf from Windows 10 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 196 | case HB_CODEPOINT_ENCODE3 (1006, 24470, 61740): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 197 | /* tahoma.ttf v6.91 from Windows 10 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 198 | case HB_CODEPOINT_ENCODE3 (1006, 24576, 61346): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 199 | /* tahomabd.ttf v6.91 from Windows 10 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 200 | case HB_CODEPOINT_ENCODE3 (1018, 24572, 62828): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 201 | /* sha1sum:b9c84d820c49850d3d27ec498be93955b82772b5 tahoma.ttf from Windows 10 AU */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 202 | case HB_CODEPOINT_ENCODE3 (1006, 24576, 61352): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 203 | /* sha1sum:2bdfaab28174bdadd2f3d4200a30a7ae31db79d2 tahomabd.ttf from Windows 10 AU */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 204 | case HB_CODEPOINT_ENCODE3 (1018, 24572, 62834): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 205 | /* sha1sum:b0d36cf5a2fbe746a3dd277bffc6756a820807a7 Tahoma.ttf from Mac OS X 10.9 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 206 | case HB_CODEPOINT_ENCODE3 (832, 7324, 47162): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 207 | /* sha1sum:12fc4538e84d461771b30c18b5eb6bd434e30fba Tahoma Bold.ttf from Mac OS X 10.9 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 208 | case HB_CODEPOINT_ENCODE3 (844, 7302, 45474): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 209 | /* sha1sum:eb8afadd28e9cf963e886b23a30b44ab4fd83acc himalaya.ttf from Windows 7 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 210 | case HB_CODEPOINT_ENCODE3 (180, 13054, 7254): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 211 | /* sha1sum:73da7f025b238a3f737aa1fde22577a6370f77b0 himalaya.ttf from Windows 8 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 212 | case HB_CODEPOINT_ENCODE3 (192, 12638, 7254): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 213 | /* sha1sum:6e80fd1c0b059bbee49272401583160dc1e6a427 himalaya.ttf from Windows 8.1 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 214 | case HB_CODEPOINT_ENCODE3 (192, 12690, 7254): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 215 | /* 8d9267aea9cd2c852ecfb9f12a6e834bfaeafe44 cantarell-fonts-0.0.21/otf/Cantarell-Regular.otf */ |
| 216 | /* 983988ff7b47439ab79aeaf9a45bd4a2c5b9d371 cantarell-fonts-0.0.21/otf/Cantarell-Oblique.otf */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 217 | case HB_CODEPOINT_ENCODE3 (188, 248, 3852): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 218 | /* 2c0c90c6f6087ffbfea76589c93113a9cbb0e75f cantarell-fonts-0.0.21/otf/Cantarell-Bold.otf */ |
| 219 | /* 55461f5b853c6da88069ffcdf7f4dd3f8d7e3e6b cantarell-fonts-0.0.21/otf/Cantarell-Bold-Oblique.otf */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 220 | case HB_CODEPOINT_ENCODE3 (188, 264, 3426): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 221 | /* d125afa82a77a6475ac0e74e7c207914af84b37a padauk-2.80/Padauk.ttf RHEL 7.2 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 222 | case HB_CODEPOINT_ENCODE3 (1058, 47032, 11818): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 223 | /* 0f7b80437227b90a577cc078c0216160ae61b031 padauk-2.80/Padauk-Bold.ttf RHEL 7.2*/ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 224 | case HB_CODEPOINT_ENCODE3 (1046, 47030, 12600): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 225 | /* d3dde9aa0a6b7f8f6a89ef1002e9aaa11b882290 padauk-2.80/Padauk.ttf Ubuntu 16.04 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 226 | case HB_CODEPOINT_ENCODE3 (1058, 71796, 16770): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 227 | /* 5f3c98ccccae8a953be2d122c1b3a77fd805093f padauk-2.80/Padauk-Bold.ttf Ubuntu 16.04 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 228 | case HB_CODEPOINT_ENCODE3 (1046, 71790, 17862): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 229 | /* 6c93b63b64e8b2c93f5e824e78caca555dc887c7 padauk-2.80/Padauk-book.ttf */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 230 | case HB_CODEPOINT_ENCODE3 (1046, 71788, 17112): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 231 | /* d89b1664058359b8ec82e35d3531931125991fb9 padauk-2.80/Padauk-bookbold.ttf */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 232 | case HB_CODEPOINT_ENCODE3 (1058, 71794, 17514): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 233 | /* 824cfd193aaf6234b2b4dc0cf3c6ef576c0d00ef padauk-3.0/Padauk-book.ttf */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 234 | case HB_CODEPOINT_ENCODE3 (1330, 109904, 57938): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 235 | /* 91fcc10cf15e012d27571e075b3b4dfe31754a8a padauk-3.0/Padauk-bookbold.ttf */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 236 | case HB_CODEPOINT_ENCODE3 (1330, 109904, 58972): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 237 | /* sha1sum: c26e41d567ed821bed997e937bc0c41435689e85 Padauk.ttf |
| 238 | * "Padauk Regular" "Version 2.5", see https://crbug.com/681813 */ |
Behdad Esfahbod | 65392b7 | 2019-05-22 16:21:21 -0400 | [diff] [blame] | 239 | case HB_CODEPOINT_ENCODE3 (1004, 59092, 14836): |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 240 | return true; |
Behdad Esfahbod | d8c57e8 | 2018-08-26 09:03:31 -0700 | [diff] [blame] | 241 | } |
| 242 | return false; |
| 243 | } |
| 244 | |
Behdad Esfahbod | c624e18 | 2018-08-26 09:19:20 -0700 | [diff] [blame] | 245 | static void |
| 246 | _hb_ot_layout_set_glyph_props (hb_font_t *font, |
| 247 | hb_buffer_t *buffer) |
| 248 | { |
| 249 | _hb_buffer_assert_gsubgpos_vars (buffer); |
| 250 | |
Behdad Esfahbod | 5e68cec | 2018-11-05 23:23:57 -0500 | [diff] [blame] | 251 | const OT::GDEF &gdef = *font->face->table.GDEF->table; |
Behdad Esfahbod | c624e18 | 2018-08-26 09:19:20 -0700 | [diff] [blame] | 252 | unsigned int count = buffer->len; |
| 253 | for (unsigned int i = 0; i < count; i++) |
| 254 | { |
| 255 | _hb_glyph_info_set_glyph_props (&buffer->info[i], gdef.get_glyph_props (buffer->info[i].codepoint)); |
| 256 | _hb_glyph_info_clear_lig_props (&buffer->info[i]); |
| 257 | buffer->info[i].syllable() = 0; |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | /* Public API */ |
| 262 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 263 | /** |
| 264 | * hb_ot_layout_has_glyph_classes: |
| 265 | * @face: #hb_face_t to work upon |
| 266 | * |
| 267 | * Tests whether a face has any glyph classes defined in its GDEF table. |
| 268 | * |
| 269 | * Return value: true if data found, false otherwise |
| 270 | * |
| 271 | **/ |
Behdad Esfahbod | 590d55c | 2008-01-24 19:13:50 -0500 | [diff] [blame] | 272 | hb_bool_t |
Behdad Esfahbod | 52ea477 | 2009-11-06 17:45:38 -0500 | [diff] [blame] | 273 | hb_ot_layout_has_glyph_classes (hb_face_t *face) |
Behdad Esfahbod | 590d55c | 2008-01-24 19:13:50 -0500 | [diff] [blame] | 274 | { |
Behdad Esfahbod | 5e68cec | 2018-11-05 23:23:57 -0500 | [diff] [blame] | 275 | return face->table.GDEF->table->has_glyph_classes (); |
Behdad Esfahbod | 590d55c | 2008-01-24 19:13:50 -0500 | [diff] [blame] | 276 | } |
| 277 | |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 278 | /** |
Behdad Esfahbod | 35d1858 | 2015-11-26 19:30:37 -0500 | [diff] [blame] | 279 | * hb_ot_layout_get_glyph_class: |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 280 | * @face: The #hb_face_t to work on |
| 281 | * @glyph: The #hb_codepoint_t code point to query |
| 282 | * |
| 283 | * Fetches the GDEF class of the requested glyph in the specified face. |
| 284 | * |
Nathan Willis | c08ddbd | 2019-03-24 15:07:07 +0000 | [diff] [blame] | 285 | * Return value: The #hb_ot_layout_glyph_class_t glyph class of the given code |
| 286 | * point in the GDEF table of the face. |
Behdad Esfahbod | 35d1858 | 2015-11-26 19:30:37 -0500 | [diff] [blame] | 287 | * |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 288 | * Since: 0.9.7 |
| 289 | **/ |
Behdad Esfahbod | 5a08ecf | 2012-11-16 13:34:29 -0800 | [diff] [blame] | 290 | hb_ot_layout_glyph_class_t |
| 291 | hb_ot_layout_get_glyph_class (hb_face_t *face, |
| 292 | hb_codepoint_t glyph) |
| 293 | { |
Behdad Esfahbod | 5e68cec | 2018-11-05 23:23:57 -0500 | [diff] [blame] | 294 | return (hb_ot_layout_glyph_class_t) face->table.GDEF->table->get_glyph_class (glyph); |
Behdad Esfahbod | 5a08ecf | 2012-11-16 13:34:29 -0800 | [diff] [blame] | 295 | } |
Behdad Esfahbod | 4a2d844 | 2010-11-03 15:28:56 -0400 | [diff] [blame] | 296 | |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 297 | /** |
Behdad Esfahbod | 35d1858 | 2015-11-26 19:30:37 -0500 | [diff] [blame] | 298 | * hb_ot_layout_get_glyphs_in_class: |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 299 | * @face: The #hb_face_t to work on |
| 300 | * @klass: The #hb_ot_layout_glyph_class_t GDEF class to retrieve |
| 301 | * @glyphs: (out): The #hb_set_t set of all glyphs belonging to the requested |
| 302 | * class. |
| 303 | * |
| 304 | * Retrieves the set of all glyphs from the face that belong to the requested |
| 305 | * glyph class in the face's GDEF table. |
Behdad Esfahbod | 35d1858 | 2015-11-26 19:30:37 -0500 | [diff] [blame] | 306 | * |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 307 | * Since: 0.9.7 |
| 308 | **/ |
Behdad Esfahbod | 89ca8ee | 2012-11-16 13:53:40 -0800 | [diff] [blame] | 309 | void |
| 310 | hb_ot_layout_get_glyphs_in_class (hb_face_t *face, |
| 311 | hb_ot_layout_glyph_class_t klass, |
| 312 | hb_set_t *glyphs /* OUT */) |
| 313 | { |
Behdad Esfahbod | 5e68cec | 2018-11-05 23:23:57 -0500 | [diff] [blame] | 314 | return face->table.GDEF->table->get_glyphs_in_class (klass, glyphs); |
Behdad Esfahbod | 89ca8ee | 2012-11-16 13:53:40 -0800 | [diff] [blame] | 315 | } |
| 316 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 317 | |
Behdad Esfahbod | bf9424a | 2019-06-18 13:31:35 -0700 | [diff] [blame] | 318 | #ifndef HB_NO_LAYOUT_UNUSED |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 319 | /** |
| 320 | * hb_ot_layout_get_attach_points: |
| 321 | * @face: The #hb_face_t to work on |
| 322 | * @glyph: The #hb_codepoint_t code point to query |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 323 | * @start_offset: offset of the first attachment point to retrieve |
| 324 | * @point_count: (inout) (allow-none): Input = the maximum number of attachment points to return; |
| 325 | * Output = the actual number of attachment points returned (may be zero) |
| 326 | * @point_array: (out) (array length=point_count): The array of attachment points found for the query |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 327 | * |
| 328 | * Fetches a list of all attachment points for the specified glyph in the GDEF |
| 329 | * table of the face. The list returned will begin at the offset provided. |
| 330 | * |
| 331 | * Useful if the client program wishes to cache the list. |
| 332 | * |
| 333 | **/ |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 334 | unsigned int |
Behdad Esfahbod | 0ead481 | 2009-08-02 17:41:36 -0400 | [diff] [blame] | 335 | hb_ot_layout_get_attach_points (hb_face_t *face, |
Behdad Esfahbod | 79420ad | 2009-05-26 12:24:16 -0400 | [diff] [blame] | 336 | hb_codepoint_t glyph, |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 337 | unsigned int start_offset, |
Behdad Esfahbod | 79420ad | 2009-05-26 12:24:16 -0400 | [diff] [blame] | 338 | unsigned int *point_count /* IN/OUT */, |
| 339 | unsigned int *point_array /* OUT */) |
| 340 | { |
Behdad Esfahbod | 5e68cec | 2018-11-05 23:23:57 -0500 | [diff] [blame] | 341 | return face->table.GDEF->table->get_attach_points (glyph, |
| 342 | start_offset, |
| 343 | point_count, |
| 344 | point_array); |
Behdad Esfahbod | 62964af | 2009-05-26 12:40:10 -0400 | [diff] [blame] | 345 | } |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 346 | /** |
| 347 | * hb_ot_layout_get_ligature_carets: |
| 348 | * @font: The #hb_font_t to work on |
| 349 | * @direction: The #hb_direction_t text direction to use |
| 350 | * @glyph: The #hb_codepoint_t code point to query |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 351 | * @start_offset: offset of the first caret position to retrieve |
| 352 | * @caret_count: (inout) (allow-none): Input = the maximum number of caret positions to return; |
| 353 | * Output = the actual number of caret positions returned (may be zero) |
| 354 | * @caret_array: (out) (array length=caret_count): The array of caret positions found for the query |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 355 | * |
| 356 | * Fetches a list of the caret positions defined for a ligature glyph in the GDEF |
| 357 | * table of the font. The list returned will begin at the offset provided. |
| 358 | * |
| 359 | **/ |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 360 | unsigned int |
Behdad Esfahbod | e204674 | 2010-10-27 12:32:02 -0400 | [diff] [blame] | 361 | hb_ot_layout_get_ligature_carets (hb_font_t *font, |
Behdad Esfahbod | e204674 | 2010-10-27 12:32:02 -0400 | [diff] [blame] | 362 | hb_direction_t direction, |
| 363 | hb_codepoint_t glyph, |
| 364 | unsigned int start_offset, |
| 365 | unsigned int *caret_count /* IN/OUT */, |
Ebrahim Byagowi | 3b0e47c | 2017-06-19 14:47:09 +0430 | [diff] [blame] | 366 | hb_position_t *caret_array /* OUT */) |
Behdad Esfahbod | 62964af | 2009-05-26 12:40:10 -0400 | [diff] [blame] | 367 | { |
Ebrahim Byagowi | b986fea | 2018-11-05 12:31:58 +0330 | [diff] [blame] | 368 | unsigned int result_caret_count = 0; |
| 369 | unsigned int result = font->face->table.GDEF->table->get_lig_carets (font, direction, glyph, start_offset, &result_caret_count, caret_array); |
| 370 | if (result) |
| 371 | { |
| 372 | if (caret_count) *caret_count = result_caret_count; |
| 373 | } |
Behdad Esfahbod | 631da9d | 2019-06-19 15:36:14 -0700 | [diff] [blame] | 374 | #ifndef HB_NO_AAT |
Ebrahim Byagowi | b986fea | 2018-11-05 12:31:58 +0330 | [diff] [blame] | 375 | else |
| 376 | result = font->face->table.lcar->get_lig_carets (font, direction, glyph, start_offset, caret_count, caret_array); |
Behdad Esfahbod | 631da9d | 2019-06-19 15:36:14 -0700 | [diff] [blame] | 377 | #endif |
Ebrahim Byagowi | b986fea | 2018-11-05 12:31:58 +0330 | [diff] [blame] | 378 | return result; |
Behdad Esfahbod | 79420ad | 2009-05-26 12:24:16 -0400 | [diff] [blame] | 379 | } |
Behdad Esfahbod | bf9424a | 2019-06-18 13:31:35 -0700 | [diff] [blame] | 380 | #endif |
Behdad Esfahbod | 79420ad | 2009-05-26 12:24:16 -0400 | [diff] [blame] | 381 | |
Behdad Esfahbod | 05bd1b6 | 2012-07-30 19:30:01 -0400 | [diff] [blame] | 382 | |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 383 | /* |
| 384 | * GSUB/GPOS |
| 385 | */ |
| 386 | |
Behdad Esfahbod | 574d888 | 2018-11-25 16:51:22 -0500 | [diff] [blame] | 387 | bool |
| 388 | OT::GSUB::is_blacklisted (hb_blob_t *blob HB_UNUSED, |
| 389 | hb_face_t *face) const |
| 390 | { |
Behdad Esfahbod | 227d85e | 2019-05-10 23:15:58 -0700 | [diff] [blame] | 391 | #ifdef HB_NO_OT_LAYOUT_BLACKLIST |
Behdad Esfahbod | 9ddbfa0 | 2019-04-12 09:33:25 -0400 | [diff] [blame] | 392 | return false; |
| 393 | #endif |
Behdad Esfahbod | f08066c | 2019-06-18 14:29:27 -0700 | [diff] [blame] | 394 | |
Behdad Esfahbod | 12092a4 | 2019-06-26 13:31:01 -0700 | [diff] [blame^] | 395 | #ifndef HB_NO_AAT_SHAPE |
Behdad Esfahbod | 574d888 | 2018-11-25 16:51:22 -0500 | [diff] [blame] | 396 | /* Mac OS X prefers morx over GSUB. It also ships with various Indic fonts, |
| 397 | * all by 'MUTF' foundry (Tamil MN, Tamil Sangam MN, etc.), that have broken |
| 398 | * GSUB/GPOS tables. Some have GSUB with zero scripts, those are ignored by |
| 399 | * our morx/GSUB preference code. But if GSUB has non-zero scripts, we tend |
| 400 | * to prefer it over morx because we want to be consistent with other OpenType |
| 401 | * shapers. |
| 402 | * |
| 403 | * To work around broken Indic Mac system fonts, we ignore GSUB table if |
| 404 | * OS/2 VendorId is 'MUTF' and font has morx table as well. |
| 405 | * |
| 406 | * https://github.com/harfbuzz/harfbuzz/issues/1410 |
| 407 | * https://github.com/harfbuzz/harfbuzz/issues/1348 |
| 408 | * https://github.com/harfbuzz/harfbuzz/issues/1391 |
| 409 | */ |
| 410 | if (unlikely (face->table.OS2->achVendID == HB_TAG ('M','U','T','F') && |
| 411 | face->table.morx->has_data ())) |
| 412 | return true; |
Behdad Esfahbod | f08066c | 2019-06-18 14:29:27 -0700 | [diff] [blame] | 413 | #endif |
Behdad Esfahbod | 574d888 | 2018-11-25 16:51:22 -0500 | [diff] [blame] | 414 | |
| 415 | return false; |
| 416 | } |
| 417 | |
| 418 | bool |
| 419 | OT::GPOS::is_blacklisted (hb_blob_t *blob HB_UNUSED, |
| 420 | hb_face_t *face HB_UNUSED) const |
| 421 | { |
Behdad Esfahbod | 227d85e | 2019-05-10 23:15:58 -0700 | [diff] [blame] | 422 | #ifdef HB_NO_OT_LAYOUT_BLACKLIST |
Behdad Esfahbod | 9ddbfa0 | 2019-04-12 09:33:25 -0400 | [diff] [blame] | 423 | return false; |
| 424 | #endif |
Behdad Esfahbod | 574d888 | 2018-11-25 16:51:22 -0500 | [diff] [blame] | 425 | return false; |
| 426 | } |
| 427 | |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 428 | static const OT::GSUBGPOS& |
Behdad Esfahbod | 23c86aa | 2009-08-03 21:40:20 -0400 | [diff] [blame] | 429 | get_gsubgpos_table (hb_face_t *face, |
| 430 | hb_tag_t table_tag) |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 431 | { |
Behdad Esfahbod | 0ead481 | 2009-08-02 17:41:36 -0400 | [diff] [blame] | 432 | switch (table_tag) { |
Behdad Esfahbod | 737efbe | 2018-11-05 23:26:29 -0500 | [diff] [blame] | 433 | case HB_OT_TAG_GSUB: return *face->table.GSUB->table; |
| 434 | case HB_OT_TAG_GPOS: return *face->table.GPOS->table; |
Behdad Esfahbod | abc12f7 | 2018-05-08 02:23:36 -0700 | [diff] [blame] | 435 | default: return Null(OT::GSUBGPOS); |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 436 | } |
| 437 | } |
| 438 | |
| 439 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 440 | /** |
| 441 | * hb_ot_layout_table_get_script_tags: |
| 442 | * @face: #hb_face_t to work upon |
| 443 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 444 | * @start_offset: offset of the first script tag to retrieve |
| 445 | * @script_count: (inout) (allow-none): Input = the maximum number of script tags to return; |
| 446 | * Output = the actual number of script tags returned (may be zero) |
| 447 | * @script_tags: (out) (array length=script_count): The array of #hb_tag_t script tags found for the query |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 448 | * |
| 449 | * Fetches a list of all scripts enumerated in the specified face's GSUB table |
| 450 | * or GPOS table. The list returned will begin at the offset provided. |
| 451 | * |
| 452 | **/ |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 453 | unsigned int |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 454 | hb_ot_layout_table_get_script_tags (hb_face_t *face, |
| 455 | hb_tag_t table_tag, |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 456 | unsigned int start_offset, |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 457 | unsigned int *script_count /* IN/OUT */, |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 458 | hb_tag_t *script_tags /* OUT */) |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 459 | { |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 460 | const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 461 | |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 462 | return g.get_script_tags (start_offset, script_count, script_tags); |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 463 | } |
| 464 | |
Behdad Esfahbod | eb45c0a | 2013-01-16 22:07:50 -0600 | [diff] [blame] | 465 | #define HB_OT_TAG_LATIN_SCRIPT HB_TAG ('l', 'a', 't', 'n') |
| 466 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 467 | /** |
| 468 | * hb_ot_layout_table_find_script: |
| 469 | * @face: #hb_face_t to work upon |
| 470 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 471 | * @script_tag: #hb_tag_t of the script tag requested |
Nathan Willis | 5122805 | 2019-03-17 14:43:06 +0000 | [diff] [blame] | 472 | * @script_index: (out): The index of the requested script tag |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 473 | * |
| 474 | * Fetches the index if a given script tag in the specified face's GSUB table |
| 475 | * or GPOS table. |
| 476 | * |
| 477 | * Return value: true if the script is found, false otherwise |
| 478 | * |
| 479 | **/ |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 480 | hb_bool_t |
Behdad Esfahbod | 0ead481 | 2009-08-02 17:41:36 -0400 | [diff] [blame] | 481 | hb_ot_layout_table_find_script (hb_face_t *face, |
| 482 | hb_tag_t table_tag, |
| 483 | hb_tag_t script_tag, |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 484 | unsigned int *script_index /* OUT */) |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 485 | { |
Behdad Esfahbod | 606bf57 | 2018-09-16 19:33:48 +0200 | [diff] [blame] | 486 | static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX), ""); |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 487 | const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 488 | |
| 489 | if (g.find_script_index (script_tag, script_index)) |
Behdad Esfahbod | 0594a24 | 2012-06-05 20:35:40 -0400 | [diff] [blame] | 490 | return true; |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 491 | |
| 492 | /* try finding 'DFLT' */ |
Behdad Esfahbod | 8a3511a | 2009-11-04 19:45:39 -0500 | [diff] [blame] | 493 | if (g.find_script_index (HB_OT_TAG_DEFAULT_SCRIPT, script_index)) |
Behdad Esfahbod | 0594a24 | 2012-06-05 20:35:40 -0400 | [diff] [blame] | 494 | return false; |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 495 | |
Behdad Esfahbod | dca8aff | 2010-09-28 16:25:23 -0400 | [diff] [blame] | 496 | /* try with 'dflt'; MS site has had typos and many fonts use it now :(. |
| 497 | * including many versions of DejaVu Sans Mono! */ |
Behdad Esfahbod | 8a3511a | 2009-11-04 19:45:39 -0500 | [diff] [blame] | 498 | if (g.find_script_index (HB_OT_TAG_DEFAULT_LANGUAGE, script_index)) |
Behdad Esfahbod | 0594a24 | 2012-06-05 20:35:40 -0400 | [diff] [blame] | 499 | return false; |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 500 | |
Behdad Esfahbod | eb45c0a | 2013-01-16 22:07:50 -0600 | [diff] [blame] | 501 | /* try with 'latn'; some old fonts put their features there even though |
| 502 | they're really trying to support Thai, for example :( */ |
| 503 | if (g.find_script_index (HB_OT_TAG_LATIN_SCRIPT, script_index)) |
| 504 | return false; |
| 505 | |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 506 | if (script_index) *script_index = HB_OT_LAYOUT_NO_SCRIPT_INDEX; |
Behdad Esfahbod | 0594a24 | 2012-06-05 20:35:40 -0400 | [diff] [blame] | 507 | return false; |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 508 | } |
| 509 | |
Behdad Esfahbod | fca2786 | 2019-05-11 00:37:01 -0700 | [diff] [blame] | 510 | #ifndef HB_DISABLE_DEPRECATED |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 511 | /** |
| 512 | * hb_ot_layout_table_choose_script: |
| 513 | * @face: #hb_face_t to work upon |
| 514 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 515 | * @script_tags: Array of #hb_tag_t script tags |
Nathan Willis | 6c0a1e8 | 2019-03-17 14:50:47 +0000 | [diff] [blame] | 516 | * @script_index: (out): The index of the requested script tag |
| 517 | * @chosen_script: (out): #hb_tag_t of the script tag requested |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 518 | * |
Nathan Willis | c08ddbd | 2019-03-24 15:07:07 +0000 | [diff] [blame] | 519 | * Deprecated since 2.0.0 |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 520 | **/ |
Behdad Esfahbod | 2014b8d | 2009-12-20 20:58:26 +0100 | [diff] [blame] | 521 | hb_bool_t |
| 522 | hb_ot_layout_table_choose_script (hb_face_t *face, |
| 523 | hb_tag_t table_tag, |
| 524 | const hb_tag_t *script_tags, |
Nathan Willis | 6c0a1e8 | 2019-03-17 14:50:47 +0000 | [diff] [blame] | 525 | unsigned int *script_index /* OUT */, |
| 526 | hb_tag_t *chosen_script /* OUT */) |
Behdad Esfahbod | 2014b8d | 2009-12-20 20:58:26 +0100 | [diff] [blame] | 527 | { |
David Corbett | 9106771 | 2017-12-08 11:21:14 -0500 | [diff] [blame] | 528 | const hb_tag_t *t; |
| 529 | for (t = script_tags; *t; t++); |
| 530 | return hb_ot_layout_table_select_script (face, table_tag, t - script_tags, script_tags, script_index, chosen_script); |
| 531 | } |
Behdad Esfahbod | fca2786 | 2019-05-11 00:37:01 -0700 | [diff] [blame] | 532 | #endif |
David Corbett | 9106771 | 2017-12-08 11:21:14 -0500 | [diff] [blame] | 533 | |
Behdad Esfahbod | 8061664 | 2018-10-11 14:16:55 -0400 | [diff] [blame] | 534 | /** |
| 535 | * hb_ot_layout_table_select_script: |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 536 | * @face: #hb_face_t to work upon |
| 537 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 538 | * @script_count: Number of script tags in the array |
| 539 | * @script_tags: Array of #hb_tag_t script tags |
Nathan Willis | 5122805 | 2019-03-17 14:43:06 +0000 | [diff] [blame] | 540 | * @script_index: (out): The index of the requested script |
| 541 | * @chosen_script: (out): #hb_tag_t of the requested script |
Behdad Esfahbod | 8061664 | 2018-10-11 14:16:55 -0400 | [diff] [blame] | 542 | * |
Behdad Esfahbod | 3d9a030 | 2018-10-18 05:58:17 -0700 | [diff] [blame] | 543 | * Since: 2.0.0 |
Behdad Esfahbod | 8061664 | 2018-10-11 14:16:55 -0400 | [diff] [blame] | 544 | **/ |
David Corbett | 9106771 | 2017-12-08 11:21:14 -0500 | [diff] [blame] | 545 | hb_bool_t |
| 546 | hb_ot_layout_table_select_script (hb_face_t *face, |
| 547 | hb_tag_t table_tag, |
| 548 | unsigned int script_count, |
| 549 | const hb_tag_t *script_tags, |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 550 | unsigned int *script_index /* OUT */, |
David Corbett | 9106771 | 2017-12-08 11:21:14 -0500 | [diff] [blame] | 551 | hb_tag_t *chosen_script /* OUT */) |
| 552 | { |
Behdad Esfahbod | 606bf57 | 2018-09-16 19:33:48 +0200 | [diff] [blame] | 553 | static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX), ""); |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 554 | const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); |
David Corbett | 9106771 | 2017-12-08 11:21:14 -0500 | [diff] [blame] | 555 | unsigned int i; |
Behdad Esfahbod | 2014b8d | 2009-12-20 20:58:26 +0100 | [diff] [blame] | 556 | |
David Corbett | 9106771 | 2017-12-08 11:21:14 -0500 | [diff] [blame] | 557 | for (i = 0; i < script_count; i++) |
Behdad Esfahbod | 2014b8d | 2009-12-20 20:58:26 +0100 | [diff] [blame] | 558 | { |
David Corbett | 9106771 | 2017-12-08 11:21:14 -0500 | [diff] [blame] | 559 | if (g.find_script_index (script_tags[i], script_index)) |
| 560 | { |
Behdad Esfahbod | c47a31f | 2011-07-30 20:57:01 -0400 | [diff] [blame] | 561 | if (chosen_script) |
David Corbett | 9106771 | 2017-12-08 11:21:14 -0500 | [diff] [blame] | 562 | *chosen_script = script_tags[i]; |
Behdad Esfahbod | 0594a24 | 2012-06-05 20:35:40 -0400 | [diff] [blame] | 563 | return true; |
Behdad Esfahbod | c47a31f | 2011-07-30 20:57:01 -0400 | [diff] [blame] | 564 | } |
Behdad Esfahbod | 2014b8d | 2009-12-20 20:58:26 +0100 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | /* try finding 'DFLT' */ |
Behdad Esfahbod | c47a31f | 2011-07-30 20:57:01 -0400 | [diff] [blame] | 568 | if (g.find_script_index (HB_OT_TAG_DEFAULT_SCRIPT, script_index)) { |
| 569 | if (chosen_script) |
| 570 | *chosen_script = HB_OT_TAG_DEFAULT_SCRIPT; |
Behdad Esfahbod | 0594a24 | 2012-06-05 20:35:40 -0400 | [diff] [blame] | 571 | return false; |
Behdad Esfahbod | c47a31f | 2011-07-30 20:57:01 -0400 | [diff] [blame] | 572 | } |
Behdad Esfahbod | 2014b8d | 2009-12-20 20:58:26 +0100 | [diff] [blame] | 573 | |
| 574 | /* try with 'dflt'; MS site has had typos and many fonts use it now :( */ |
Behdad Esfahbod | c47a31f | 2011-07-30 20:57:01 -0400 | [diff] [blame] | 575 | if (g.find_script_index (HB_OT_TAG_DEFAULT_LANGUAGE, script_index)) { |
| 576 | if (chosen_script) |
| 577 | *chosen_script = HB_OT_TAG_DEFAULT_LANGUAGE; |
Behdad Esfahbod | 0594a24 | 2012-06-05 20:35:40 -0400 | [diff] [blame] | 578 | return false; |
Behdad Esfahbod | c47a31f | 2011-07-30 20:57:01 -0400 | [diff] [blame] | 579 | } |
Behdad Esfahbod | 2014b8d | 2009-12-20 20:58:26 +0100 | [diff] [blame] | 580 | |
Behdad Esfahbod | 71632c9 | 2012-01-22 15:31:44 -0500 | [diff] [blame] | 581 | /* try with 'latn'; some old fonts put their features there even though |
| 582 | they're really trying to support Thai, for example :( */ |
Behdad Esfahbod | 71632c9 | 2012-01-22 15:31:44 -0500 | [diff] [blame] | 583 | if (g.find_script_index (HB_OT_TAG_LATIN_SCRIPT, script_index)) { |
| 584 | if (chosen_script) |
| 585 | *chosen_script = HB_OT_TAG_LATIN_SCRIPT; |
Behdad Esfahbod | 0594a24 | 2012-06-05 20:35:40 -0400 | [diff] [blame] | 586 | return false; |
Behdad Esfahbod | 71632c9 | 2012-01-22 15:31:44 -0500 | [diff] [blame] | 587 | } |
| 588 | |
Behdad Esfahbod | 2014b8d | 2009-12-20 20:58:26 +0100 | [diff] [blame] | 589 | if (script_index) *script_index = HB_OT_LAYOUT_NO_SCRIPT_INDEX; |
Behdad Esfahbod | c47a31f | 2011-07-30 20:57:01 -0400 | [diff] [blame] | 590 | if (chosen_script) |
| 591 | *chosen_script = HB_OT_LAYOUT_NO_SCRIPT_INDEX; |
Behdad Esfahbod | 0594a24 | 2012-06-05 20:35:40 -0400 | [diff] [blame] | 592 | return false; |
Behdad Esfahbod | 2014b8d | 2009-12-20 20:58:26 +0100 | [diff] [blame] | 593 | } |
| 594 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 595 | |
| 596 | /** |
| 597 | * hb_ot_layout_table_get_feature_tags: |
| 598 | * @face: #hb_face_t to work upon |
| 599 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 600 | * @start_offset: offset of the first feature tag to retrieve |
| 601 | * @feature_count: (inout) (allow-none): Input = the maximum number of feature tags to return; |
| 602 | * Output = the actual number of feature tags returned (may be zero) |
| 603 | * @feature_tags: (out) (array length=feature_count): Array of feature tags found in the table |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 604 | * |
| 605 | * Fetches a list of all feature tags in the given face's GSUB or GPOS table. |
| 606 | * |
| 607 | **/ |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 608 | unsigned int |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 609 | hb_ot_layout_table_get_feature_tags (hb_face_t *face, |
| 610 | hb_tag_t table_tag, |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 611 | unsigned int start_offset, |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 612 | unsigned int *feature_count /* IN/OUT */, |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 613 | hb_tag_t *feature_tags /* OUT */) |
Behdad Esfahbod | c447335 | 2008-02-18 21:14:23 -0500 | [diff] [blame] | 614 | { |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 615 | const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); |
Behdad Esfahbod | c447335 | 2008-02-18 21:14:23 -0500 | [diff] [blame] | 616 | |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 617 | return g.get_feature_tags (start_offset, feature_count, feature_tags); |
Behdad Esfahbod | c447335 | 2008-02-18 21:14:23 -0500 | [diff] [blame] | 618 | } |
| 619 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 620 | |
| 621 | /** |
| 622 | * hb_ot_layout_table_find_feature: |
| 623 | * @face: #hb_face_t to work upon |
| 624 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 625 | * @feature_tag: The #hb_tag_t og the requested feature tag |
Nathan Willis | 5122805 | 2019-03-17 14:43:06 +0000 | [diff] [blame] | 626 | * @feature_index: (out): The index of the requested feature |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 627 | * |
| 628 | * Fetches the index for a given feature tag in the specified face's GSUB table |
| 629 | * or GPOS table. |
| 630 | * |
| 631 | * Return value: true if the feature is found, false otherwise |
| 632 | **/ |
Behdad Esfahbod | 385f78b | 2018-11-07 17:19:21 -0500 | [diff] [blame] | 633 | bool |
Behdad Esfahbod | 0f98fe8 | 2015-07-23 11:52:11 +0100 | [diff] [blame] | 634 | hb_ot_layout_table_find_feature (hb_face_t *face, |
| 635 | hb_tag_t table_tag, |
| 636 | hb_tag_t feature_tag, |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 637 | unsigned int *feature_index /* OUT */) |
Behdad Esfahbod | 0f98fe8 | 2015-07-23 11:52:11 +0100 | [diff] [blame] | 638 | { |
Behdad Esfahbod | 606bf57 | 2018-09-16 19:33:48 +0200 | [diff] [blame] | 639 | static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_FEATURE_INDEX), ""); |
Behdad Esfahbod | 0f98fe8 | 2015-07-23 11:52:11 +0100 | [diff] [blame] | 640 | const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); |
| 641 | |
| 642 | unsigned int num_features = g.get_feature_count (); |
| 643 | for (unsigned int i = 0; i < num_features; i++) |
| 644 | { |
| 645 | if (feature_tag == g.get_feature_tag (i)) { |
| 646 | if (feature_index) *feature_index = i; |
| 647 | return true; |
| 648 | } |
| 649 | } |
| 650 | |
| 651 | if (feature_index) *feature_index = HB_OT_LAYOUT_NO_FEATURE_INDEX; |
| 652 | return false; |
| 653 | } |
| 654 | |
Behdad Esfahbod | c447335 | 2008-02-18 21:14:23 -0500 | [diff] [blame] | 655 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 656 | /** |
| 657 | * hb_ot_layout_script_get_language_tags: |
| 658 | * @face: #hb_face_t to work upon |
| 659 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 660 | * @script_index: The index of the requested script tag |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 661 | * @start_offset: offset of the first language tag to retrieve |
| 662 | * @language_count: (inout) (allow-none): Input = the maximum number of language tags to return; |
| 663 | * Output = the actual number of language tags returned (may be zero) |
| 664 | * @language_tags: (out) (array length=language_count): Array of language tags found in the table |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 665 | * |
| 666 | * Fetches a list of language tags in the given face's GSUB or GPOS table, underneath |
| 667 | * the specified script index. The list returned will begin at the offset provided. |
| 668 | * |
| 669 | **/ |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 670 | unsigned int |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 671 | hb_ot_layout_script_get_language_tags (hb_face_t *face, |
| 672 | hb_tag_t table_tag, |
| 673 | unsigned int script_index, |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 674 | unsigned int start_offset, |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 675 | unsigned int *language_count /* IN/OUT */, |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 676 | hb_tag_t *language_tags /* OUT */) |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 677 | { |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 678 | const OT::Script &s = get_gsubgpos_table (face, table_tag).get_script (script_index); |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 679 | |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 680 | return s.get_lang_sys_tags (start_offset, language_count, language_tags); |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 681 | } |
| 682 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 683 | |
Behdad Esfahbod | fca2786 | 2019-05-11 00:37:01 -0700 | [diff] [blame] | 684 | #ifndef HB_DISABLE_DEPRECATED |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 685 | /** |
| 686 | * hb_ot_layout_script_find_language: |
| 687 | * @face: #hb_face_t to work upon |
| 688 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 689 | * @script_index: The index of the requested script tag |
| 690 | * @language_tag: The #hb_tag_t of the requested language |
| 691 | * @language_index: The index of the requested language |
| 692 | * |
| 693 | * Fetches the index of a given language tag in the specified face's GSUB table |
| 694 | * or GPOS table, underneath the specified script tag. |
| 695 | * |
| 696 | * Return value: true if the language tag is found, false otherwise |
| 697 | * |
Behdad Esfahbod | fca2786 | 2019-05-11 00:37:01 -0700 | [diff] [blame] | 698 | * Since: ?? |
| 699 | * Deprecated: ?? |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 700 | **/ |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 701 | hb_bool_t |
Behdad Esfahbod | 0ead481 | 2009-08-02 17:41:36 -0400 | [diff] [blame] | 702 | hb_ot_layout_script_find_language (hb_face_t *face, |
| 703 | hb_tag_t table_tag, |
| 704 | unsigned int script_index, |
| 705 | hb_tag_t language_tag, |
| 706 | unsigned int *language_index) |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 707 | { |
Behdad Esfahbod | 737efbe | 2018-11-05 23:26:29 -0500 | [diff] [blame] | 708 | return hb_ot_layout_script_select_language (face, |
| 709 | table_tag, |
| 710 | script_index, |
| 711 | 1, |
| 712 | &language_tag, |
| 713 | language_index); |
David Corbett | 9106771 | 2017-12-08 11:21:14 -0500 | [diff] [blame] | 714 | } |
Behdad Esfahbod | fca2786 | 2019-05-11 00:37:01 -0700 | [diff] [blame] | 715 | #endif |
David Corbett | 9106771 | 2017-12-08 11:21:14 -0500 | [diff] [blame] | 716 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 717 | |
Behdad Esfahbod | 8061664 | 2018-10-11 14:16:55 -0400 | [diff] [blame] | 718 | /** |
| 719 | * hb_ot_layout_script_select_language: |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 720 | * @face: #hb_face_t to work upon |
| 721 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 722 | * @script_index: The index of the requested script tag |
| 723 | * @language_count: The number of languages in the specified script |
| 724 | * @language_tags: The array of language tags |
Nathan Willis | 5122805 | 2019-03-17 14:43:06 +0000 | [diff] [blame] | 725 | * @language_index: (out): The index of the requested language |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 726 | * |
| 727 | * Fetches the index of a given language tag in the specified face's GSUB table |
| 728 | * or GPOS table, underneath the specified script index. |
| 729 | * |
| 730 | * Return value: true if the language tag is found, false otherwise |
| 731 | * |
Behdad Esfahbod | 3d9a030 | 2018-10-18 05:58:17 -0700 | [diff] [blame] | 732 | * Since: 2.0.0 |
Behdad Esfahbod | 8061664 | 2018-10-11 14:16:55 -0400 | [diff] [blame] | 733 | **/ |
David Corbett | 9106771 | 2017-12-08 11:21:14 -0500 | [diff] [blame] | 734 | hb_bool_t |
Behdad Esfahbod | cf975ac | 2018-10-11 14:07:44 -0400 | [diff] [blame] | 735 | hb_ot_layout_script_select_language (hb_face_t *face, |
| 736 | hb_tag_t table_tag, |
| 737 | unsigned int script_index, |
| 738 | unsigned int language_count, |
| 739 | const hb_tag_t *language_tags, |
| 740 | unsigned int *language_index /* OUT */) |
David Corbett | 9106771 | 2017-12-08 11:21:14 -0500 | [diff] [blame] | 741 | { |
Behdad Esfahbod | 606bf57 | 2018-09-16 19:33:48 +0200 | [diff] [blame] | 742 | static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX), ""); |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 743 | const OT::Script &s = get_gsubgpos_table (face, table_tag).get_script (script_index); |
David Corbett | 9106771 | 2017-12-08 11:21:14 -0500 | [diff] [blame] | 744 | unsigned int i; |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 745 | |
David Corbett | 9106771 | 2017-12-08 11:21:14 -0500 | [diff] [blame] | 746 | for (i = 0; i < language_count; i++) |
| 747 | { |
| 748 | if (s.find_lang_sys_index (language_tags[i], language_index)) |
| 749 | return true; |
| 750 | } |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 751 | |
David Corbett | 9106771 | 2017-12-08 11:21:14 -0500 | [diff] [blame] | 752 | /* try finding 'dflt' */ |
Behdad Esfahbod | 8a3511a | 2009-11-04 19:45:39 -0500 | [diff] [blame] | 753 | if (s.find_lang_sys_index (HB_OT_TAG_DEFAULT_LANGUAGE, language_index)) |
Behdad Esfahbod | 0594a24 | 2012-06-05 20:35:40 -0400 | [diff] [blame] | 754 | return false; |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 755 | |
Behdad Esfahbod | 4a26ea4 | 2008-01-28 07:40:10 -0500 | [diff] [blame] | 756 | if (language_index) *language_index = HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX; |
Behdad Esfahbod | 0594a24 | 2012-06-05 20:35:40 -0400 | [diff] [blame] | 757 | return false; |
Behdad Esfahbod | 4a26ea4 | 2008-01-28 07:40:10 -0500 | [diff] [blame] | 758 | } |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 759 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 760 | |
| 761 | /** |
| 762 | * hb_ot_layout_language_get_required_feature_index: |
| 763 | * @face: #hb_face_t to work upon |
| 764 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 765 | * @script_index: The index of the requested script tag |
| 766 | * @language_index: The index of the requested language tag |
Nathan Willis | 5122805 | 2019-03-17 14:43:06 +0000 | [diff] [blame] | 767 | * @feature_index: (out): The index of the requested feature |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 768 | * |
| 769 | * Fetches the index of a requested feature in the given face's GSUB or GPOS table, |
| 770 | * underneath the specified script and language. |
| 771 | * |
| 772 | * Return value: true if the feature is found, false otherwise |
| 773 | * |
| 774 | **/ |
Behdad Esfahbod | 4a26ea4 | 2008-01-28 07:40:10 -0500 | [diff] [blame] | 775 | hb_bool_t |
Behdad Esfahbod | 911ca38 | 2014-06-24 10:20:36 -0600 | [diff] [blame] | 776 | hb_ot_layout_language_get_required_feature_index (hb_face_t *face, |
| 777 | hb_tag_t table_tag, |
| 778 | unsigned int script_index, |
| 779 | unsigned int language_index, |
| 780 | unsigned int *feature_index) |
| 781 | { |
| 782 | return hb_ot_layout_language_get_required_feature (face, |
| 783 | table_tag, |
| 784 | script_index, |
| 785 | language_index, |
| 786 | feature_index, |
Behdad Esfahbod | dbdbfe3 | 2017-10-15 12:11:08 +0200 | [diff] [blame] | 787 | nullptr); |
Behdad Esfahbod | 911ca38 | 2014-06-24 10:20:36 -0600 | [diff] [blame] | 788 | } |
| 789 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 790 | |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 791 | /** |
Behdad Esfahbod | 35d1858 | 2015-11-26 19:30:37 -0500 | [diff] [blame] | 792 | * hb_ot_layout_language_get_required_feature: |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 793 | * @face: #hb_face_t to work upon |
| 794 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 795 | * @script_index: The index of the requested script tag |
| 796 | * @language_index: The index of the requested language tag |
| 797 | * @feature_index: The index of the requested feature |
Nathan Willis | 5122805 | 2019-03-17 14:43:06 +0000 | [diff] [blame] | 798 | * @feature_tag: (out): The #hb_tag_t of the requested feature |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 799 | * |
| 800 | * Fetches the tag of a requested feature index in the given face's GSUB or GPOS table, |
| 801 | * underneath the specified script and language. |
| 802 | * |
| 803 | * Return value: true if the feature is found, false otherwise |
Behdad Esfahbod | 35d1858 | 2015-11-26 19:30:37 -0500 | [diff] [blame] | 804 | * |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 805 | * Since: 0.9.30 |
| 806 | **/ |
Behdad Esfahbod | 911ca38 | 2014-06-24 10:20:36 -0600 | [diff] [blame] | 807 | hb_bool_t |
Jonathan Kew | da13293 | 2014-04-27 14:05:24 +0100 | [diff] [blame] | 808 | hb_ot_layout_language_get_required_feature (hb_face_t *face, |
| 809 | hb_tag_t table_tag, |
| 810 | unsigned int script_index, |
| 811 | unsigned int language_index, |
| 812 | unsigned int *feature_index, |
| 813 | hb_tag_t *feature_tag) |
Behdad Esfahbod | 4a26ea4 | 2008-01-28 07:40:10 -0500 | [diff] [blame] | 814 | { |
Jonathan Kew | da13293 | 2014-04-27 14:05:24 +0100 | [diff] [blame] | 815 | const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); |
| 816 | const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index); |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 817 | |
Jonathan Kew | da13293 | 2014-04-27 14:05:24 +0100 | [diff] [blame] | 818 | unsigned int index = l.get_required_feature_index (); |
| 819 | if (feature_index) *feature_index = index; |
| 820 | if (feature_tag) *feature_tag = g.get_feature_tag (index); |
Behdad Esfahbod | 4a26ea4 | 2008-01-28 07:40:10 -0500 | [diff] [blame] | 821 | |
| 822 | return l.has_required_feature (); |
| 823 | } |
| 824 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 825 | |
| 826 | /** |
| 827 | * hb_ot_layout_language_get_feature_indexes: |
| 828 | * @face: #hb_face_t to work upon |
| 829 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 830 | * @script_index: The index of the requested script tag |
| 831 | * @language_index: The index of the requested language tag |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 832 | * @start_offset: offset of the first feature tag to retrieve |
| 833 | * @feature_count: (inout) (allow-none): Input = the maximum number of feature tags to return; |
| 834 | * Output: the actual number of feature tags returned (may be zero) |
| 835 | * @feature_indexes: (out) (array length=feature_count): The array of feature indexes found for the query |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 836 | * |
| 837 | * Fetches a list of all features in the specified face's GSUB table |
| 838 | * or GPOS table, underneath the specified script and language. The list |
| 839 | * returned will begin at the offset provided. |
| 840 | **/ |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 841 | unsigned int |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 842 | hb_ot_layout_language_get_feature_indexes (hb_face_t *face, |
| 843 | hb_tag_t table_tag, |
| 844 | unsigned int script_index, |
| 845 | unsigned int language_index, |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 846 | unsigned int start_offset, |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 847 | unsigned int *feature_count /* IN/OUT */, |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 848 | unsigned int *feature_indexes /* OUT */) |
Behdad Esfahbod | 4a26ea4 | 2008-01-28 07:40:10 -0500 | [diff] [blame] | 849 | { |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 850 | const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); |
| 851 | const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index); |
Behdad Esfahbod | 4a26ea4 | 2008-01-28 07:40:10 -0500 | [diff] [blame] | 852 | |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 853 | return l.get_feature_indexes (start_offset, feature_count, feature_indexes); |
Behdad Esfahbod | c447335 | 2008-02-18 21:14:23 -0500 | [diff] [blame] | 854 | } |
| 855 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 856 | |
| 857 | /** |
| 858 | * hb_ot_layout_language_get_feature_tags: |
| 859 | * @face: #hb_face_t to work upon |
| 860 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 861 | * @script_index: The index of the requested script tag |
| 862 | * @language_index: The index of the requested language tag |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 863 | * @start_offset: offset of the first feature tag to retrieve |
| 864 | * @feature_count: (inout) (allow-none): Input = the maximum number of feature tags to return; |
| 865 | * Output = the actual number of feature tags returned (may be zero) |
| 866 | * @feature_tags: (out) (array length=feature_count): The array of #hb_tag_t feature tags found for the query |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 867 | * |
| 868 | * Fetches a list of all features in the specified face's GSUB table |
| 869 | * or GPOS table, underneath the specified script and language. The list |
| 870 | * returned will begin at the offset provided. |
| 871 | * |
| 872 | **/ |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 873 | unsigned int |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 874 | hb_ot_layout_language_get_feature_tags (hb_face_t *face, |
| 875 | hb_tag_t table_tag, |
| 876 | unsigned int script_index, |
| 877 | unsigned int language_index, |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 878 | unsigned int start_offset, |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 879 | unsigned int *feature_count /* IN/OUT */, |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 880 | hb_tag_t *feature_tags /* OUT */) |
Behdad Esfahbod | c447335 | 2008-02-18 21:14:23 -0500 | [diff] [blame] | 881 | { |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 882 | const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); |
| 883 | const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index); |
Behdad Esfahbod | 4a26ea4 | 2008-01-28 07:40:10 -0500 | [diff] [blame] | 884 | |
Behdad Esfahbod | 606bf57 | 2018-09-16 19:33:48 +0200 | [diff] [blame] | 885 | static_assert ((sizeof (unsigned int) == sizeof (hb_tag_t)), ""); |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 886 | unsigned int ret = l.get_feature_indexes (start_offset, feature_count, (unsigned int *) feature_tags); |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 887 | |
Behdad Esfahbod | 9897749 | 2009-08-27 01:32:17 -0400 | [diff] [blame] | 888 | if (feature_tags) { |
| 889 | unsigned int count = *feature_count; |
| 890 | for (unsigned int i = 0; i < count; i++) |
| 891 | feature_tags[i] = g.get_feature_tag ((unsigned int) feature_tags[i]); |
| 892 | } |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 893 | |
| 894 | return ret; |
Behdad Esfahbod | 4a26ea4 | 2008-01-28 07:40:10 -0500 | [diff] [blame] | 895 | } |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 896 | |
| 897 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 898 | /** |
| 899 | * hb_ot_layout_language_find_feature: |
| 900 | * @face: #hb_face_t to work upon |
| 901 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 902 | * @script_index: The index of the requested script tag |
| 903 | * @language_index: The index of the requested language tag |
| 904 | * @feature_tag: #hb_tag_t of the feature tag requested |
Nathan Willis | 5122805 | 2019-03-17 14:43:06 +0000 | [diff] [blame] | 905 | * @feature_index: (out): The index of the requested feature |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 906 | * |
| 907 | * Fetches the index of a given feature tag in the specified face's GSUB table |
| 908 | * or GPOS table, underneath the specified script and language. |
| 909 | * |
| 910 | * Return value: true if the feature is found, false otherwise |
| 911 | * |
| 912 | **/ |
Behdad Esfahbod | 4a26ea4 | 2008-01-28 07:40:10 -0500 | [diff] [blame] | 913 | hb_bool_t |
Behdad Esfahbod | 0ead481 | 2009-08-02 17:41:36 -0400 | [diff] [blame] | 914 | hb_ot_layout_language_find_feature (hb_face_t *face, |
| 915 | hb_tag_t table_tag, |
| 916 | unsigned int script_index, |
| 917 | unsigned int language_index, |
| 918 | hb_tag_t feature_tag, |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 919 | unsigned int *feature_index /* OUT */) |
Behdad Esfahbod | 4a26ea4 | 2008-01-28 07:40:10 -0500 | [diff] [blame] | 920 | { |
Behdad Esfahbod | 606bf57 | 2018-09-16 19:33:48 +0200 | [diff] [blame] | 921 | static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_FEATURE_INDEX), ""); |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 922 | const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); |
| 923 | const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index); |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 924 | |
Behdad Esfahbod | f4c9514 | 2009-05-17 04:59:56 -0400 | [diff] [blame] | 925 | unsigned int num_features = l.get_feature_count (); |
| 926 | for (unsigned int i = 0; i < num_features; i++) { |
Behdad Esfahbod | 4a26ea4 | 2008-01-28 07:40:10 -0500 | [diff] [blame] | 927 | unsigned int f_index = l.get_feature_index (i); |
| 928 | |
| 929 | if (feature_tag == g.get_feature_tag (f_index)) { |
| 930 | if (feature_index) *feature_index = f_index; |
Behdad Esfahbod | 0594a24 | 2012-06-05 20:35:40 -0400 | [diff] [blame] | 931 | return true; |
Behdad Esfahbod | 4a26ea4 | 2008-01-28 07:40:10 -0500 | [diff] [blame] | 932 | } |
| 933 | } |
| 934 | |
| 935 | if (feature_index) *feature_index = HB_OT_LAYOUT_NO_FEATURE_INDEX; |
Behdad Esfahbod | 0594a24 | 2012-06-05 20:35:40 -0400 | [diff] [blame] | 936 | return false; |
Behdad Esfahbod | 706ab25 | 2008-01-28 05:58:50 -0500 | [diff] [blame] | 937 | } |
Behdad Esfahbod | c447335 | 2008-02-18 21:14:23 -0500 | [diff] [blame] | 938 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 939 | |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 940 | /** |
Khaled Hosny | d7bf9d0 | 2015-12-29 02:23:24 +0400 | [diff] [blame] | 941 | * hb_ot_layout_feature_get_lookups: |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 942 | * @face: #hb_face_t to work upon |
| 943 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 944 | * @feature_index: The index of the requested feature |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 945 | * @start_offset: offset of the first lookup to retrieve |
| 946 | * @lookup_count: (inout) (allow-none): Input = the maximum number of lookups to return; |
| 947 | * Output = the actual number of lookups returned (may be zero) |
| 948 | * @lookup_indexes: (out) (array length=lookup_count): The array of lookup indexes found for the query |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 949 | * |
| 950 | * Fetches a list of all lookups enumerated for the specified feature, in |
| 951 | * the specified face's GSUB table or GPOS table. The list returned will |
| 952 | * begin at the offset provided. |
Khaled Hosny | d7bf9d0 | 2015-12-29 02:23:24 +0400 | [diff] [blame] | 953 | * |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 954 | * Since: 0.9.7 |
| 955 | **/ |
Behdad Esfahbod | e21899b | 2009-11-04 16:36:14 -0500 | [diff] [blame] | 956 | unsigned int |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 957 | hb_ot_layout_feature_get_lookups (hb_face_t *face, |
| 958 | hb_tag_t table_tag, |
| 959 | unsigned int feature_index, |
| 960 | unsigned int start_offset, |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 961 | unsigned int *lookup_count /* IN/OUT */, |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 962 | unsigned int *lookup_indexes /* OUT */) |
Behdad Esfahbod | c447335 | 2008-02-18 21:14:23 -0500 | [diff] [blame] | 963 | { |
Behdad Esfahbod | ec87ba9 | 2016-09-10 03:53:11 -0700 | [diff] [blame] | 964 | return hb_ot_layout_feature_with_variations_get_lookups (face, |
| 965 | table_tag, |
| 966 | feature_index, |
| 967 | HB_OT_LAYOUT_NO_VARIATIONS_INDEX, |
| 968 | start_offset, |
| 969 | lookup_count, |
| 970 | lookup_indexes); |
Behdad Esfahbod | c447335 | 2008-02-18 21:14:23 -0500 | [diff] [blame] | 971 | } |
| 972 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 973 | |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 974 | /** |
Khaled Hosny | d7bf9d0 | 2015-12-29 02:23:24 +0400 | [diff] [blame] | 975 | * hb_ot_layout_table_get_lookup_count: |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 976 | * @face: #hb_face_t to work upon |
| 977 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 978 | * |
| 979 | * Fetches the total number of lookups enumerated in the specified |
| 980 | * face's GSUB table or GPOS table. |
Khaled Hosny | d7bf9d0 | 2015-12-29 02:23:24 +0400 | [diff] [blame] | 981 | * |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 982 | * Since: 0.9.22 |
| 983 | **/ |
Behdad Esfahbod | 27674b4 | 2013-10-03 14:54:50 -0400 | [diff] [blame] | 984 | unsigned int |
| 985 | hb_ot_layout_table_get_lookup_count (hb_face_t *face, |
| 986 | hb_tag_t table_tag) |
| 987 | { |
Behdad Esfahbod | 96828b9 | 2018-10-25 20:34:29 -0700 | [diff] [blame] | 988 | return get_gsubgpos_table (face, table_tag).get_lookup_count (); |
Behdad Esfahbod | 27674b4 | 2013-10-03 14:54:50 -0400 | [diff] [blame] | 989 | } |
| 990 | |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 991 | |
| 992 | struct hb_collect_features_context_t |
| 993 | { |
| 994 | hb_collect_features_context_t (hb_face_t *face, |
| 995 | hb_tag_t table_tag, |
| 996 | hb_set_t *feature_indexes_) |
| 997 | : g (get_gsubgpos_table (face, table_tag)), |
Garret Rieger | 0e1ad5a | 2018-10-30 11:29:58 -0700 | [diff] [blame] | 998 | feature_indexes (feature_indexes_), |
Behdad Esfahbod | bfd549d | 2018-10-30 14:47:27 -0700 | [diff] [blame] | 999 | script_count(0),langsys_count(0) {} |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1000 | |
Ebrahim Byagowi | d0a706c | 2018-12-22 19:47:48 +0330 | [diff] [blame] | 1001 | bool visited (const OT::Script &s) |
Behdad Esfahbod | eb44bfc | 2018-10-25 21:42:19 -0700 | [diff] [blame] | 1002 | { |
| 1003 | /* We might have Null() object here. Don't want to involve |
| 1004 | * that in the memoize. So, detect empty objects and return. */ |
| 1005 | if (unlikely (!s.has_default_lang_sys () && |
| 1006 | !s.get_lang_sys_count ())) |
| 1007 | return true; |
| 1008 | |
Garret Rieger | 0e1ad5a | 2018-10-30 11:29:58 -0700 | [diff] [blame] | 1009 | if (script_count++ > HB_MAX_SCRIPTS) |
| 1010 | return true; |
| 1011 | |
Behdad Esfahbod | eb44bfc | 2018-10-25 21:42:19 -0700 | [diff] [blame] | 1012 | return visited (s, visited_script); |
| 1013 | } |
Ebrahim Byagowi | d0a706c | 2018-12-22 19:47:48 +0330 | [diff] [blame] | 1014 | bool visited (const OT::LangSys &l) |
Behdad Esfahbod | eb44bfc | 2018-10-25 21:42:19 -0700 | [diff] [blame] | 1015 | { |
| 1016 | /* We might have Null() object here. Don't want to involve |
| 1017 | * that in the memoize. So, detect empty objects and return. */ |
| 1018 | if (unlikely (!l.has_required_feature () && |
| 1019 | !l.get_feature_count ())) |
| 1020 | return true; |
| 1021 | |
Garret Rieger | 0e1ad5a | 2018-10-30 11:29:58 -0700 | [diff] [blame] | 1022 | if (langsys_count++ > HB_MAX_LANGSYS) |
| 1023 | return true; |
| 1024 | |
Behdad Esfahbod | eb44bfc | 2018-10-25 21:42:19 -0700 | [diff] [blame] | 1025 | return visited (l, visited_langsys); |
| 1026 | } |
| 1027 | |
| 1028 | private: |
| 1029 | template <typename T> |
Ebrahim Byagowi | d0a706c | 2018-12-22 19:47:48 +0330 | [diff] [blame] | 1030 | bool visited (const T &p, hb_set_t &visited_set) |
Behdad Esfahbod | eb44bfc | 2018-10-25 21:42:19 -0700 | [diff] [blame] | 1031 | { |
| 1032 | hb_codepoint_t delta = (hb_codepoint_t) ((uintptr_t) &p - (uintptr_t) &g); |
| 1033 | if (visited_set.has (delta)) |
| 1034 | return true; |
| 1035 | |
| 1036 | visited_set.add (delta); |
| 1037 | return false; |
| 1038 | } |
| 1039 | |
| 1040 | public: |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1041 | const OT::GSUBGPOS &g; |
| 1042 | hb_set_t *feature_indexes; |
Behdad Esfahbod | eb44bfc | 2018-10-25 21:42:19 -0700 | [diff] [blame] | 1043 | |
| 1044 | private: |
Behdad Esfahbod | 3a4e5dd | 2018-10-29 18:05:25 -0700 | [diff] [blame] | 1045 | hb_set_t visited_script; |
| 1046 | hb_set_t visited_langsys; |
Garret Rieger | 0e1ad5a | 2018-10-30 11:29:58 -0700 | [diff] [blame] | 1047 | unsigned int script_count; |
| 1048 | unsigned int langsys_count; |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1049 | }; |
| 1050 | |
Behdad Esfahbod | a88e716 | 2012-11-24 02:31:02 -0500 | [diff] [blame] | 1051 | static void |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1052 | langsys_collect_features (hb_collect_features_context_t *c, |
Behdad Esfahbod | e8e6750 | 2018-10-25 20:48:20 -0700 | [diff] [blame] | 1053 | const OT::LangSys &l, |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1054 | const hb_tag_t *features) |
Behdad Esfahbod | a88e716 | 2012-11-24 02:31:02 -0500 | [diff] [blame] | 1055 | { |
Behdad Esfahbod | eb44bfc | 2018-10-25 21:42:19 -0700 | [diff] [blame] | 1056 | if (c->visited (l)) return; |
| 1057 | |
Behdad Esfahbod | a88e716 | 2012-11-24 02:31:02 -0500 | [diff] [blame] | 1058 | if (!features) |
| 1059 | { |
Behdad Esfahbod | e8e6750 | 2018-10-25 20:48:20 -0700 | [diff] [blame] | 1060 | /* All features. */ |
Behdad Esfahbod | eb44bfc | 2018-10-25 21:42:19 -0700 | [diff] [blame] | 1061 | if (l.has_required_feature ()) |
| 1062 | c->feature_indexes->add (l.get_required_feature_index ()); |
Behdad Esfahbod | 5f85c80 | 2013-06-26 20:14:18 -0400 | [diff] [blame] | 1063 | |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1064 | l.add_feature_indexes_to (c->feature_indexes); |
Behdad Esfahbod | 15e9e4e | 2013-01-03 00:04:40 -0600 | [diff] [blame] | 1065 | } |
| 1066 | else |
| 1067 | { |
Behdad Esfahbod | e8e6750 | 2018-10-25 20:48:20 -0700 | [diff] [blame] | 1068 | /* Ugh. Any faster way? */ |
Behdad Esfahbod | a88e716 | 2012-11-24 02:31:02 -0500 | [diff] [blame] | 1069 | for (; *features; features++) |
| 1070 | { |
Behdad Esfahbod | e8e6750 | 2018-10-25 20:48:20 -0700 | [diff] [blame] | 1071 | hb_tag_t feature_tag = *features; |
Behdad Esfahbod | e8e6750 | 2018-10-25 20:48:20 -0700 | [diff] [blame] | 1072 | unsigned int num_features = l.get_feature_count (); |
| 1073 | for (unsigned int i = 0; i < num_features; i++) |
| 1074 | { |
| 1075 | unsigned int feature_index = l.get_feature_index (i); |
| 1076 | |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1077 | if (feature_tag == c->g.get_feature_tag (feature_index)) |
Behdad Esfahbod | e8e6750 | 2018-10-25 20:48:20 -0700 | [diff] [blame] | 1078 | { |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1079 | c->feature_indexes->add (feature_index); |
Behdad Esfahbod | e8e6750 | 2018-10-25 20:48:20 -0700 | [diff] [blame] | 1080 | break; |
| 1081 | } |
| 1082 | } |
Behdad Esfahbod | a88e716 | 2012-11-24 02:31:02 -0500 | [diff] [blame] | 1083 | } |
| 1084 | } |
| 1085 | } |
| 1086 | |
| 1087 | static void |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1088 | script_collect_features (hb_collect_features_context_t *c, |
Behdad Esfahbod | fe5520d | 2018-10-25 20:58:34 -0700 | [diff] [blame] | 1089 | const OT::Script &s, |
| 1090 | const hb_tag_t *languages, |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1091 | const hb_tag_t *features) |
Behdad Esfahbod | a88e716 | 2012-11-24 02:31:02 -0500 | [diff] [blame] | 1092 | { |
Behdad Esfahbod | eb44bfc | 2018-10-25 21:42:19 -0700 | [diff] [blame] | 1093 | if (c->visited (s)) return; |
| 1094 | |
Behdad Esfahbod | a88e716 | 2012-11-24 02:31:02 -0500 | [diff] [blame] | 1095 | if (!languages) |
| 1096 | { |
Behdad Esfahbod | e8e6750 | 2018-10-25 20:48:20 -0700 | [diff] [blame] | 1097 | /* All languages. */ |
Behdad Esfahbod | eb44bfc | 2018-10-25 21:42:19 -0700 | [diff] [blame] | 1098 | if (s.has_default_lang_sys ()) |
| 1099 | langsys_collect_features (c, |
| 1100 | s.get_default_lang_sys (), |
| 1101 | features); |
Behdad Esfahbod | e8e6750 | 2018-10-25 20:48:20 -0700 | [diff] [blame] | 1102 | |
Behdad Esfahbod | fe5520d | 2018-10-25 20:58:34 -0700 | [diff] [blame] | 1103 | unsigned int count = s.get_lang_sys_count (); |
Behdad Esfahbod | a88e716 | 2012-11-24 02:31:02 -0500 | [diff] [blame] | 1104 | for (unsigned int language_index = 0; language_index < count; language_index++) |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1105 | langsys_collect_features (c, |
Behdad Esfahbod | fe5520d | 2018-10-25 20:58:34 -0700 | [diff] [blame] | 1106 | s.get_lang_sys (language_index), |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1107 | features); |
Behdad Esfahbod | 15e9e4e | 2013-01-03 00:04:40 -0600 | [diff] [blame] | 1108 | } |
| 1109 | else |
| 1110 | { |
Behdad Esfahbod | a88e716 | 2012-11-24 02:31:02 -0500 | [diff] [blame] | 1111 | for (; *languages; languages++) |
| 1112 | { |
| 1113 | unsigned int language_index; |
Behdad Esfahbod | fe5520d | 2018-10-25 20:58:34 -0700 | [diff] [blame] | 1114 | if (s.find_lang_sys_index (*languages, &language_index)) |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1115 | langsys_collect_features (c, |
Behdad Esfahbod | fe5520d | 2018-10-25 20:58:34 -0700 | [diff] [blame] | 1116 | s.get_lang_sys (language_index), |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1117 | features); |
Garret Rieger | 7d92bef | 2018-07-30 17:17:43 -0700 | [diff] [blame] | 1118 | } |
| 1119 | } |
| 1120 | } |
| 1121 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1122 | |
Garret Rieger | 7d92bef | 2018-07-30 17:17:43 -0700 | [diff] [blame] | 1123 | /** |
Garret Rieger | 8973375 | 2018-07-30 18:10:43 -0700 | [diff] [blame] | 1124 | * hb_ot_layout_collect_features: |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1125 | * @face: #hb_face_t to work upon |
| 1126 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 1127 | * @scripts: The array of scripts to collect features for |
| 1128 | * @languages: The array of languages to collect features for |
| 1129 | * @features: The array of features to collect |
Nathan Willis | 5122805 | 2019-03-17 14:43:06 +0000 | [diff] [blame] | 1130 | * @feature_indexes: (out): The array of feature indexes found for the query |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1131 | * |
| 1132 | * Fetches a list of all feature indexes in the specified face's GSUB table |
| 1133 | * or GPOS table, underneath the specified scripts, languages, and features. |
| 1134 | * If no list of scripts is provided, all scripts will be queried. If no list |
| 1135 | * of languages is provided, all languages will be queried. If no list of |
| 1136 | * features is provided, all features will be queried. |
Garret Rieger | 7d92bef | 2018-07-30 17:17:43 -0700 | [diff] [blame] | 1137 | * |
Behdad Esfahbod | 44d1fb3 | 2018-08-01 14:51:51 -0700 | [diff] [blame] | 1138 | * Since: 1.8.5 |
Garret Rieger | 7d92bef | 2018-07-30 17:17:43 -0700 | [diff] [blame] | 1139 | **/ |
| 1140 | void |
| 1141 | hb_ot_layout_collect_features (hb_face_t *face, |
| 1142 | hb_tag_t table_tag, |
| 1143 | const hb_tag_t *scripts, |
| 1144 | const hb_tag_t *languages, |
| 1145 | const hb_tag_t *features, |
| 1146 | hb_set_t *feature_indexes /* OUT */) |
| 1147 | { |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1148 | hb_collect_features_context_t c (face, table_tag, feature_indexes); |
Garret Rieger | 7d92bef | 2018-07-30 17:17:43 -0700 | [diff] [blame] | 1149 | if (!scripts) |
| 1150 | { |
Behdad Esfahbod | e8e6750 | 2018-10-25 20:48:20 -0700 | [diff] [blame] | 1151 | /* All scripts. */ |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1152 | unsigned int count = c.g.get_script_count (); |
Garret Rieger | 7d92bef | 2018-07-30 17:17:43 -0700 | [diff] [blame] | 1153 | for (unsigned int script_index = 0; script_index < count; script_index++) |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1154 | script_collect_features (&c, |
| 1155 | c.g.get_script (script_index), |
Behdad Esfahbod | fe5520d | 2018-10-25 20:58:34 -0700 | [diff] [blame] | 1156 | languages, |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1157 | features); |
Garret Rieger | 7d92bef | 2018-07-30 17:17:43 -0700 | [diff] [blame] | 1158 | } |
| 1159 | else |
| 1160 | { |
| 1161 | for (; *scripts; scripts++) |
| 1162 | { |
| 1163 | unsigned int script_index; |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1164 | if (c.g.find_script_index (*scripts, &script_index)) |
| 1165 | script_collect_features (&c, |
| 1166 | c.g.get_script (script_index), |
Behdad Esfahbod | fe5520d | 2018-10-25 20:58:34 -0700 | [diff] [blame] | 1167 | languages, |
Behdad Esfahbod | 941600a | 2018-10-25 21:26:08 -0700 | [diff] [blame] | 1168 | features); |
Behdad Esfahbod | a88e716 | 2012-11-24 02:31:02 -0500 | [diff] [blame] | 1169 | } |
| 1170 | } |
| 1171 | } |
| 1172 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1173 | |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 1174 | /** |
Khaled Hosny | d7bf9d0 | 2015-12-29 02:23:24 +0400 | [diff] [blame] | 1175 | * hb_ot_layout_collect_lookups: |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1176 | * @face: #hb_face_t to work upon |
| 1177 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 1178 | * @scripts: The array of scripts to collect lookups for |
| 1179 | * @languages: The array of languages to collect lookups for |
| 1180 | * @features: The array of features to collect lookups for |
Nathan Willis | 5122805 | 2019-03-17 14:43:06 +0000 | [diff] [blame] | 1181 | * @lookup_indexes: (out): The array of lookup indexes found for the query |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1182 | * |
| 1183 | * Fetches a list of all feature-lookup indexes in the specified face's GSUB |
| 1184 | * table or GPOS table, underneath the specified scripts, languages, and |
| 1185 | * features. If no list of scripts is provided, all scripts will be queried. |
| 1186 | * If no list of languages is provided, all languages will be queried. If no |
| 1187 | * list of features is provided, all features will be queried. |
Khaled Hosny | d7bf9d0 | 2015-12-29 02:23:24 +0400 | [diff] [blame] | 1188 | * |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 1189 | * Since: 0.9.8 |
| 1190 | **/ |
Behdad Esfahbod | a88e716 | 2012-11-24 02:31:02 -0500 | [diff] [blame] | 1191 | void |
| 1192 | hb_ot_layout_collect_lookups (hb_face_t *face, |
| 1193 | hb_tag_t table_tag, |
| 1194 | const hb_tag_t *scripts, |
| 1195 | const hb_tag_t *languages, |
| 1196 | const hb_tag_t *features, |
| 1197 | hb_set_t *lookup_indexes /* OUT */) |
| 1198 | { |
Behdad Esfahbod | e98af6d | 2018-10-25 22:25:29 -0700 | [diff] [blame] | 1199 | const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); |
| 1200 | |
Behdad Esfahbod | 3a4e5dd | 2018-10-29 18:05:25 -0700 | [diff] [blame] | 1201 | hb_set_t feature_indexes; |
Garret Rieger | 7d92bef | 2018-07-30 17:17:43 -0700 | [diff] [blame] | 1202 | hb_ot_layout_collect_features (face, table_tag, scripts, languages, features, &feature_indexes); |
Behdad Esfahbod | e98af6d | 2018-10-25 22:25:29 -0700 | [diff] [blame] | 1203 | |
Behdad Esfahbod | c237cdf | 2018-10-25 21:17:30 -0700 | [diff] [blame] | 1204 | for (hb_codepoint_t feature_index = HB_SET_VALUE_INVALID; |
| 1205 | hb_set_next (&feature_indexes, &feature_index);) |
Behdad Esfahbod | e98af6d | 2018-10-25 22:25:29 -0700 | [diff] [blame] | 1206 | g.get_feature (feature_index).add_lookup_indexes_to (lookup_indexes); |
Behdad Esfahbod | a88e716 | 2012-11-24 02:31:02 -0500 | [diff] [blame] | 1207 | } |
| 1208 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1209 | |
Behdad Esfahbod | fce3bf8 | 2019-06-19 20:34:29 -0700 | [diff] [blame] | 1210 | #ifndef HB_NO_LAYOUT_COLLECT_GLYPHS |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 1211 | /** |
Khaled Hosny | d7bf9d0 | 2015-12-29 02:23:24 +0400 | [diff] [blame] | 1212 | * hb_ot_layout_lookup_collect_glyphs: |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1213 | * @face: #hb_face_t to work upon |
| 1214 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 1215 | * @lookup_index: The index of the feature lookup to query |
Nathan Willis | 5122805 | 2019-03-17 14:43:06 +0000 | [diff] [blame] | 1216 | * @glyphs_before: (out): Array of glyphs preceding the substitution range |
| 1217 | * @glyphs_input: (out): Array of input glyphs that would be substituted by the lookup |
| 1218 | * @glyphs_after: (out): Array of glyphs following the substition range |
| 1219 | * @glyphs_output: (out): Array of glyphs that would be the substitued output of the lookup |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1220 | * |
| 1221 | * Fetches a list of all glyphs affected by the specified lookup in the |
| 1222 | * specified face's GSUB table of GPOS table. |
Khaled Hosny | d7bf9d0 | 2015-12-29 02:23:24 +0400 | [diff] [blame] | 1223 | * |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 1224 | * Since: 0.9.7 |
| 1225 | **/ |
Behdad Esfahbod | e8cfdd7 | 2012-11-16 19:07:06 -0800 | [diff] [blame] | 1226 | void |
| 1227 | hb_ot_layout_lookup_collect_glyphs (hb_face_t *face, |
| 1228 | hb_tag_t table_tag, |
| 1229 | unsigned int lookup_index, |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 1230 | hb_set_t *glyphs_before, /* OUT. May be NULL */ |
| 1231 | hb_set_t *glyphs_input, /* OUT. May be NULL */ |
| 1232 | hb_set_t *glyphs_after, /* OUT. May be NULL */ |
| 1233 | hb_set_t *glyphs_output /* OUT. May be NULL */) |
Behdad Esfahbod | e8cfdd7 | 2012-11-16 19:07:06 -0800 | [diff] [blame] | 1234 | { |
Behdad Esfahbod | 733e8c0 | 2013-01-03 00:00:23 -0600 | [diff] [blame] | 1235 | OT::hb_collect_glyphs_context_t c (face, |
| 1236 | glyphs_before, |
| 1237 | glyphs_input, |
| 1238 | glyphs_after, |
| 1239 | glyphs_output); |
Behdad Esfahbod | e8cfdd7 | 2012-11-16 19:07:06 -0800 | [diff] [blame] | 1240 | |
Behdad Esfahbod | 15e9e4e | 2013-01-03 00:04:40 -0600 | [diff] [blame] | 1241 | switch (table_tag) |
| 1242 | { |
Behdad Esfahbod | e8cfdd7 | 2012-11-16 19:07:06 -0800 | [diff] [blame] | 1243 | case HB_OT_TAG_GSUB: |
| 1244 | { |
Behdad Esfahbod | 0fe7a74 | 2018-11-05 23:08:33 -0500 | [diff] [blame] | 1245 | const OT::SubstLookup& l = face->table.GSUB->table->get_lookup (lookup_index); |
Behdad Esfahbod | 780cd93 | 2013-05-03 17:33:16 -0400 | [diff] [blame] | 1246 | l.collect_glyphs (&c); |
Behdad Esfahbod | e8cfdd7 | 2012-11-16 19:07:06 -0800 | [diff] [blame] | 1247 | return; |
| 1248 | } |
| 1249 | case HB_OT_TAG_GPOS: |
| 1250 | { |
Behdad Esfahbod | 0fe7a74 | 2018-11-05 23:08:33 -0500 | [diff] [blame] | 1251 | const OT::PosLookup& l = face->table.GPOS->table->get_lookup (lookup_index); |
Behdad Esfahbod | 780cd93 | 2013-05-03 17:33:16 -0400 | [diff] [blame] | 1252 | l.collect_glyphs (&c); |
Behdad Esfahbod | e8cfdd7 | 2012-11-16 19:07:06 -0800 | [diff] [blame] | 1253 | return; |
| 1254 | } |
| 1255 | } |
| 1256 | } |
Behdad Esfahbod | fce3bf8 | 2019-06-19 20:34:29 -0700 | [diff] [blame] | 1257 | #endif |
Behdad Esfahbod | e8cfdd7 | 2012-11-16 19:07:06 -0800 | [diff] [blame] | 1258 | |
Behdad Esfahbod | 2d15e72 | 2009-04-15 19:50:16 -0400 | [diff] [blame] | 1259 | |
Behdad Esfahbod | 30c42b6 | 2016-09-10 03:32:39 -0700 | [diff] [blame] | 1260 | /* Variations support */ |
| 1261 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1262 | |
| 1263 | /** |
| 1264 | * hb_ot_layout_table_find_feature_variations: |
| 1265 | * @face: #hb_face_t to work upon |
| 1266 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 1267 | * @coords: The variation coordinates to query |
| 1268 | * @num_coords: The number of variation coorinates |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 1269 | * @variations_index: (out): The array of feature variations found for the query |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1270 | * |
| 1271 | * Fetches a list of feature variations in the specified face's GSUB table |
| 1272 | * or GPOS table, at the specified variation coordinates. |
| 1273 | * |
| 1274 | **/ |
Behdad Esfahbod | 30c42b6 | 2016-09-10 03:32:39 -0700 | [diff] [blame] | 1275 | hb_bool_t |
| 1276 | hb_ot_layout_table_find_feature_variations (hb_face_t *face, |
| 1277 | hb_tag_t table_tag, |
| 1278 | const int *coords, |
| 1279 | unsigned int num_coords, |
| 1280 | unsigned int *variations_index /* out */) |
| 1281 | { |
| 1282 | const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); |
| 1283 | |
| 1284 | return g.find_variations_index (coords, num_coords, variations_index); |
| 1285 | } |
| 1286 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1287 | |
| 1288 | /** |
| 1289 | * hb_ot_layout_feature_with_variations_get_lookups: |
| 1290 | * @face: #hb_face_t to work upon |
| 1291 | * @table_tag: HB_OT_TAG_GSUB or HB_OT_TAG_GPOS |
| 1292 | * @feature_index: The index of the feature to query |
| 1293 | * @variations_index: The index of the feature variation to query |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 1294 | * @start_offset: offset of the first lookup to retrieve |
| 1295 | * @lookup_count: (inout) (allow-none): Input = the maximum number of lookups to return; |
| 1296 | * Output = the actual number of lookups returned (may be zero) |
| 1297 | * @lookup_indexes: (out) (array length=lookup_count): The array of lookups found for the query |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1298 | * |
| 1299 | * Fetches a list of all lookups enumerated for the specified feature, in |
| 1300 | * the specified face's GSUB table or GPOS table, enabled at the specified |
| 1301 | * variations index. The list returned will begin at the offset provided. |
| 1302 | * |
| 1303 | **/ |
Behdad Esfahbod | ec87ba9 | 2016-09-10 03:53:11 -0700 | [diff] [blame] | 1304 | unsigned int |
| 1305 | hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face, |
| 1306 | hb_tag_t table_tag, |
| 1307 | unsigned int feature_index, |
| 1308 | unsigned int variations_index, |
| 1309 | unsigned int start_offset, |
| 1310 | unsigned int *lookup_count /* IN/OUT */, |
| 1311 | unsigned int *lookup_indexes /* OUT */) |
| 1312 | { |
Behdad Esfahbod | 606bf57 | 2018-09-16 19:33:48 +0200 | [diff] [blame] | 1313 | static_assert ((OT::FeatureVariations::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_VARIATIONS_INDEX), ""); |
Behdad Esfahbod | ec87ba9 | 2016-09-10 03:53:11 -0700 | [diff] [blame] | 1314 | const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); |
| 1315 | |
| 1316 | const OT::Feature &f = g.get_feature_variation (feature_index, variations_index); |
| 1317 | |
| 1318 | return f.get_lookup_indexes (start_offset, lookup_count, lookup_indexes); |
| 1319 | } |
| 1320 | |
Behdad Esfahbod | 30c42b6 | 2016-09-10 03:32:39 -0700 | [diff] [blame] | 1321 | |
Behdad Esfahbod | 2d15e72 | 2009-04-15 19:50:16 -0400 | [diff] [blame] | 1322 | /* |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 1323 | * OT::GSUB |
Behdad Esfahbod | 2d15e72 | 2009-04-15 19:50:16 -0400 | [diff] [blame] | 1324 | */ |
| 1325 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1326 | |
| 1327 | /** |
| 1328 | * hb_ot_layout_has_substitution: |
| 1329 | * @face: #hb_face_t to work upon |
| 1330 | * |
| 1331 | * Tests whether the specified face includes any GSUB substitutions. |
| 1332 | * |
| 1333 | * Return value: true if data found, false otherwise |
| 1334 | * |
| 1335 | **/ |
Behdad Esfahbod | 2d15e72 | 2009-04-15 19:50:16 -0400 | [diff] [blame] | 1336 | hb_bool_t |
Behdad Esfahbod | 0ead481 | 2009-08-02 17:41:36 -0400 | [diff] [blame] | 1337 | hb_ot_layout_has_substitution (hb_face_t *face) |
| 1338 | { |
Behdad Esfahbod | 737efbe | 2018-11-05 23:26:29 -0500 | [diff] [blame] | 1339 | return face->table.GSUB->table->has_data (); |
Behdad Esfahbod | 0ead481 | 2009-08-02 17:41:36 -0400 | [diff] [blame] | 1340 | } |
| 1341 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1342 | |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 1343 | /** |
Khaled Hosny | d7bf9d0 | 2015-12-29 02:23:24 +0400 | [diff] [blame] | 1344 | * hb_ot_layout_lookup_would_substitute: |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1345 | * @face: #hb_face_t to work upon |
| 1346 | * @lookup_index: The index of the lookup to query |
| 1347 | * @glyphs: The sequence of glyphs to query for substitution |
| 1348 | * @glyphs_length: The length of the glyph sequence |
| 1349 | * @zero_context: #hb_bool_t indicating whether substitutions should be context-free |
| 1350 | * |
| 1351 | * Tests whether a specified lookup in the specified face would |
| 1352 | * trigger a substitution on the given glyph sequence. |
| 1353 | * |
| 1354 | * Return value: true if a substitution would be triggered, false otherwise |
Khaled Hosny | d7bf9d0 | 2015-12-29 02:23:24 +0400 | [diff] [blame] | 1355 | * |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 1356 | * Since: 0.9.7 |
| 1357 | **/ |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1358 | hb_bool_t |
Behdad Esfahbod | 362a990 | 2012-11-15 14:57:31 -0800 | [diff] [blame] | 1359 | hb_ot_layout_lookup_would_substitute (hb_face_t *face, |
Behdad Esfahbod | d9b204d | 2012-08-23 16:22:28 -0400 | [diff] [blame] | 1360 | unsigned int lookup_index, |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1361 | const hb_codepoint_t *glyphs, |
| 1362 | unsigned int glyphs_length, |
Behdad Esfahbod | d9b204d | 2012-08-23 16:22:28 -0400 | [diff] [blame] | 1363 | hb_bool_t zero_context) |
Behdad Esfahbod | e72b360 | 2012-07-19 14:35:23 -0400 | [diff] [blame] | 1364 | { |
Behdad Esfahbod | 0fe7a74 | 2018-11-05 23:08:33 -0500 | [diff] [blame] | 1365 | if (unlikely (lookup_index >= face->table.GSUB->lookup_count)) return false; |
Behdad Esfahbod | ea512f7 | 2015-11-26 19:22:22 -0500 | [diff] [blame] | 1366 | OT::hb_would_apply_context_t c (face, glyphs, glyphs_length, (bool) zero_context); |
Behdad Esfahbod | 2bd9fe3 | 2012-09-04 15:15:19 -0400 | [diff] [blame] | 1367 | |
Behdad Esfahbod | 0fe7a74 | 2018-11-05 23:08:33 -0500 | [diff] [blame] | 1368 | const OT::SubstLookup& l = face->table.GSUB->table->get_lookup (lookup_index); |
Behdad Esfahbod | 2bd9fe3 | 2012-09-04 15:15:19 -0400 | [diff] [blame] | 1369 | |
Behdad Esfahbod | 0fe7a74 | 2018-11-05 23:08:33 -0500 | [diff] [blame] | 1370 | return l.would_apply (&c, &face->table.GSUB->accels[lookup_index]); |
Behdad Esfahbod | f860366 | 2012-07-30 02:38:39 -0400 | [diff] [blame] | 1371 | } |
| 1372 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1373 | |
| 1374 | /** |
| 1375 | * hb_ot_layout_substitute_start: |
| 1376 | * @font: #hb_font_t to use |
| 1377 | * @buffer: #hb_buffer_t buffer to work upon |
| 1378 | * |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 1379 | * Called before substitution lookups are performed, to ensure that glyph |
| 1380 | * class and other properties are set on the glyphs in the buffer. |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1381 | * |
| 1382 | **/ |
Behdad Esfahbod | 46d6a21 | 2011-05-11 22:33:13 -0400 | [diff] [blame] | 1383 | void |
Behdad Esfahbod | c624e18 | 2018-08-26 09:19:20 -0700 | [diff] [blame] | 1384 | hb_ot_layout_substitute_start (hb_font_t *font, |
| 1385 | hb_buffer_t *buffer) |
Behdad Esfahbod | 46d6a21 | 2011-05-11 22:33:13 -0400 | [diff] [blame] | 1386 | { |
Behdad Esfahbod | c624e18 | 2018-08-26 09:19:20 -0700 | [diff] [blame] | 1387 | _hb_ot_layout_set_glyph_props (font, buffer); |
Behdad Esfahbod | 46d6a21 | 2011-05-11 22:33:13 -0400 | [diff] [blame] | 1388 | } |
| 1389 | |
Behdad Esfahbod | 385f78b | 2018-11-07 17:19:21 -0500 | [diff] [blame] | 1390 | void |
| 1391 | hb_ot_layout_delete_glyphs_inplace (hb_buffer_t *buffer, |
| 1392 | bool (*filter) (const hb_glyph_info_t *info)) |
| 1393 | { |
| 1394 | /* Merge clusters and delete filtered glyphs. |
| 1395 | * NOTE! We can't use out-buffer as we have positioning data. */ |
| 1396 | unsigned int j = 0; |
| 1397 | unsigned int count = buffer->len; |
| 1398 | hb_glyph_info_t *info = buffer->info; |
| 1399 | hb_glyph_position_t *pos = buffer->pos; |
| 1400 | for (unsigned int i = 0; i < count; i++) |
| 1401 | { |
| 1402 | if (filter (&info[i])) |
| 1403 | { |
| 1404 | /* Merge clusters. |
| 1405 | * Same logic as buffer->delete_glyph(), but for in-place removal. */ |
| 1406 | |
| 1407 | unsigned int cluster = info[i].cluster; |
| 1408 | if (i + 1 < count && cluster == info[i + 1].cluster) |
| 1409 | continue; /* Cluster survives; do nothing. */ |
| 1410 | |
| 1411 | if (j) |
| 1412 | { |
| 1413 | /* Merge cluster backward. */ |
| 1414 | if (cluster < info[j - 1].cluster) |
| 1415 | { |
| 1416 | unsigned int mask = info[i].mask; |
| 1417 | unsigned int old_cluster = info[j - 1].cluster; |
| 1418 | for (unsigned k = j; k && info[k - 1].cluster == old_cluster; k--) |
| 1419 | buffer->set_cluster (info[k - 1], cluster, mask); |
| 1420 | } |
| 1421 | continue; |
| 1422 | } |
| 1423 | |
| 1424 | if (i + 1 < count) |
| 1425 | buffer->merge_clusters (i, i + 2); /* Merge cluster forward. */ |
| 1426 | |
| 1427 | continue; |
| 1428 | } |
| 1429 | |
| 1430 | if (j != i) |
| 1431 | { |
| 1432 | info[j] = info[i]; |
| 1433 | pos[j] = pos[i]; |
| 1434 | } |
| 1435 | j++; |
| 1436 | } |
| 1437 | buffer->len = j; |
| 1438 | } |
| 1439 | |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 1440 | /** |
Khaled Hosny | d7bf9d0 | 2015-12-29 02:23:24 +0400 | [diff] [blame] | 1441 | * hb_ot_layout_lookup_substitute_closure: |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1442 | * @face: #hb_face_t to work upon |
| 1443 | * @lookup_index: index of the feature lookup to query |
Nathan Willis | 5122805 | 2019-03-17 14:43:06 +0000 | [diff] [blame] | 1444 | * @glyphs: (out): Array of glyphs comprising the transitive closure of the lookup |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1445 | * |
| 1446 | * Compute the transitive closure of glyphs needed for a |
| 1447 | * specified lookup. |
Khaled Hosny | d7bf9d0 | 2015-12-29 02:23:24 +0400 | [diff] [blame] | 1448 | * |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 1449 | * Since: 0.9.7 |
| 1450 | **/ |
Behdad Esfahbod | 5caece6 | 2012-04-23 23:03:12 -0400 | [diff] [blame] | 1451 | void |
Behdad Esfahbod | 362a990 | 2012-11-15 14:57:31 -0800 | [diff] [blame] | 1452 | hb_ot_layout_lookup_substitute_closure (hb_face_t *face, |
Behdad Esfahbod | d9b204d | 2012-08-23 16:22:28 -0400 | [diff] [blame] | 1453 | unsigned int lookup_index, |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1454 | hb_set_t *glyphs /* OUT */) |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 1455 | { |
Behdad Esfahbod | 3a4e5dd | 2018-10-29 18:05:25 -0700 | [diff] [blame] | 1456 | hb_map_t done_lookups; |
Garret Rieger | 45186b9 | 2018-06-05 17:14:42 -0700 | [diff] [blame] | 1457 | OT::hb_closure_context_t c (face, glyphs, &done_lookups); |
Behdad Esfahbod | 9b34677 | 2012-11-23 17:55:40 -0500 | [diff] [blame] | 1458 | |
Behdad Esfahbod | 737efbe | 2018-11-05 23:26:29 -0500 | [diff] [blame] | 1459 | const OT::SubstLookup& l = face->table.GSUB->table->get_lookup (lookup_index); |
Behdad Esfahbod | 9b34677 | 2012-11-23 17:55:40 -0500 | [diff] [blame] | 1460 | |
Garret Rieger | 45186b9 | 2018-06-05 17:14:42 -0700 | [diff] [blame] | 1461 | l.closure (&c, lookup_index); |
Behdad Esfahbod | f94b0aa | 2012-04-23 13:04:38 -0400 | [diff] [blame] | 1462 | } |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 1463 | |
Garret Rieger | 57badad | 2018-06-06 16:02:51 -0700 | [diff] [blame] | 1464 | /** |
| 1465 | * hb_ot_layout_lookups_substitute_closure: |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1466 | * @face: #hb_face_t to work upon |
| 1467 | * @lookups: The set of lookups to query |
Nathan Willis | 5122805 | 2019-03-17 14:43:06 +0000 | [diff] [blame] | 1468 | * @glyphs: (out): Array of glyphs comprising the transitive closure of the lookups |
Garret Rieger | 57badad | 2018-06-06 16:02:51 -0700 | [diff] [blame] | 1469 | * |
| 1470 | * Compute the transitive closure of glyphs needed for all of the |
| 1471 | * provided lookups. |
| 1472 | * |
| 1473 | * Since: 1.8.1 |
| 1474 | **/ |
| 1475 | void |
| 1476 | hb_ot_layout_lookups_substitute_closure (hb_face_t *face, |
| 1477 | const hb_set_t *lookups, |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1478 | hb_set_t *glyphs /* OUT */) |
Garret Rieger | 57badad | 2018-06-06 16:02:51 -0700 | [diff] [blame] | 1479 | { |
Behdad Esfahbod | 3a4e5dd | 2018-10-29 18:05:25 -0700 | [diff] [blame] | 1480 | hb_map_t done_lookups; |
Garret Rieger | 57badad | 2018-06-06 16:02:51 -0700 | [diff] [blame] | 1481 | OT::hb_closure_context_t c (face, glyphs, &done_lookups); |
Behdad Esfahbod | 737efbe | 2018-11-05 23:26:29 -0500 | [diff] [blame] | 1482 | const OT::GSUB& gsub = *face->table.GSUB->table; |
Garret Rieger | 57badad | 2018-06-06 16:02:51 -0700 | [diff] [blame] | 1483 | |
Garret Rieger | 85646fd | 2018-07-23 15:37:18 -0700 | [diff] [blame] | 1484 | unsigned int iteration_count = 0; |
Garret Rieger | 57badad | 2018-06-06 16:02:51 -0700 | [diff] [blame] | 1485 | unsigned int glyphs_length; |
| 1486 | do |
| 1487 | { |
| 1488 | glyphs_length = glyphs->get_population (); |
Garret Rieger | feb2389 | 2018-06-07 14:32:34 -0700 | [diff] [blame] | 1489 | if (lookups != nullptr) |
| 1490 | { |
| 1491 | for (hb_codepoint_t lookup_index = HB_SET_VALUE_INVALID; hb_set_next (lookups, &lookup_index);) |
| 1492 | gsub.get_lookup (lookup_index).closure (&c, lookup_index); |
Behdad Esfahbod | f56cd9d | 2018-06-11 22:02:38 -0400 | [diff] [blame] | 1493 | } |
| 1494 | else |
| 1495 | { |
Garret Rieger | feb2389 | 2018-06-07 14:32:34 -0700 | [diff] [blame] | 1496 | for (unsigned int i = 0; i < gsub.get_lookup_count (); i++) |
| 1497 | gsub.get_lookup (i).closure (&c, i); |
| 1498 | } |
Behdad Esfahbod | e44046e | 2018-11-10 22:41:35 -0500 | [diff] [blame] | 1499 | } while (iteration_count++ <= HB_CLOSURE_MAX_STAGES && |
| 1500 | glyphs_length != glyphs->get_population ()); |
Garret Rieger | 57badad | 2018-06-06 16:02:51 -0700 | [diff] [blame] | 1501 | } |
| 1502 | |
Behdad Esfahbod | 9c42f05 | 2009-05-18 17:43:49 -0400 | [diff] [blame] | 1503 | /* |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 1504 | * OT::GPOS |
Behdad Esfahbod | 9c42f05 | 2009-05-18 17:43:49 -0400 | [diff] [blame] | 1505 | */ |
| 1506 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1507 | |
| 1508 | /** |
| 1509 | * hb_ot_layout_has_positioning: |
| 1510 | * @face: #hb_face_t to work upon |
| 1511 | * |
| 1512 | * Return value: true if the face has GPOS data, false otherwise |
| 1513 | * |
| 1514 | **/ |
Behdad Esfahbod | 9c42f05 | 2009-05-18 17:43:49 -0400 | [diff] [blame] | 1515 | hb_bool_t |
Behdad Esfahbod | 0ead481 | 2009-08-02 17:41:36 -0400 | [diff] [blame] | 1516 | hb_ot_layout_has_positioning (hb_face_t *face) |
| 1517 | { |
Behdad Esfahbod | 737efbe | 2018-11-05 23:26:29 -0500 | [diff] [blame] | 1518 | return face->table.GPOS->table->has_data (); |
Behdad Esfahbod | 0ead481 | 2009-08-02 17:41:36 -0400 | [diff] [blame] | 1519 | } |
| 1520 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1521 | /** |
| 1522 | * hb_ot_layout_position_start: |
| 1523 | * @font: #hb_font_t to use |
| 1524 | * @buffer: #hb_buffer_t buffer to work upon |
| 1525 | * |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 1526 | * Called before positioning lookups are performed, to ensure that glyph |
| 1527 | * attachment types and glyph-attachment chains are set for the glyphs in the buffer. |
| 1528 | * |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1529 | **/ |
Behdad Esfahbod | 8f0d7e0 | 2011-04-15 18:59:56 -0400 | [diff] [blame] | 1530 | void |
Behdad Esfahbod | 05bd1b6 | 2012-07-30 19:30:01 -0400 | [diff] [blame] | 1531 | hb_ot_layout_position_start (hb_font_t *font, hb_buffer_t *buffer) |
Behdad Esfahbod | 8f0d7e0 | 2011-04-15 18:59:56 -0400 | [diff] [blame] | 1532 | { |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 1533 | OT::GPOS::position_start (font, buffer); |
Behdad Esfahbod | 8f0d7e0 | 2011-04-15 18:59:56 -0400 | [diff] [blame] | 1534 | } |
| 1535 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1536 | |
| 1537 | /** |
| 1538 | * hb_ot_layout_position_finish_advances: |
| 1539 | * @font: #hb_font_t to use |
| 1540 | * @buffer: #hb_buffer_t buffer to work upon |
| 1541 | * |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 1542 | * Called after positioning lookups are performed, to finish glyph advances. |
| 1543 | * |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1544 | **/ |
Behdad Esfahbod | 9db8ad7 | 2009-11-06 16:47:31 -0500 | [diff] [blame] | 1545 | void |
Behdad Esfahbod | 7d8d58a | 2016-02-11 16:34:28 +0700 | [diff] [blame] | 1546 | hb_ot_layout_position_finish_advances (hb_font_t *font, hb_buffer_t *buffer) |
Behdad Esfahbod | 9db8ad7 | 2009-11-06 16:47:31 -0500 | [diff] [blame] | 1547 | { |
Behdad Esfahbod | 7d8d58a | 2016-02-11 16:34:28 +0700 | [diff] [blame] | 1548 | OT::GPOS::position_finish_advances (font, buffer); |
| 1549 | } |
| 1550 | |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 1551 | /** |
| 1552 | * hb_ot_layout_position_finish_offsets: |
| 1553 | * @font: #hb_font_t to use |
| 1554 | * @buffer: #hb_buffer_t buffer to work upon |
| 1555 | * |
| 1556 | * Called after positioning lookups are performed, to finish glyph offsets. |
| 1557 | * |
| 1558 | **/ |
Behdad Esfahbod | 7d8d58a | 2016-02-11 16:34:28 +0700 | [diff] [blame] | 1559 | void |
| 1560 | hb_ot_layout_position_finish_offsets (hb_font_t *font, hb_buffer_t *buffer) |
| 1561 | { |
| 1562 | OT::GPOS::position_finish_offsets (font, buffer); |
Behdad Esfahbod | 9db8ad7 | 2009-11-06 16:47:31 -0500 | [diff] [blame] | 1563 | } |
Behdad Esfahbod | f54cce3 | 2012-11-26 14:02:31 +0200 | [diff] [blame] | 1564 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1565 | |
Behdad Esfahbod | 6c725c7 | 2019-06-19 20:12:25 -0700 | [diff] [blame] | 1566 | #ifndef HB_NO_LAYOUT_FEATURE_PARAMS |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 1567 | /** |
Khaled Hosny | d7bf9d0 | 2015-12-29 02:23:24 +0400 | [diff] [blame] | 1568 | * hb_ot_layout_get_size_params: |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1569 | * @face: #hb_face_t to work upon |
Nathan Willis | 5122805 | 2019-03-17 14:43:06 +0000 | [diff] [blame] | 1570 | * @design_size: (out): The design size of the face |
| 1571 | * @subfamily_id: (out): The identifier of the face within the font subfamily |
Nathan Willis | c08ddbd | 2019-03-24 15:07:07 +0000 | [diff] [blame] | 1572 | * @subfamily_name_id: (out): The ‘name’ table name ID of the face within the font subfamily |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 1573 | * @range_start: (out): The minimum size of the recommended size range for the face |
| 1574 | * @range_end: (out): The maximum size of the recommended size range for the face |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1575 | * |
Nathan Willis | c08ddbd | 2019-03-24 15:07:07 +0000 | [diff] [blame] | 1576 | * Fetches optical-size feature data (i.e., the `size` feature from GPOS). Note that |
| 1577 | * the subfamily_id and the subfamily name string (accessible via the subfamily_name_id) |
| 1578 | * as used here are defined as pertaining only to fonts within a font family that differ |
| 1579 | * specifically in their respective size ranges; other ways to differentiate fonts within |
| 1580 | * a subfamily are not covered by the `size` feature. |
| 1581 | * |
| 1582 | * For more information on this distinction, see the `size` documentation at |
| 1583 | * https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#tag-39size39 |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1584 | * |
| 1585 | * Return value: true if data found, false otherwise |
Khaled Hosny | d7bf9d0 | 2015-12-29 02:23:24 +0400 | [diff] [blame] | 1586 | * |
Behdad Esfahbod | b881142 | 2015-09-03 15:53:22 +0430 | [diff] [blame] | 1587 | * Since: 0.9.10 |
Sascha Brawer | 01c3a88 | 2015-06-01 13:22:01 +0200 | [diff] [blame] | 1588 | **/ |
Behdad Esfahbod | f54cce3 | 2012-11-26 14:02:31 +0200 | [diff] [blame] | 1589 | hb_bool_t |
Behdad Esfahbod | a7aba99 | 2018-10-30 14:04:09 -0700 | [diff] [blame] | 1590 | hb_ot_layout_get_size_params (hb_face_t *face, |
| 1591 | unsigned int *design_size, /* OUT. May be NULL */ |
| 1592 | unsigned int *subfamily_id, /* OUT. May be NULL */ |
| 1593 | hb_ot_name_id_t *subfamily_name_id, /* OUT. May be NULL */ |
| 1594 | unsigned int *range_start, /* OUT. May be NULL */ |
| 1595 | unsigned int *range_end /* OUT. May be NULL */) |
Behdad Esfahbod | f54cce3 | 2012-11-26 14:02:31 +0200 | [diff] [blame] | 1596 | { |
Behdad Esfahbod | 737efbe | 2018-11-05 23:26:29 -0500 | [diff] [blame] | 1597 | const OT::GPOS &gpos = *face->table.GPOS->table; |
Behdad Esfahbod | efe252e | 2012-12-17 23:21:05 -0500 | [diff] [blame] | 1598 | const hb_tag_t tag = HB_TAG ('s','i','z','e'); |
Behdad Esfahbod | f54cce3 | 2012-11-26 14:02:31 +0200 | [diff] [blame] | 1599 | |
Behdad Esfahbod | 0dff11f | 2012-11-30 08:14:20 +0200 | [diff] [blame] | 1600 | unsigned int num_features = gpos.get_feature_count (); |
| 1601 | for (unsigned int i = 0; i < num_features; i++) |
| 1602 | { |
Behdad Esfahbod | efe252e | 2012-12-17 23:21:05 -0500 | [diff] [blame] | 1603 | if (tag == gpos.get_feature_tag (i)) |
Behdad Esfahbod | f54cce3 | 2012-11-26 14:02:31 +0200 | [diff] [blame] | 1604 | { |
Behdad Esfahbod | 0dff11f | 2012-11-30 08:14:20 +0200 | [diff] [blame] | 1605 | const OT::Feature &f = gpos.get_feature (i); |
Behdad Esfahbod | efe252e | 2012-12-17 23:21:05 -0500 | [diff] [blame] | 1606 | const OT::FeatureParamsSize ¶ms = f.get_feature_params ().get_size_params (tag); |
Behdad Esfahbod | f54cce3 | 2012-11-26 14:02:31 +0200 | [diff] [blame] | 1607 | |
Behdad Esfahbod | efe252e | 2012-12-17 23:21:05 -0500 | [diff] [blame] | 1608 | if (params.designSize) |
Behdad Esfahbod | 85bc44b | 2012-12-12 11:38:49 -0500 | [diff] [blame] | 1609 | { |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 1610 | if (design_size) *design_size = params.designSize; |
| 1611 | if (subfamily_id) *subfamily_id = params.subfamilyID; |
Behdad Esfahbod | 6ce49a9 | 2018-10-28 08:26:30 -0700 | [diff] [blame] | 1612 | if (subfamily_name_id) *subfamily_name_id = params.subfamilyNameID; |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 1613 | if (range_start) *range_start = params.rangeStart; |
| 1614 | if (range_end) *range_end = params.rangeEnd; |
Behdad Esfahbod | efe252e | 2012-12-17 23:21:05 -0500 | [diff] [blame] | 1615 | |
| 1616 | return true; |
| 1617 | } |
Behdad Esfahbod | f54cce3 | 2012-11-26 14:02:31 +0200 | [diff] [blame] | 1618 | } |
| 1619 | } |
| 1620 | |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 1621 | if (design_size) *design_size = 0; |
| 1622 | if (subfamily_id) *subfamily_id = 0; |
Behdad Esfahbod | a7aba99 | 2018-10-30 14:04:09 -0700 | [diff] [blame] | 1623 | if (subfamily_name_id) *subfamily_name_id = HB_OT_NAME_ID_INVALID; |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 1624 | if (range_start) *range_start = 0; |
| 1625 | if (range_end) *range_end = 0; |
Behdad Esfahbod | f54cce3 | 2012-11-26 14:02:31 +0200 | [diff] [blame] | 1626 | |
Behdad Esfahbod | efe252e | 2012-12-17 23:21:05 -0500 | [diff] [blame] | 1627 | return false; |
Behdad Esfahbod | f54cce3 | 2012-11-26 14:02:31 +0200 | [diff] [blame] | 1628 | } |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1629 | /** |
| 1630 | * hb_ot_layout_feature_get_name_ids: |
| 1631 | * @face: #hb_face_t to work upon |
Behdad Esfahbod | a5ad8c6 | 2018-10-20 16:52:55 -0700 | [diff] [blame] | 1632 | * @table_tag: table tag to query, "GSUB" or "GPOS". |
| 1633 | * @feature_index: index of feature to query. |
Nathan Willis | af5230b | 2019-03-18 14:03:16 +0000 | [diff] [blame] | 1634 | * @label_id: (out) (allow-none): The ‘name’ table name ID that specifies a string |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1635 | * for a user-interface label for this feature. (May be NULL.) |
Nathan Willis | af5230b | 2019-03-18 14:03:16 +0000 | [diff] [blame] | 1636 | * @tooltip_id: (out) (allow-none): The ‘name’ table name ID that specifies a string |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1637 | * that an application can use for tooltip text for this |
| 1638 | * feature. (May be NULL.) |
Nathan Willis | af5230b | 2019-03-18 14:03:16 +0000 | [diff] [blame] | 1639 | * @sample_id: (out) (allow-none): The ‘name’ table name ID that specifies sample text |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1640 | * that illustrates the effect of this feature. (May be NULL.) |
Nathan Willis | af5230b | 2019-03-18 14:03:16 +0000 | [diff] [blame] | 1641 | * @num_named_parameters: (out) (allow-none): Number of named parameters. (May be zero.) |
| 1642 | * @first_param_id: (out) (allow-none): The first ‘name’ table name ID used to specify |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1643 | * strings for user-interface labels for the feature |
| 1644 | * parameters. (Must be zero if numParameters is zero.) |
| 1645 | * |
Behdad Esfahbod | c0a6814 | 2018-10-12 16:05:56 -0400 | [diff] [blame] | 1646 | * Fetches name indices from feature parameters for "Stylistic Set" ('ssXX') or |
| 1647 | * "Character Variant" ('cvXX') features. |
| 1648 | * |
| 1649 | * Return value: true if data found, false otherwise |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1650 | * |
Behdad Esfahbod | 3d9a030 | 2018-10-18 05:58:17 -0700 | [diff] [blame] | 1651 | * Since: 2.0.0 |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1652 | **/ |
| 1653 | hb_bool_t |
Behdad Esfahbod | a7aba99 | 2018-10-30 14:04:09 -0700 | [diff] [blame] | 1654 | hb_ot_layout_feature_get_name_ids (hb_face_t *face, |
| 1655 | hb_tag_t table_tag, |
| 1656 | unsigned int feature_index, |
| 1657 | hb_ot_name_id_t *label_id, /* OUT. May be NULL */ |
| 1658 | hb_ot_name_id_t *tooltip_id, /* OUT. May be NULL */ |
| 1659 | hb_ot_name_id_t *sample_id, /* OUT. May be NULL */ |
| 1660 | unsigned int *num_named_parameters, /* OUT. May be NULL */ |
| 1661 | hb_ot_name_id_t *first_param_id /* OUT. May be NULL */) |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1662 | { |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1663 | const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); |
| 1664 | |
Behdad Esfahbod | c0a6814 | 2018-10-12 16:05:56 -0400 | [diff] [blame] | 1665 | hb_tag_t feature_tag = g.get_feature_tag (feature_index); |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1666 | const OT::Feature &f = g.get_feature (feature_index); |
| 1667 | |
| 1668 | const OT::FeatureParams &feature_params = f.get_feature_params (); |
| 1669 | if (&feature_params != &Null (OT::FeatureParams)) |
| 1670 | { |
| 1671 | const OT::FeatureParamsStylisticSet& ss_params = |
| 1672 | feature_params.get_stylistic_set_params (feature_tag); |
| 1673 | if (&ss_params != &Null (OT::FeatureParamsStylisticSet)) /* ssXX */ |
| 1674 | { |
Behdad Esfahbod | 6ce49a9 | 2018-10-28 08:26:30 -0700 | [diff] [blame] | 1675 | if (label_id) *label_id = ss_params.uiNameID; |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1676 | // ssXX features don't have the rest |
Behdad Esfahbod | a7aba99 | 2018-10-30 14:04:09 -0700 | [diff] [blame] | 1677 | if (tooltip_id) *tooltip_id = HB_OT_NAME_ID_INVALID; |
| 1678 | if (sample_id) *sample_id = HB_OT_NAME_ID_INVALID; |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 1679 | if (num_named_parameters) *num_named_parameters = 0; |
Behdad Esfahbod | a7aba99 | 2018-10-30 14:04:09 -0700 | [diff] [blame] | 1680 | if (first_param_id) *first_param_id = HB_OT_NAME_ID_INVALID; |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1681 | return true; |
| 1682 | } |
| 1683 | const OT::FeatureParamsCharacterVariants& cv_params = |
| 1684 | feature_params.get_character_variants_params (feature_tag); |
| 1685 | if (&cv_params != &Null (OT::FeatureParamsCharacterVariants)) /* cvXX */ |
| 1686 | { |
Behdad Esfahbod | 6ce49a9 | 2018-10-28 08:26:30 -0700 | [diff] [blame] | 1687 | if (label_id) *label_id = cv_params.featUILableNameID; |
| 1688 | if (tooltip_id) *tooltip_id = cv_params.featUITooltipTextNameID; |
| 1689 | if (sample_id) *sample_id = cv_params.sampleTextNameID; |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 1690 | if (num_named_parameters) *num_named_parameters = cv_params.numNamedParameters; |
Behdad Esfahbod | 6ce49a9 | 2018-10-28 08:26:30 -0700 | [diff] [blame] | 1691 | if (first_param_id) *first_param_id = cv_params.firstParamUILabelNameID; |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1692 | return true; |
| 1693 | } |
| 1694 | } |
| 1695 | |
Behdad Esfahbod | a7aba99 | 2018-10-30 14:04:09 -0700 | [diff] [blame] | 1696 | if (label_id) *label_id = HB_OT_NAME_ID_INVALID; |
| 1697 | if (tooltip_id) *tooltip_id = HB_OT_NAME_ID_INVALID; |
| 1698 | if (sample_id) *sample_id = HB_OT_NAME_ID_INVALID; |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 1699 | if (num_named_parameters) *num_named_parameters = 0; |
Behdad Esfahbod | a7aba99 | 2018-10-30 14:04:09 -0700 | [diff] [blame] | 1700 | if (first_param_id) *first_param_id = HB_OT_NAME_ID_INVALID; |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1701 | return false; |
| 1702 | } |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1703 | /** |
Behdad Esfahbod | a5ad8c6 | 2018-10-20 16:52:55 -0700 | [diff] [blame] | 1704 | * hb_ot_layout_feature_get_characters: |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1705 | * @face: #hb_face_t to work upon |
Behdad Esfahbod | a5ad8c6 | 2018-10-20 16:52:55 -0700 | [diff] [blame] | 1706 | * @table_tag: table tag to query, "GSUB" or "GPOS". |
| 1707 | * @feature_index: index of feature to query. |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 1708 | * @start_offset: offset of the first character to retrieve |
| 1709 | * @char_count: (inout) (allow-none): Input = the maximum number of characters to return; |
| 1710 | * Output = the actual number of characters returned (may be zero) |
| 1711 | * @characters: (out caller-allocates) (array length=char_count): A buffer pointer. |
| 1712 | * The Unicode codepoints of the characters for which this feature provides |
| 1713 | * glyph variants. |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1714 | * |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 1715 | * Fetches a list of the characters defined as having a variant under the specified |
| 1716 | * "Character Variant" ("cvXX") feature tag. |
Behdad Esfahbod | c0a6814 | 2018-10-12 16:05:56 -0400 | [diff] [blame] | 1717 | * |
Nathan Willis | 3db2272 | 2019-04-02 18:49:40 +0100 | [diff] [blame] | 1718 | * <note>Note: If the char_count output value is equal to its input value, then there |
| 1719 | * is a chance there were more characters defined under the feature tag than were |
| 1720 | * returned. This function can be called with incrementally larger start_offset |
| 1721 | * until the char_count output value is lower than its input value, or the size |
| 1722 | * of the characters array can be increased.</note> |
| 1723 | * |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1724 | * Return value: Number of total sample characters in the cvXX feature. |
| 1725 | * |
Behdad Esfahbod | 3d9a030 | 2018-10-18 05:58:17 -0700 | [diff] [blame] | 1726 | * Since: 2.0.0 |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1727 | **/ |
| 1728 | unsigned int |
| 1729 | hb_ot_layout_feature_get_characters (hb_face_t *face, |
| 1730 | hb_tag_t table_tag, |
| 1731 | unsigned int feature_index, |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1732 | unsigned int start_offset, |
| 1733 | unsigned int *char_count, /* IN/OUT. May be NULL */ |
| 1734 | hb_codepoint_t *characters /* OUT. May be NULL */) |
| 1735 | { |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1736 | const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); |
| 1737 | |
Behdad Esfahbod | c0a6814 | 2018-10-12 16:05:56 -0400 | [diff] [blame] | 1738 | hb_tag_t feature_tag = g.get_feature_tag (feature_index); |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1739 | const OT::Feature &f = g.get_feature (feature_index); |
| 1740 | |
| 1741 | const OT::FeatureParams &feature_params = f.get_feature_params (); |
| 1742 | |
| 1743 | const OT::FeatureParamsCharacterVariants& cv_params = |
| 1744 | feature_params.get_character_variants_params(feature_tag); |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 1745 | |
| 1746 | unsigned int len = 0; |
| 1747 | if (char_count && characters && start_offset < cv_params.characters.len) |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1748 | { |
Behdad Esfahbod | 41248cc | 2019-05-07 20:54:31 -0700 | [diff] [blame] | 1749 | len = hb_min (cv_params.characters.len - start_offset, *char_count); |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 1750 | for (unsigned int i = 0; i < len; ++i) |
| 1751 | characters[i] = cv_params.characters[start_offset + i]; |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1752 | } |
Ebrahim Byagowi | 6310943 | 2018-10-13 14:00:05 +0330 | [diff] [blame] | 1753 | if (char_count) *char_count = len; |
| 1754 | return cv_params.characters.len; |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1755 | } |
Behdad Esfahbod | 6c725c7 | 2019-06-19 20:12:25 -0700 | [diff] [blame] | 1756 | #endif |
Ebrahim Byagowi | dc49bd8 | 2018-10-12 03:00:59 +0330 | [diff] [blame] | 1757 | |
Behdad Esfahbod | d2c9681 | 2013-05-02 18:18:24 -0400 | [diff] [blame] | 1758 | |
| 1759 | /* |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 1760 | * Parts of different types are implemented here such that they have direct |
Behdad Esfahbod | d2c9681 | 2013-05-02 18:18:24 -0400 | [diff] [blame] | 1761 | * access to GSUB/GPOS lookups. |
| 1762 | */ |
| 1763 | |
| 1764 | |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 1765 | struct GSUBProxy |
| 1766 | { |
Behdad Esfahbod | 5d4b037 | 2019-01-22 12:11:24 +0100 | [diff] [blame] | 1767 | static constexpr unsigned table_index = 0u; |
Behdad Esfahbod | 39e1b6d | 2019-01-22 12:07:43 +0100 | [diff] [blame] | 1768 | static constexpr bool inplace = false; |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 1769 | typedef OT::SubstLookup Lookup; |
| 1770 | |
| 1771 | GSUBProxy (hb_face_t *face) : |
Behdad Esfahbod | 0fe7a74 | 2018-11-05 23:08:33 -0500 | [diff] [blame] | 1772 | table (*face->table.GSUB->table), |
| 1773 | accels (face->table.GSUB->accels) {} |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 1774 | |
| 1775 | const OT::GSUB &table; |
Behdad Esfahbod | 97e5913 | 2018-10-10 11:41:05 -0400 | [diff] [blame] | 1776 | const OT::hb_ot_layout_lookup_accelerator_t *accels; |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 1777 | }; |
| 1778 | |
| 1779 | struct GPOSProxy |
| 1780 | { |
Behdad Esfahbod | 5d4b037 | 2019-01-22 12:11:24 +0100 | [diff] [blame] | 1781 | static constexpr unsigned table_index = 1u; |
Behdad Esfahbod | 39e1b6d | 2019-01-22 12:07:43 +0100 | [diff] [blame] | 1782 | static constexpr bool inplace = true; |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 1783 | typedef OT::PosLookup Lookup; |
| 1784 | |
| 1785 | GPOSProxy (hb_face_t *face) : |
Behdad Esfahbod | 0fe7a74 | 2018-11-05 23:08:33 -0500 | [diff] [blame] | 1786 | table (*face->table.GPOS->table), |
| 1787 | accels (face->table.GPOS->accels) {} |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 1788 | |
| 1789 | const OT::GPOS &table; |
Behdad Esfahbod | 97e5913 | 2018-10-10 11:41:05 -0400 | [diff] [blame] | 1790 | const OT::hb_ot_layout_lookup_accelerator_t *accels; |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 1791 | }; |
| 1792 | |
| 1793 | |
Behdad Esfahbod | e2f50f2 | 2015-02-19 17:15:05 +0300 | [diff] [blame] | 1794 | static inline bool |
Behdad Esfahbod | fd03449 | 2018-01-17 16:46:51 -0800 | [diff] [blame] | 1795 | apply_forward (OT::hb_ot_apply_context_t *c, |
Behdad Esfahbod | 78c09bf | 2018-10-10 11:50:46 -0400 | [diff] [blame] | 1796 | const OT::hb_ot_layout_lookup_accelerator_t &accel) |
Behdad Esfahbod | e2f50f2 | 2015-02-19 17:15:05 +0300 | [diff] [blame] | 1797 | { |
| 1798 | bool ret = false; |
| 1799 | hb_buffer_t *buffer = c->buffer; |
Behdad Esfahbod | 7185b27 | 2018-05-31 20:03:00 -0700 | [diff] [blame] | 1800 | while (buffer->idx < buffer->len && buffer->successful) |
Behdad Esfahbod | e2f50f2 | 2015-02-19 17:15:05 +0300 | [diff] [blame] | 1801 | { |
Behdad Esfahbod | 3e70452 | 2016-01-11 17:38:41 +0000 | [diff] [blame] | 1802 | bool applied = false; |
Behdad Esfahbod | e2f50f2 | 2015-02-19 17:15:05 +0300 | [diff] [blame] | 1803 | if (accel.may_have (buffer->cur().codepoint) && |
| 1804 | (buffer->cur().mask & c->lookup_mask) && |
Behdad Esfahbod | 3e70452 | 2016-01-11 17:38:41 +0000 | [diff] [blame] | 1805 | c->check_glyph_property (&buffer->cur(), c->lookup_props)) |
| 1806 | { |
Behdad Esfahbod | e78549e | 2018-10-10 11:54:48 -0400 | [diff] [blame] | 1807 | applied = accel.apply (c); |
Behdad Esfahbod | 3e70452 | 2016-01-11 17:38:41 +0000 | [diff] [blame] | 1808 | } |
| 1809 | |
| 1810 | if (applied) |
Behdad Esfahbod | e2f50f2 | 2015-02-19 17:15:05 +0300 | [diff] [blame] | 1811 | ret = true; |
| 1812 | else |
| 1813 | buffer->next_glyph (); |
| 1814 | } |
| 1815 | return ret; |
| 1816 | } |
| 1817 | |
Behdad Esfahbod | e2f50f2 | 2015-02-19 17:15:05 +0300 | [diff] [blame] | 1818 | static inline bool |
Behdad Esfahbod | fd03449 | 2018-01-17 16:46:51 -0800 | [diff] [blame] | 1819 | apply_backward (OT::hb_ot_apply_context_t *c, |
Behdad Esfahbod | 78c09bf | 2018-10-10 11:50:46 -0400 | [diff] [blame] | 1820 | const OT::hb_ot_layout_lookup_accelerator_t &accel) |
Behdad Esfahbod | e2f50f2 | 2015-02-19 17:15:05 +0300 | [diff] [blame] | 1821 | { |
| 1822 | bool ret = false; |
| 1823 | hb_buffer_t *buffer = c->buffer; |
| 1824 | do |
| 1825 | { |
| 1826 | if (accel.may_have (buffer->cur().codepoint) && |
| 1827 | (buffer->cur().mask & c->lookup_mask) && |
Behdad Esfahbod | 3e70452 | 2016-01-11 17:38:41 +0000 | [diff] [blame] | 1828 | c->check_glyph_property (&buffer->cur(), c->lookup_props)) |
Behdad Esfahbod | 9af983a | 2018-11-07 16:03:09 -0500 | [diff] [blame] | 1829 | ret |= accel.apply (c); |
| 1830 | |
Behdad Esfahbod | e2f50f2 | 2015-02-19 17:15:05 +0300 | [diff] [blame] | 1831 | /* The reverse lookup doesn't "advance" cursor (for good reason). */ |
| 1832 | buffer->idx--; |
| 1833 | |
| 1834 | } |
| 1835 | while ((int) buffer->idx >= 0); |
| 1836 | return ret; |
| 1837 | } |
| 1838 | |
Behdad Esfahbod | 45f3d98 | 2013-05-03 17:49:44 -0400 | [diff] [blame] | 1839 | template <typename Proxy> |
Behdad Esfahbod | 1d4a328 | 2015-02-19 11:33:30 +0300 | [diff] [blame] | 1840 | static inline void |
Behdad Esfahbod | fd03449 | 2018-01-17 16:46:51 -0800 | [diff] [blame] | 1841 | apply_string (OT::hb_ot_apply_context_t *c, |
Behdad Esfahbod | 45f3d98 | 2013-05-03 17:49:44 -0400 | [diff] [blame] | 1842 | const typename Proxy::Lookup &lookup, |
Behdad Esfahbod | 97e5913 | 2018-10-10 11:41:05 -0400 | [diff] [blame] | 1843 | const OT::hb_ot_layout_lookup_accelerator_t &accel) |
Behdad Esfahbod | 45f3d98 | 2013-05-03 17:49:44 -0400 | [diff] [blame] | 1844 | { |
Behdad Esfahbod | ac8cd51 | 2013-10-18 19:33:09 +0200 | [diff] [blame] | 1845 | hb_buffer_t *buffer = c->buffer; |
Behdad Esfahbod | 45f3d98 | 2013-05-03 17:49:44 -0400 | [diff] [blame] | 1846 | |
Behdad Esfahbod | 5337db2 | 2015-11-06 16:18:09 -0800 | [diff] [blame] | 1847 | if (unlikely (!buffer->len || !c->lookup_mask)) |
Behdad Esfahbod | 1d4a328 | 2015-02-19 11:33:30 +0300 | [diff] [blame] | 1848 | return; |
Behdad Esfahbod | 45f3d98 | 2013-05-03 17:49:44 -0400 | [diff] [blame] | 1849 | |
Behdad Esfahbod | 2c8b3b2 | 2015-08-18 14:36:43 +0100 | [diff] [blame] | 1850 | c->set_lookup_props (lookup.get_props ()); |
Behdad Esfahbod | 45f3d98 | 2013-05-03 17:49:44 -0400 | [diff] [blame] | 1851 | |
| 1852 | if (likely (!lookup.is_reverse ())) |
| 1853 | { |
| 1854 | /* in/out forward substitution/positioning */ |
Behdad Esfahbod | 271cb7c | 2019-01-22 12:05:35 +0100 | [diff] [blame] | 1855 | if (Proxy::table_index == 0u) |
Behdad Esfahbod | ac8cd51 | 2013-10-18 19:33:09 +0200 | [diff] [blame] | 1856 | buffer->clear_output (); |
| 1857 | buffer->idx = 0; |
Behdad Esfahbod | 45f3d98 | 2013-05-03 17:49:44 -0400 | [diff] [blame] | 1858 | |
Behdad Esfahbod | 640b66c | 2015-02-19 17:30:05 +0300 | [diff] [blame] | 1859 | bool ret; |
Behdad Esfahbod | 78c09bf | 2018-10-10 11:50:46 -0400 | [diff] [blame] | 1860 | ret = apply_forward (c, accel); |
Behdad Esfahbod | 640b66c | 2015-02-19 17:30:05 +0300 | [diff] [blame] | 1861 | if (ret) |
Behdad Esfahbod | 9d9e72e | 2013-05-03 18:10:10 -0400 | [diff] [blame] | 1862 | { |
Behdad Esfahbod | 6ffc007 | 2013-10-28 19:26:02 +0100 | [diff] [blame] | 1863 | if (!Proxy::inplace) |
Behdad Esfahbod | ac8cd51 | 2013-10-18 19:33:09 +0200 | [diff] [blame] | 1864 | buffer->swap_buffers (); |
Behdad Esfahbod | 9d9e72e | 2013-05-03 18:10:10 -0400 | [diff] [blame] | 1865 | else |
Behdad Esfahbod | 1d4a328 | 2015-02-19 11:33:30 +0300 | [diff] [blame] | 1866 | assert (!buffer->has_separate_output ()); |
Behdad Esfahbod | 9d9e72e | 2013-05-03 18:10:10 -0400 | [diff] [blame] | 1867 | } |
Behdad Esfahbod | 45f3d98 | 2013-05-03 17:49:44 -0400 | [diff] [blame] | 1868 | } |
| 1869 | else |
| 1870 | { |
| 1871 | /* in-place backward substitution/positioning */ |
Behdad Esfahbod | 271cb7c | 2019-01-22 12:05:35 +0100 | [diff] [blame] | 1872 | if (Proxy::table_index == 0u) |
Behdad Esfahbod | ac8cd51 | 2013-10-18 19:33:09 +0200 | [diff] [blame] | 1873 | buffer->remove_output (); |
| 1874 | buffer->idx = buffer->len - 1; |
Behdad Esfahbod | 45f3d98 | 2013-05-03 17:49:44 -0400 | [diff] [blame] | 1875 | |
Behdad Esfahbod | 78c09bf | 2018-10-10 11:50:46 -0400 | [diff] [blame] | 1876 | apply_backward (c, accel); |
Behdad Esfahbod | 45f3d98 | 2013-05-03 17:49:44 -0400 | [diff] [blame] | 1877 | } |
Behdad Esfahbod | 45f3d98 | 2013-05-03 17:49:44 -0400 | [diff] [blame] | 1878 | } |
| 1879 | |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 1880 | template <typename Proxy> |
| 1881 | inline void hb_ot_map_t::apply (const Proxy &proxy, |
Behdad Esfahbod | d2c9681 | 2013-05-02 18:18:24 -0400 | [diff] [blame] | 1882 | const hb_ot_shape_plan_t *plan, |
| 1883 | hb_font_t *font, |
| 1884 | hb_buffer_t *buffer) const |
| 1885 | { |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 1886 | const unsigned int table_index = proxy.table_index; |
Behdad Esfahbod | d2c9681 | 2013-05-02 18:18:24 -0400 | [diff] [blame] | 1887 | unsigned int i = 0; |
Behdad Esfahbod | fd03449 | 2018-01-17 16:46:51 -0800 | [diff] [blame] | 1888 | OT::hb_ot_apply_context_t c (table_index, font, buffer); |
Behdad Esfahbod | 45f3d98 | 2013-05-03 17:49:44 -0400 | [diff] [blame] | 1889 | c.set_recurse_func (Proxy::Lookup::apply_recurse_func); |
Behdad Esfahbod | d2c9681 | 2013-05-02 18:18:24 -0400 | [diff] [blame] | 1890 | |
Behdad Esfahbod | 474a120 | 2018-12-21 18:46:51 -0500 | [diff] [blame] | 1891 | for (unsigned int stage_index = 0; stage_index < stages[table_index].length; stage_index++) { |
Behdad Esfahbod | d2c9681 | 2013-05-02 18:18:24 -0400 | [diff] [blame] | 1892 | const stage_map_t *stage = &stages[table_index][stage_index]; |
| 1893 | for (; i < stage->last_lookup; i++) |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 1894 | { |
| 1895 | unsigned int lookup_index = lookups[table_index][i].index; |
Behdad Esfahbod | 0475ef2 | 2015-12-18 18:17:07 +0000 | [diff] [blame] | 1896 | if (!buffer->message (font, "start lookup %d", lookup_index)) continue; |
Behdad Esfahbod | 2c8b3b2 | 2015-08-18 14:36:43 +0100 | [diff] [blame] | 1897 | c.set_lookup_index (lookup_index); |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 1898 | c.set_lookup_mask (lookups[table_index][i].mask); |
| 1899 | c.set_auto_zwj (lookups[table_index][i].auto_zwj); |
Behdad Esfahbod | cdf1fd0 | 2017-07-14 12:43:34 +0100 | [diff] [blame] | 1900 | c.set_auto_zwnj (lookups[table_index][i].auto_zwnj); |
David Corbett | c2a75e0 | 2018-01-25 14:22:03 -0500 | [diff] [blame] | 1901 | if (lookups[table_index][i].random) |
| 1902 | { |
David Corbett | b545e27 | 2018-02-23 12:22:32 -0500 | [diff] [blame] | 1903 | c.set_random (true); |
David Corbett | c2a75e0 | 2018-01-25 14:22:03 -0500 | [diff] [blame] | 1904 | buffer->unsafe_to_break_all (); |
| 1905 | } |
Behdad Esfahbod | 45f3d98 | 2013-05-03 17:49:44 -0400 | [diff] [blame] | 1906 | apply_string<Proxy> (&c, |
| 1907 | proxy.table.get_lookup (lookup_index), |
| 1908 | proxy.accels[lookup_index]); |
Behdad Esfahbod | 0475ef2 | 2015-12-18 18:17:07 +0000 | [diff] [blame] | 1909 | (void) buffer->message (font, "end lookup %d", lookup_index); |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 1910 | } |
Behdad Esfahbod | d2c9681 | 2013-05-02 18:18:24 -0400 | [diff] [blame] | 1911 | |
| 1912 | if (stage->pause_func) |
| 1913 | { |
| 1914 | buffer->clear_output (); |
| 1915 | stage->pause_func (plan, font, buffer); |
| 1916 | } |
| 1917 | } |
| 1918 | } |
| 1919 | |
| 1920 | void hb_ot_map_t::substitute (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const |
| 1921 | { |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 1922 | GSUBProxy proxy (font->face); |
| 1923 | apply (proxy, plan, font, buffer); |
Behdad Esfahbod | d2c9681 | 2013-05-02 18:18:24 -0400 | [diff] [blame] | 1924 | } |
| 1925 | |
| 1926 | void hb_ot_map_t::position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const |
| 1927 | { |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 1928 | GPOSProxy proxy (font->face); |
| 1929 | apply (proxy, plan, font, buffer); |
| 1930 | } |
| 1931 | |
Behdad Esfahbod | cdab20d | 2018-02-10 15:45:17 -0600 | [diff] [blame] | 1932 | void |
Behdad Esfahbod | fd03449 | 2018-01-17 16:46:51 -0800 | [diff] [blame] | 1933 | hb_ot_layout_substitute_lookup (OT::hb_ot_apply_context_t *c, |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 1934 | const OT::SubstLookup &lookup, |
Behdad Esfahbod | 97e5913 | 2018-10-10 11:41:05 -0400 | [diff] [blame] | 1935 | const OT::hb_ot_layout_lookup_accelerator_t &accel) |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 1936 | { |
Behdad Esfahbod | 45f3d98 | 2013-05-03 17:49:44 -0400 | [diff] [blame] | 1937 | apply_string<GSUBProxy> (c, lookup, accel); |
Behdad Esfahbod | d2c9681 | 2013-05-02 18:18:24 -0400 | [diff] [blame] | 1938 | } |
Ebrahim Byagowi | b8a78ce | 2018-11-03 22:28:30 +0330 | [diff] [blame] | 1939 | |
| 1940 | #if 0 |
Ebrahim Byagowi | b8a78ce | 2018-11-03 22:28:30 +0330 | [diff] [blame] | 1941 | hb_bool_t |
| 1942 | hb_ot_layout_get_baseline (hb_font_t *font, |
| 1943 | hb_ot_layout_baseline_t baseline, |
| 1944 | hb_direction_t direction, |
| 1945 | hb_tag_t script_tag, |
| 1946 | hb_tag_t language_tag, |
| 1947 | hb_position_t *coord /* OUT. May be NULL. */) |
| 1948 | { |
Behdad Esfahbod | f0b0fd4 | 2019-06-18 14:40:24 -0700 | [diff] [blame] | 1949 | bool result = font->face->table.BASE->get_baseline (font, baseline, direction, script_tag, |
| 1950 | language_tag, coord); |
Ebrahim Byagowi | b8a78ce | 2018-11-03 22:28:30 +0330 | [diff] [blame] | 1951 | |
| 1952 | /* TODO: Simulate https://docs.microsoft.com/en-us/typography/opentype/spec/baselinetags#ideographic-em-box */ |
| 1953 | if (!result && coord) *coord = 0; |
| 1954 | |
| 1955 | if (coord) *coord = font->em_scale_dir (*coord, direction); |
| 1956 | |
| 1957 | return result; |
| 1958 | } |
| 1959 | |
| 1960 | /* To be moved to public header */ |
| 1961 | /* |
| 1962 | * BASE |
| 1963 | */ |
| 1964 | |
| 1965 | /** |
| 1966 | * hb_ot_layout_baseline_t: |
| 1967 | * |
| 1968 | * https://docs.microsoft.com/en-us/typography/opentype/spec/baselinetags |
| 1969 | * |
| 1970 | * Since: DONTREPLACEME |
| 1971 | */ |
| 1972 | typedef enum { |
| 1973 | HB_OT_LAYOUT_BASELINE_HANG = HB_TAG('h','a','n','g'), |
| 1974 | HB_OT_LAYOUT_BASELINE_ICFB = HB_TAG('i','c','f','b'), |
| 1975 | HB_OT_LAYOUT_BASELINE_ICFT = HB_TAG('i','c','f','t'), |
| 1976 | HB_OT_LAYOUT_BASELINE_IDEO = HB_TAG('i','d','e','o'), |
| 1977 | HB_OT_LAYOUT_BASELINE_IDTB = HB_TAG('i','d','t','b'), |
| 1978 | HB_OT_LAYOUT_BASELINE_MATH = HB_TAG('m','a','t','h'), |
| 1979 | HB_OT_LAYOUT_BASELINE_ROMN = HB_TAG('r','o','m','n') |
| 1980 | } hb_ot_layout_baseline_t; |
| 1981 | |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1982 | |
| 1983 | /** |
| 1984 | * hb_ot_layout_get_baseline: |
| 1985 | * @font: The #hb_font_t to work upon |
| 1986 | * @baseline: The #hb_ot_layout_baseline_t to query |
Nathan Willis | c08ddbd | 2019-03-24 15:07:07 +0000 | [diff] [blame] | 1987 | * @direction: The #hb_direction_t text direction to use (horizontal or vertical) |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1988 | * @script_tag: #hb_tag_t of the script to use |
| 1989 | * @language_tag: #hb_tag_t of the language to use |
Nathan Willis | 5122805 | 2019-03-17 14:43:06 +0000 | [diff] [blame] | 1990 | * @coord: (out): The position of the requested baseline |
Nathan Willis | 930f6fc | 2019-03-16 15:10:21 +0000 | [diff] [blame] | 1991 | * |
| 1992 | * Fetches the coordinates of the specified baseline in the face, underneath |
| 1993 | * the specified script and language and in the specified text direction. |
| 1994 | * |
| 1995 | * Return value: true if the baseline is found for the settings queried, false otherwise |
| 1996 | * |
| 1997 | **/ |
Ebrahim Byagowi | b8a78ce | 2018-11-03 22:28:30 +0330 | [diff] [blame] | 1998 | HB_EXTERN hb_bool_t |
| 1999 | hb_ot_layout_get_baseline (hb_font_t *font, |
| 2000 | hb_ot_layout_baseline_t baseline, |
| 2001 | hb_direction_t direction, |
| 2002 | hb_tag_t script_tag, |
| 2003 | hb_tag_t language_tag, |
| 2004 | hb_position_t *coord /* OUT. May be NULL. */); |
| 2005 | |
| 2006 | #endif |
Behdad Esfahbod | bb4bbe6 | 2019-06-26 13:29:58 -0700 | [diff] [blame] | 2007 | |
| 2008 | |
| 2009 | #endif |