hb-ot-layout-gdef-table.hh revision 48de3730cdf91b9f6473509e22260a902ccec992
164aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod/* 2ee58aaebd296ea8237516754fd4e825d524b11b7Behdad Esfahbod * Copyright (C) 2007,2008,2009 Red Hat, Inc. 364aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * 464aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * This is part of HarfBuzz, an OpenType Layout engine library. 564aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * 664aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * Permission is hereby granted, without written agreement and without 764aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * license or royalty fees, to use, copy, modify, and distribute this 864aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * software and its documentation for any purpose, provided that the 964aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * above copyright notice and the following two paragraphs appear in 1064aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * all copies of this software. 1164aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * 1264aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 1364aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 1464aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 1564aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 1664aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * DAMAGE. 1764aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * 1864aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 1964aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 2064aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 2164aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 2264aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 2364aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * 2464aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * Red Hat Author(s): Behdad Esfahbod 2564aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod */ 2664aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod 275f5b24f99f52bbc922e238b65c06061ba07c8548Behdad Esfahbod#ifndef HB_OT_LAYOUT_GDEF_PRIVATE_HH 285f5b24f99f52bbc922e238b65c06061ba07c8548Behdad Esfahbod#define HB_OT_LAYOUT_GDEF_PRIVATE_HH 295b3f7702a64fe0513d08a67bdb72704e46fd7cd4Behdad Esfahbod 305f5b24f99f52bbc922e238b65c06061ba07c8548Behdad Esfahbod#include "hb-ot-layout-common-private.hh" 315b3f7702a64fe0513d08a67bdb72704e46fd7cd4Behdad Esfahbod 3223c86aa0009324433e78fcd0c47f2c0ff14b1949Behdad Esfahbod#include "hb-font-private.h" 3323c86aa0009324433e78fcd0c47f2c0ff14b1949Behdad Esfahbod 3412360f7c159826ae72271b34486dee59d96aa8caBehdad Esfahbod 351f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod/* 361f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod * Attachment List Table 371f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod */ 384c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod 39e4efdd80a8fa4edbcdec9cd84f35f5f4521943c2Behdad Esfahbodtypedef ArrayOf<USHORT> AttachPoint; /* Array of contour point indices--in 401f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod * increasing numerical order */ 418b8358033184198ff638ee1379093717596e162dBehdad EsfahbodASSERT_SIZE (AttachPoint, 2); 42303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod 4360d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct AttachList 4460d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 45e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod inline unsigned int get_attach_points (hb_codepoint_t glyph_id, 46e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int start_offset, 47e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int *point_count /* IN/OUT */, 48e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int *point_array /* OUT */) const 49855720ca47bf5a7a44eb5b84dce9f7da6e7156bdBehdad Esfahbod { 5079420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod unsigned int index = (this+coverage) (glyph_id); 5162964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod if (index == NOT_COVERED) 5262964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod { 53e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod if (point_count) 54e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod *point_count = 0; 55e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod return 0; 5662964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod } 57e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod 5879420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod const AttachPoint &points = this+attachPoint[index]; 5979420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod 60e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod if (point_count) { 6148de3730cdf91b9f6473509e22260a902ccec992Behdad Esfahbod const USHORT *array = points.const_sub_array (start_offset, point_count); 6248de3730cdf91b9f6473509e22260a902ccec992Behdad Esfahbod unsigned int count = *point_count; 63e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod for (unsigned int i = 0; i < count; i++) 64e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod point_array[i] = array[i]; 65e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod } 6662964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod 67e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod return points.len; 68855720ca47bf5a7a44eb5b84dce9f7da6e7156bdBehdad Esfahbod } 694c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod 70e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod inline bool sanitize (SANITIZE_ARG_DEF) { 713e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 72e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod return SANITIZE_THIS2 (coverage, attachPoint); 73e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod } 74e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod 75855720ca47bf5a7a44eb5b84dce9f7da6e7156bdBehdad Esfahbod private: 763d54bd1293069fc3d3bdeeea8ad45036f3ee65f3Behdad Esfahbod OffsetTo<Coverage> 773d54bd1293069fc3d3bdeeea8ad45036f3ee65f3Behdad Esfahbod coverage; /* Offset to Coverage table -- from 784c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod * beginning of AttachList table */ 795f810363acc3ad3cba631a68620e3d37e54c95c4Behdad Esfahbod OffsetArrayOf<AttachPoint> 805f810363acc3ad3cba631a68620e3d37e54c95c4Behdad Esfahbod attachPoint; /* Array of AttachPoint tables 815f810363acc3ad3cba631a68620e3d37e54c95c4Behdad Esfahbod * in Coverage Index order */ 824c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod}; 838b8358033184198ff638ee1379093717596e162dBehdad EsfahbodASSERT_SIZE (AttachList, 4); 844c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod 854c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod/* 864c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod * Ligature Caret Table 874c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod */ 884c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod 8960d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct CaretValueFormat1 9060d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 917586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod friend struct CaretValue; 927586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod 937586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod private: 940ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const 9560d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod { 96d0b657379bbe63602953412d6bc944b2a0f430ebBehdad Esfahbod /* TODO vertical */ 970ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod return context->font->x_scale * coordinate / 0x10000; 984c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod } 99303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod 100e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod inline bool sanitize (SANITIZE_ARG_DEF) { 1013e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 102e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod return SANITIZE_SELF (); 103e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod } 104e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod 105303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod private: 106303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod USHORT caretValueFormat; /* Format identifier--format = 1 */ 107303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod SHORT coordinate; /* X or Y value, in design units */ 1084c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod}; 10912360f7c159826ae72271b34486dee59d96aa8caBehdad EsfahbodASSERT_SIZE (CaretValueFormat1, 4); 1104c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod 11160d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct CaretValueFormat2 11260d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 1137586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod friend struct CaretValue; 1147586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod 1157586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod private: 1160ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const 11760d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod { 118e4efdd80a8fa4edbcdec9cd84f35f5f4521943c2Behdad Esfahbod return /* TODO contour point */ 0; 1194c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod } 120303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod 121e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod inline bool sanitize (SANITIZE_ARG_DEF) { 1223e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 123e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod return SANITIZE_SELF (); 124e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod } 125e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod 126303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod private: 127303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod USHORT caretValueFormat; /* Format identifier--format = 2 */ 128303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod USHORT caretValuePoint; /* Contour point index on glyph */ 1294c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod}; 13012360f7c159826ae72271b34486dee59d96aa8caBehdad EsfahbodASSERT_SIZE (CaretValueFormat2, 4); 1314c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod 13260d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct CaretValueFormat3 13360d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 1347586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod friend struct CaretValue; 1357586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod 1360ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const 13760d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod { 138d0b657379bbe63602953412d6bc944b2a0f430ebBehdad Esfahbod /* TODO vertical */ 1390ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod return context->font->x_scale * coordinate / 0x10000 + 14015164d9258a74122a4db748d35532bd72c47cec2Behdad Esfahbod ((this+deviceTable).get_delta (context->font->x_ppem) << 6); 141303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod } 142303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod 143e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod inline bool sanitize (SANITIZE_ARG_DEF) { 1443e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 145e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod return SANITIZE_SELF () && SANITIZE_THIS (deviceTable); 146e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod } 147e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod 148303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod private: 1494c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod USHORT caretValueFormat; /* Format identifier--format = 3 */ 1504c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod SHORT coordinate; /* X or Y value, in design units */ 151263bbef7670b59aa88ef9ba910579dfa51226524Behdad Esfahbod OffsetTo<Device> 152263bbef7670b59aa88ef9ba910579dfa51226524Behdad Esfahbod deviceTable; /* Offset to Device table for X or Y 1534c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod * value--from beginning of CaretValue 1544c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod * table */ 1554c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod}; 15612360f7c159826ae72271b34486dee59d96aa8caBehdad EsfahbodASSERT_SIZE (CaretValueFormat3, 6); 1574c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod 15860d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct CaretValue 15960d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 16020b035dad41247076815a2bbb0346d63058b322fBehdad Esfahbod inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const 16160d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod { 162f8dc67b3c24dfc805da756a73cb217b36e16b4b8Behdad Esfahbod switch (u.format) { 1630ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod case 1: return u.format1->get_caret_value (context, glyph_id); 1640ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod case 2: return u.format2->get_caret_value (context, glyph_id); 1650ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod case 3: return u.format3->get_caret_value (context, glyph_id); 1664c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod default:return 0; 1674c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod } 1684c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod } 1694c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod 170e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod inline bool sanitize (SANITIZE_ARG_DEF) { 1713e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 172e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod if (!SANITIZE (u.format)) return false; 173e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod switch (u.format) { 174e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod case 1: return u.format1->sanitize (SANITIZE_ARG); 175e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod case 2: return u.format2->sanitize (SANITIZE_ARG); 176e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod case 3: return u.format3->sanitize (SANITIZE_ARG); 177e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod default:return true; 178e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod } 179e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod } 180e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod 181303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod private: 1824c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod union { 183f8dc67b3c24dfc805da756a73cb217b36e16b4b8Behdad Esfahbod USHORT format; /* Format identifier */ 184d3480ba37fbb5d4be75b094060f5b2f1ce98fb53Behdad Esfahbod CaretValueFormat1 format1[VAR]; 185d3480ba37fbb5d4be75b094060f5b2f1ce98fb53Behdad Esfahbod CaretValueFormat2 format2[VAR]; 186d3480ba37fbb5d4be75b094060f5b2f1ce98fb53Behdad Esfahbod CaretValueFormat3 format3[VAR]; 1874c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod } u; 1884c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod}; 1891f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod 19060d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct LigGlyph 19160d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 192e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod inline unsigned int get_lig_carets (hb_ot_layout_context_t *context, 193e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod hb_codepoint_t glyph_id, 194e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int start_offset, 195e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int *caret_count /* IN/OUT */, 196e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod int *caret_array /* OUT */) const 19762964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod { 198e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod if (caret_count) { 19948de3730cdf91b9f6473509e22260a902ccec992Behdad Esfahbod const OffsetTo<CaretValue> *array = carets.const_sub_array (start_offset, caret_count); 20048de3730cdf91b9f6473509e22260a902ccec992Behdad Esfahbod unsigned int count = *caret_count; 201e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod for (unsigned int i = 0; i < count; i++) 202e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod caret_array[i] = (this+array[i]).get_caret_value (context, glyph_id); 203e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod } 20462964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod 205e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod return carets.len; 20662964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod } 2077586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod 208e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod inline bool sanitize (SANITIZE_ARG_DEF) { 2093e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 2103564ee5216004d45d30b0ded61184cf8dde5dd89Behdad Esfahbod return SANITIZE_THIS (carets); 211e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod } 212e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod 21360d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod private: 2145f810363acc3ad3cba631a68620e3d37e54c95c4Behdad Esfahbod OffsetArrayOf<CaretValue> 2153564ee5216004d45d30b0ded61184cf8dde5dd89Behdad Esfahbod carets; /* Offset array of CaretValue tables 216e4efdd80a8fa4edbcdec9cd84f35f5f4521943c2Behdad Esfahbod * --from beginning of LigGlyph table 217e4efdd80a8fa4edbcdec9cd84f35f5f4521943c2Behdad Esfahbod * --in increasing coordinate order */ 2181f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod}; 2198b8358033184198ff638ee1379093717596e162dBehdad EsfahbodASSERT_SIZE (LigGlyph, 2); 220b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod 22160d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct LigCaretList 22260d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 223e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod inline unsigned int get_lig_carets (hb_ot_layout_context_t *context, 224e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod hb_codepoint_t glyph_id, 225e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int start_offset, 226e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int *caret_count /* IN/OUT */, 227e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod int *caret_array /* OUT */) const 228855720ca47bf5a7a44eb5b84dce9f7da6e7156bdBehdad Esfahbod { 22979420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod unsigned int index = (this+coverage) (glyph_id); 23062964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod if (index == NOT_COVERED) 23162964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod { 232e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod if (caret_count) 233e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod *caret_count = 0; 234e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod return 0; 23562964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod } 23662964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod const LigGlyph &lig_glyph = this+ligGlyph[index]; 237e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod return lig_glyph.get_lig_carets (context, glyph_id, start_offset, caret_count, caret_array); 238855720ca47bf5a7a44eb5b84dce9f7da6e7156bdBehdad Esfahbod } 23912360f7c159826ae72271b34486dee59d96aa8caBehdad Esfahbod 240e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod inline bool sanitize (SANITIZE_ARG_DEF) { 2413e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 242e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod return SANITIZE_THIS2 (coverage, ligGlyph); 243e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod } 244e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod 24512360f7c159826ae72271b34486dee59d96aa8caBehdad Esfahbod private: 2463d54bd1293069fc3d3bdeeea8ad45036f3ee65f3Behdad Esfahbod OffsetTo<Coverage> 2473d54bd1293069fc3d3bdeeea8ad45036f3ee65f3Behdad Esfahbod coverage; /* Offset to Coverage table--from 24812360f7c159826ae72271b34486dee59d96aa8caBehdad Esfahbod * beginning of LigCaretList table */ 2495f810363acc3ad3cba631a68620e3d37e54c95c4Behdad Esfahbod OffsetArrayOf<LigGlyph> 2505f810363acc3ad3cba631a68620e3d37e54c95c4Behdad Esfahbod ligGlyph; /* Array of LigGlyph tables 2515f810363acc3ad3cba631a68620e3d37e54c95c4Behdad Esfahbod * in Coverage Index order */ 25212360f7c159826ae72271b34486dee59d96aa8caBehdad Esfahbod}; 2538b8358033184198ff638ee1379093717596e162dBehdad EsfahbodASSERT_SIZE (LigCaretList, 4); 25412360f7c159826ae72271b34486dee59d96aa8caBehdad Esfahbod 255e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod 256e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbodstruct MarkGlyphSetsFormat1 257e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod{ 258e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const 259e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod { return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; } 260e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod 261e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod inline bool sanitize (SANITIZE_ARG_DEF) { 2623e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 263e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod return SANITIZE_THIS (coverage); 264e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod } 265e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod 266e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod private: 267e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod USHORT format; /* Format identifier--format = 1 */ 268e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod LongOffsetArrayOf<Coverage> 269e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod coverage; /* Array of long offsets to mark set 270e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod * coverage tables */ 271e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod}; 272e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad EsfahbodASSERT_SIZE (MarkGlyphSetsFormat1, 4); 273e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod 274e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbodstruct MarkGlyphSets 275e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod{ 276e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const 277e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod { 278e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod switch (u.format) { 279e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod case 1: return u.format1->covers (set_index, glyph_id); 280e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod default:return false; 281e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod } 282e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod } 283e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod 284e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod inline bool sanitize (SANITIZE_ARG_DEF) { 2853e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 286e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod if (!SANITIZE (u.format)) return false; 287e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod switch (u.format) { 288e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod case 1: return u.format1->sanitize (SANITIZE_ARG); 289e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod default:return true; 290e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod } 291e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod } 292e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod 293e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod private: 294e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod union { 295e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod USHORT format; /* Format identifier */ 296d3480ba37fbb5d4be75b094060f5b2f1ce98fb53Behdad Esfahbod MarkGlyphSetsFormat1 format1[VAR]; 297e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod } u; 298e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod}; 299e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod 300e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod 3011f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod/* 302aefaafe5bc4fc6d37a412c135b1079c287be7045Behdad Esfahbod * GDEF 3031f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod */ 304b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod 30560d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct GDEF 30660d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 307a328d66e6a8122f7d4d71941449d4d0136203e08Behdad Esfahbod static const hb_tag_t Tag = HB_OT_TAG_GDEF; 308600e5eb80f553ea8eb862e6784133574c74ca513Behdad Esfahbod 3094fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod enum { 3104fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod UnclassifiedGlyph = 0, 3114fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod BaseGlyph = 1, 3124fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod LigatureGlyph = 2, 3134fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod MarkGlyph = 3, 3148f034d5849627ee95a5889fa34c9ba294fff13caBehdad Esfahbod ComponentGlyph = 4 3154fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod }; 316aff831ed6787abe8e24a977e34d97ff2e0b7dc21Behdad Esfahbod 317cd3827ee567612c5500206b62840702fc956e0f5Behdad Esfahbod STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GDEF, 1, 1); 318b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod 3199e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod inline bool has_glyph_classes () const { return glyphClassDef != 0; } 320e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod inline hb_ot_layout_class_t get_glyph_class (hb_codepoint_t glyph) const 32179420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod { return (this+glyphClassDef).get_class (glyph); } 322b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod 3239e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod inline bool has_mark_attachment_types () const { return markAttachClassDef != 0; } 324e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod inline hb_ot_layout_class_t get_mark_attachment_type (hb_codepoint_t glyph) const 32579420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod { return (this+markAttachClassDef).get_class (glyph); } 32679420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod 32779420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod inline bool has_attach_points () const { return attachList != 0; } 328e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod inline unsigned int get_attach_points (hb_codepoint_t glyph_id, 329e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int start_offset, 330e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int *point_count /* IN/OUT */, 331e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int *point_array /* OUT */) const 332e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod { return (this+attachList).get_attach_points (glyph_id, start_offset, point_count, point_array); } 333b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod 33479420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod inline bool has_lig_carets () const { return ligCaretList != 0; } 335e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod inline unsigned int get_lig_carets (hb_ot_layout_context_t *context, 336e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod hb_codepoint_t glyph_id, 337e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int start_offset, 338e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int *caret_count /* IN/OUT */, 339e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod int *caret_array /* OUT */) const 340e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod { return (this+ligCaretList).get_lig_carets (context, glyph_id, start_offset, caret_count, caret_array); } 341b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod 342e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod inline bool has_mark_sets () const { return version >= 0x00010002 && markGlyphSetsDef[0] != 0; } 343e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const 344e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod { return version >= 0x00010002 && (this+markGlyphSetsDef[0]).covers (set_index, glyph_id); } 345e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod 34620b035dad41247076815a2bbb0346d63058b322fBehdad Esfahbod inline bool sanitize (SANITIZE_ARG_DEF) { 3473e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 348e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod if (!SANITIZE (version)) return false; 349e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod if (version.major != 1) return true; 350e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod return SANITIZE_THIS2 (glyphClassDef, attachList) && 351e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod SANITIZE_THIS2 (ligCaretList, markAttachClassDef) && 352e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod (version < 0x00010002 || SANITIZE_THIS (markGlyphSetsDef[0])); 353e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod } 354e49a84c9e37c08808880e74e94c8160731ababa1Behdad Esfahbod 355238c855fcd4f0ef97a94a8662d2a2f2bb5c21ecbBehdad Esfahbod private: 356e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod FixedVersion version; /* Version of the GDEF table--currently 357e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod * 0x00010002 */ 3589e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod OffsetTo<ClassDef> 3599e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod glyphClassDef; /* Offset to class definition table 360b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod * for glyph type--from beginning of 3611f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod * GDEF header (may be Null) */ 3629e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod OffsetTo<AttachList> 3639e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod attachList; /* Offset to list of glyphs with 364b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod * attachment points--from beginning 3651f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod * of GDEF header (may be Null) */ 3669e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod OffsetTo<LigCaretList> 3679e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod ligCaretList; /* Offset to list of positioning points 368b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod * for ligature carets--from beginning 3691f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod * of GDEF header (may be Null) */ 3709e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod OffsetTo<ClassDef> 3719e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod markAttachClassDef; /* Offset to class definition table for 372b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod * mark attachment type--from beginning 3731f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod * of GDEF header (may be Null) */ 374e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod OffsetTo<MarkGlyphSets> 375d3480ba37fbb5d4be75b094060f5b2f1ce98fb53Behdad Esfahbod markGlyphSetsDef[VAR]; /* Offset to the table of mark set 376e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod * definitions--from beginning of GDEF 377e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod * header (may be NULL). Introduced 378e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod * in version 00010002. */ 379b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod}; 380d3480ba37fbb5d4be75b094060f5b2f1ce98fb53Behdad EsfahbodASSERT_SIZE_VAR (GDEF, 12, OffsetTo<MarkGlyphSets>); 381b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod 3826f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 3835f5b24f99f52bbc922e238b65c06061ba07c8548Behdad Esfahbod#endif /* HB_OT_LAYOUT_GDEF_PRIVATE_HH */ 384