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